- Learning PostgreSQL 10(Second Edition)
- Salahaldin Juba Andrey Volkov
- 407字
- 2021-07-02 22:42:10
PostgreSQL utility tools
Several PostgreSQL utility tools are wrappers around SQL constructs. These tools are used to create and drop databases, users and languages. For example, dropdb and createdb commands are wrappers around DROP DATABASE [ IF EXISTS ] and CREATE DATABASE respectively.
Also PostgreSQL provide tools to maintain the system objects, mainly clusterdb and reindexdb. The clusterdb is a wrapper around the CLUSTER statement, which is used to physically reorder the table based on a certain index information. This can increase database performance read operation due to the locality of reference principles, mainly spatial locality. Clustering the table helps in retrieving data from adjacent storage blocks and thus reduces hard disk access cost.
reindexdb tool is a wrapper a round around reindex SQL statement. There are several reasons to reindex an index, for example, the index might get corrupted--which rarely happens in practice--or bloated.
In addition to the previous ones, postgreSQL provides tools for the following:
- Physical backup: This is used to back up the PostgreSQL database files by taking a hard disk snapshot. This method is a very fast way to create a backup, but the backup can only be restored on compatible PostgreSQL versions. The tool pg_basebackup is used for this purpose. The pg_basebackup is often used for setting up streaming replication as the slave is a clone of a master.
- Logical backup: This is used to back up the database objects in the form of SQL statements such as CREATE TABLE, CREATE VIEW, COPY, and so on. The generated backup can be restored on different PostgreSQL cluster versions, but it is slow. The tools pg_dump, pg_dumpall are used to dump a single database or a database cluster respectively. pg_dump also can be used to dump a specific relation or set of relation and schema. Also it has a lot of features such as dumping schema only or data only. pg_dumpall internally uses pg_dump to dump all databases on the cluster. Finally, the pg_restore tool is used to restore the dumps generated by pg_dump or pg_dumpall.
pg_dump does not dump the CREATE DATABASE statement command. For example, one can dump a database called customer to another database called client. Due to this, if you have a special privileges assigned to the database such as CONNECT, you need to assign these privileges to the new database.
- Word 2003、Excel 2003、PowerPoint 2003上機(jī)指導(dǎo)與練習(xí)
- Microsoft Dynamics CRM Customization Essentials
- Mastering Hadoop 3
- Google Cloud Platform Cookbook
- Mastering Salesforce CRM Administration
- 數(shù)據(jù)運(yùn)營之路:掘金數(shù)據(jù)化時(shí)代
- JMAG電機(jī)電磁仿真分析與實(shí)例解析
- 大型數(shù)據(jù)庫管理系統(tǒng)技術(shù)、應(yīng)用與實(shí)例分析:SQL Server 2005
- RPA(機(jī)器人流程自動(dòng)化)快速入門:基于Blue Prism
- 分析力!專業(yè)Excel的制作與分析實(shí)用法則
- 氣動(dòng)系統(tǒng)裝調(diào)與PLC控制
- C++程序設(shè)計(jì)基礎(chǔ)(上)
- 單片機(jī)技術(shù)項(xiàng)目化原理與實(shí)訓(xùn)
- Hands-On Microservices with C#
- 我的IT世界