- 在 mysql 中可以用
SHOW TABLES
來查看目前database中有那些 tables, 而在 PostgreSQL 中, 有兩種方法:- 如果是用 psql 連到 database 中的話可以使用
\dt
這個指令來看. - 或是直接使用 SQL 語法來查詢:
SELECT table_name FROM information_schema.tables WHERE table_schema = 'public';
- Reference:
- 如果是用 psql 連到 database 中的話可以使用
*** The user comment on the postgresql document page *** Display or show tables in a PostgreSQL/PgSQL database on tech-recipes
* GROUP BY
**SELECT
column_nameFROM
table_nameGROUP BY
column_name;
**SELECT table_catalog FROM information_schema.tables WHERE table_schema = 'public' GROUP BY table_catalog;
/* Will display all table_catalogs but the sames will appear once only */
* LIKE
**SELECT * FROM
table_nameWHERE
stringLIKE
pattern;
**SELECT table_name FROM information_schema.tables WHERE table_schema = 'public' AND table_name LIKE 'm%';
/* Will display all tables whose table_name starts with m*/