postgreSQL - RayGutt/PersonalWiki GitHub Wiki

psql tricks

get info on the current connection:

\conninfo

list databases:

\list

switch database:

\connect dbname
# or
\c dbname

show tables in the current database:

\dt

describe a table:

\d table_name
# or
\d+ table_name

# or, for a simpler output
SELECT
	COLUMN_NAME
FROM
	information_schema.COLUMNS
WHERE
	TABLE_NAME = 'table_name';
⚠️ **GitHub.com Fallback** ⚠️