1. 查询表名称

在psql状态下查询表名称

\dt  



SQL方式查看表名称

 SELECT tablename FROM pg_tables;  

 

SELECT   viewname   FROM   pg_views  
WHERE     schemaname ='public'  

PostgreSQL获取数据库中所有view名 视图

SELECT   viewname   FROM   pg_views  
WHERE     schemaname ='public'

2. 查询表结构

在psql状态下查询表结构

 \d tablename  


SQL方式查看表结构

SELECT a.attnum,
a.attname AS field,
t.typname AS type,
a.attlen AS length,
a.atttypmod AS lengthvar,
a.attnotnull AS notnull,
b.description AS comment
FROM pg_class c,
pg_attribute a
LEFT OUTER JOIN pg_description b ON a.attrelid=b.objoid AND a.attnum = b.objsubid,
pg_type t
WHERE c.relname = 'udoc_saldiscount'
and a.attnum > 0
and a.attrelid = c.oid
and a.atttypid = t.oid
ORDER BY a.attnum;

相关文章:

  • 2021-10-29
  • 2021-12-08
  • 2021-10-14
  • 2022-12-23
  • 2022-12-23
  • 2021-10-13
猜你喜欢
  • 2022-12-23
  • 2022-02-19
  • 2022-01-12
  • 2022-12-23
  • 2021-11-27
  • 2021-07-26
相关资源
相似解决方案