postgresql数据库常用命令(1)
1、服务器版本号 select version();在PGDATA目录下cat PG_Version 2、服务器运行时间: select date_trunc('second',current_timestamp - pg_postmaster_start_time()) as server_duration; 3、列出数据库服务器上的数据库: psql -l ; l; select datname from pg_database; 4、列出数据库中的关系数量: psql -c "d";d;select count(*) FROM information_schema.tablesWHERE table_schema NOT IN ('information_schema','pg_catalog') 5、列出数据库使用多少空间: select sum(pg_database_size(datname)) from pg_database; 6、列出表使用多少空间: select pg_relation_size(relationName): (pg_total_relation_size(),包括索引等空间) ; dt+ relationName 7、最大的十个表; SELECT table_name,pg_relation_size(table_name) as sizeFROM information_schema.tablesWHERE table_schema NOT IN ('information_schema','pg_catalog') 8、表中有多少行记录: select count(*) from relationName; (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |