SELECT datname, Count(*) FROM pg_stat_activity GROUPBY datname;
順便附上 Sql Server 的查詢連線數方式
1 2 3 4 5 6
USEmaster
SELECT cntr_value AS User_Connections FROM sys.sysperfinfo AS sp WHERE sp.object_name = 'SQLServer:General Statistics' AND sp.counter_name = 'User Connections'
取得版本
1
SELECTversion();
列出資料表名稱
1 2 3 4
SELECT * FROM information_schema.TABLES WHERE table_schema = 'public' AND table_type = 'BASE TABLE'
SQL Server 的查詢方式相當簡單,還是附上好了
1
select @@VERSION
取得繼承關係的資料表
1 2 3 4 5 6 7
SELECT parent.relname AS parent_table, child.relname AS child_table FROM pg_inherits join pg_class ASchild ON ( inhrelid = child.oid ) join pg_class ASparent ON ( inhparent = parent.oid )