15 useful PostgreSQL commands

15 useful PostgreSQL commands

GETTING INFORMATION ABOUT A DATABASE

Database size

Table list

Table size

Name of the largest table

  • relname is the name of a table, index, view, etc.
  • relpages — the size of this table view on disk in the number of pages (by default, one page is equal to 8 Kb).
  • pg_class — the system table that contains information about the database table links.

List of connected users

User activity

WORKING WITH DATA AND TABLE FIELDS

Deletion of identical rows

  • duplicated rows,
  • situations when one or more columns are duplicated (if these columns are supposed to be used as the primary key).

SAFE CHANGE OF FIELD TYPE

SEARCH FOR “LOST” VALUES

The first way

The second way

COUNTING THE NUMBER OF ROWS IN A TABLE

TRANSACTION USAGE

  • Let us start the transaction using the BEGIN command.
  • To roll back all operations located after BEGIN, use the ROLLBACK command.
  • The COMMIT command shall be used to apply the ROLLBACK command.

VIEWING AND FINISHING EXECUTABLE QUERIES

WORKING WITH CONFIGURATION

Search and change the location of a cluster instance

Getting a list of available data types

  • typname is the name of the data type;
  • typlen is the size of the data type.

CHANGING DBMS SETTINGS WITHOUT REBOOTING

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Akademily

Akademily

38 Followers

We conduct reviews, guides and comparative tests of gaming laptops, monitors, graphics cards, keyboards, mouses, headsets and chairs to help you buy the best ga