Saturday, 12 December 2020

PostgreSQL Commands



 

Command

Description

\l   or \list

List all the databases created

\c  database_name

To connect a database

\dt  schema.*

List all the tables in a schema

\q

Quit

\db

List of tablespaces

\dn

List all schemas in postgres

\d

List of relations / Tables

\d  schema.table_name

Describe structure of the table

\dt *

All Tables

\dv *

All views

\ds *

All sequences

\e

(Edit) Modify the query buffer

\g

(Go) Execute the query buffer

\s

(Search) Last commands used

\r

(Reset) Clears the query buffer

SELECT spcname FROM pg_tablespace;

List all tablespaces

select * from pg_namespace;

List all schemas

\h

Display help on Command

\i

read name into query buffer (input)

\o name

Send output to name

\p

Display the query buffer

\t

Toggle the output headers on/ off

\w name

Write the query buffer to name

\!

Execute the Linux command

\?

Help on meta-commands

\x

display in transpose mode


Most of cases you can use '+' to display more information for same command.
e.f. \dt (display table information) \dt+ ( display table information with addition columns)

No comments:

Post a Comment

Featured post

duplicate db from standy to other server

 Duplicate Testuat   $ export ORACLE_SID=Testuat3 $ sqlplus '/as sysdba' Testuat3 SQL> alter system set cluster_database=FALSE sc...