postgresql数据库及表信息,字段查询
数据库恢复查询pgsql数据库(及其⼤⼩)
select pg_database.datname, pg_size_pretty (pg_database_size(pg_database.datname))AS size from pg_database;
支付宝支付密码被锁定怎么办以本地postgres库为例
结果:[(‘postgres’, ‘7723 kB’), (‘test’, ‘7683 kB’), (‘template1’, ‘7521 kB’), (‘template0’, ‘7521 kB’)]查询pgsql数据库下有哪些模式
SELECT*FROM information_schema.schemata;
Ps:
选择的是postgres数据库
conn = t(database="postgres", user="postgres", password="*", host="localhost", port="5432")
返回:[(‘postgres’, ‘information_schema’, ‘postgres’, None, None, None, None), (‘postgres’, ‘public’,
‘postgres’, None, None, None, None), (‘postgres’, ‘pg_catalog’, ‘postgres’, None, None, None, None),
(‘postgres’, ‘pg_toast_temp_1’, ‘postgres’, None, None, None, None), (‘postgres’, ‘pg_temp_1’, ‘postgres’, None, None, None, None), (‘postgres’, ‘pg_toast’, ‘postgres’, None, None, None, None)]
⿊⾊加粗为postgres库下的模式什么专业就业前景好
查询pgsql模式下有哪些表
select tablename from pg_tables where schemaname='public';--这⾥是public模式
返回:[(‘titles_test’,), (‘ctrip_hotel_order’,), (‘testtest’,)]
查看pgsql视图下有哪些表
SELECT viewname FROM pg_views WHERE schemaname ='public';
查询pgsql表的信息
2022的第一个红包发多少合适查询列名
老人家生日祝词冰箱结冰是什么原因造成的select*from lumns where table_schema='public'and table_name='titles_test';
查看pgsql表的注释
select relname as tabname,cast(obj_description(relfilenode,'pg_class')as varchar)as comment from pg_class c where relkind ='r'and relname not like'pg _%'and relname not like'sql_%'and relname='表名';
select relname as tabname,cast(obj_description(relfilenode,'pg_class')as varchar)as comment from p
g_class c where relkind ='r'and relname not like'pg _%'and relname not like'sql_%'order by relname;--所有表的
获取pgsql表的字段名、类型、注释、是否为空:(可以查视图的)
SELECT a.attname,col_description(a.attrelid,a.attnum)as comment,format_type(a.atttypid,a.atttypmod)as type,a.attname as name, a.attnotnull as notnull FROM pg_class as c,pg_attribute as a lname ='zhpjzb'and a.attrelid = c.oid and a.attnum>0;
ps:
(select oid from pg_class where relname = ‘表名’;
select * from pg_attribute where attrelid = ‘29279856’; )
表名的oid和pg_attribute⾥⾯的attrelid关联
查看前⼏⾏
select*from表名limit10;
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论