# Postgres

# psql

show all tables in all schema

\dt *.*

show all tables in schema hhh

\dt hhh.*


After a query has produced an output table (after the select list has been processed) it can optionally be sorted. If sorting is not chosen, the rows will be returned in an unspecified order. The actual order in that case will depend on the scan and join plan types and the order on disk, but it must not be relied on. A particular output ordering can only be guaranteed if the sort step is explicitly chosen. (opens new window)

The PostgreSQL Catalog

PostgreSQL stores the metadata information about the database and cluster in the schema 'pg_catalog'. This information is partially used by PostgreSQL itself to keep track of things itself, but it also is presented so external people / processes can understand the inside of the databases too.

what is COLLATE pg_catalog."default

oid

查看连接

select * from pg_stat_activity;

pg_dump 某一张表
pg_dump --host aaa.bbb.ccc.ddd --port 5432 --username user_name --format plain --verbose --file "output.sql" --table schems.table_name database_name

删除 schema 以及内部的所有表

drop schema schema_name cascade

查看某个表的 oid

select 'table_name'::regclass::oid

查看某个 schema 的 oid

SELECT 'public'::regnamespace::oid;

OIDs assigned during normal database operation are constrained to be 16384 or higher. This ensures that the range 10000—16383 is free for OIDs assigned automatically by genbki.pl or during bootstrap. These automatically-assigned OIDs are not considered stable, and may change from one installation to another. (opens new window)