1. 程式人生 > >mysql 和 postgres 檢視資料庫結構命令

mysql 和 postgres 檢視資料庫結構命令

mysql 和 postgres 常用命令對比

1.檢視所有表

mysql: SHOW TABLES
postgresql: \d
postgresql: SELECT table_name FROM information_schema.tables WHERE table_schema = 'public'; (顯示public下的表,這樣指定schema可以過濾一些系統表)

2.檢視所有資料庫

mysql: SHOW DATABASES
postgresql: \l
postgresql: SELECT datname FROM pg_database;

3.查看錶結構

mysql: SHOW COLUMNS (或 DESCRIBE TABLE)
postgresql: \d table
postgresql: SELECT column_name FROM information_schema.columns WHERE table_name ='table';