以ä¸ã¡ã¢æ¸ãã§ãã
Postgresã«ã¦ãã¼ãã«ä¸è¦§ã¨ãã«ã©ã ä¸è¦§ã¨ãå種æ
å ±ãåå¾ããããã®SQLã§ãã
ééãã¦ãããæãã¦ãã ãããm(_ _)m
[ãã¼ãã«ä¸è¦§åå¾]
select relname as TABLE_NAME from pg_stat_user_tables
[ã«ã©ã ä¸è¦§]
select * from information_schema.columns where table_catalog='ãã¼ã¿ãã¼ã¹å' and table_name='ãã¼ãã«å' order by ordinal_position;
[ãã©ã¤ããªã¼ãã¼æ
å ±åå¾]
select ccu.column_name as COLUMN_NAME from information_schema.table_constraints tc ,information_schema.constraint_column_usage ccu where tc.table_catalog='ãã¼ã¿ãã¼ã¹å' and tc.table_name='ãã¼ãã«å' and tc.constraint_type='PRIMARY KEY' and tc.table_catalog=ccu.table_catalog and tc.table_schema=ccu.table_schema and tc.table_name=ccu.table_name and tc.constraint_name=ccu.constraint_name
[ãã¼ãã«ã®ã³ã¡ã³ããåå¾]
select psut.relname as TABLE_NAME ,pd.description as TABLE_COMMENT from pg_stat_user_tables psut ,pg_description pd where psut.relname='ãã¼ãã«å' and psut.relid=pd.objoid and pd.objsubid=0
[ã«ã©ã ã®ã³ã¡ã³ããåå¾]
select psat.relname as TABLE_NAME, pa.attname as COLUMN_NAME, pd.description as COLUMN_COMMENT from pg_stat_all_tables psat ,pg_description pd ,pg_attribute pa where psat.schemaname=(select schemaname from pg_stat_user_tables where relname = 'ãã¼ãã«å') and psat.relname='ãã¼ãã«å' and psat.relid=pd.objoid and pd.objsubid<>0 and pd.objoid=pa.attrelid and pd.objsubid=pa.attnum order by pd.objsubid
ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼
éå»ã®è¨äºã«ã¤ãã¦ã¯ã以ä¸ã®ãã¼ã¸ãããåç
§ä¸ããã
- ããããåå¿é²æ¥è¨ã¾ã¨ã