Postgresql数据库的系统表初探

1.在psql中可以使用/dS(区分大小写)查看系统表,如下:

                      关联列表
 /xBC芄/xB9模式 |          名/xB3           | 型/xB1  |   拥有者
------------+--------------------------+--------+----------
 pg_catalog | pg_aggregate             | 资料/xB1 | postgres
 pg_catalog | pg_am                    | 资料/xB1 | postgres
 pg_catalog | pg_amop                  | 资料/xB1 | postgres
 pg_catalog | pg_amproc                | 资料/xB1 | postgres
 pg_catalog | pg_attrdef               | 资料/xB1 | postgres
 pg_catalog | pg_attribute             | 资料/xB1 | postgres
 pg_catalog | pg_auth_members          | 资料/xB1 | postgres
 pg_catalog | pg_authid                | 资料/xB1 | postgres
 pg_catalog | pg_autovacuum            | 资料/xB1 | postgres
 pg_catalog | pg_cast                  | 资料/xB1 | postgres
 pg_catalog | pg_class                 | 资料/xB1 | postgres
 pg_catalog | pg_constraint            | 资料/xB1 | postgres
 pg_catalog | pg_conversion            | 资料/xB1 | postgres
 pg_catalog | pg_cursors               | 视/xB9郾 | postgres
 pg_catalog | pg_database              | 资料/xB1 | postgres
 pg_catalog | pg_depend                | 资料/xB1 | postgres
 pg_catalog | pg_description           | 资料/xB1 | postgres
 pg_catalog | pg_enum                  | 资料/xB1 | postgres
 pg_catalog | pg_group                 | 视/xB9郾 | postgres
 pg_catalog | pg_index                 | 资料/xB1 | postgres
 pg_catalog | pg_indexes               | 视/xB9郾 | postgres
 pg_catalog | pg_inherits              | 资料/xB1 | postgres
 pg_catalog | pg_language              | 资料/xB1 | postgres
 pg_catalog | pg_largeobject           | 资料/xB1 | postgres
 pg_catalog | pg_listener              | 资料/xB1 | postgres
 pg_catalog | pg_locks                 | 视/xB9郾 | postgres
 pg_catalog | pg_namespace             | 资料/xB1 | postgres
 pg_catalog | pg_opclass               | 资料/xB1 | postgres
 pg_catalog | pg_operator              | 资料/xB1 | postgres
 pg_catalog | pg_opfamily              | 资料/xB1 | postgres
 pg_catalog | pg_pltemplate            | 资料/xB1 | postgres
 pg_catalog | pg_prepared_statements   | 视/xB9郾 | postgres
 pg_catalog | pg_prepared_xacts        | 视/xB9郾 | postgres
 pg_catalog | pg_proc                  | 资料/xB1 | postgres
 pg_catalog | pg_rewrite               | 资料/xB1 | postgres
 pg_catalog | pg_roles                 | 视/xB9郾 | postgres
 pg_catalog | pg_rules                 | 视/xB9郾 | postgres
 pg_catalog | pg_settings              | 视/xB9郾 | postgres
 pg_catalog | pg_shadow                | 视/xB9郾 | postgres
 pg_catalog | pg_shdepend              | 资料/xB1 | postgres
 pg_catalog | pg_shdescription         | 资料/xB1 | postgres
 pg_catalog | pg_stat_activity         | 视/xB9郾 | postgres
 pg_catalog | pg_stat_all_indexes      | 视/xB9郾 | postgres
 pg_catalog | pg_stat_all_tables       | 视/xB9郾 | postgres
 pg_catalog | pg_stat_bgwriter         | 视/xB9郾 | postgres
 pg_catalog | pg_stat_database         | 视/xB9郾 | postgres
 pg_catalog | pg_stat_sys_indexes      | 视/xB9郾 | postgres
 pg_catalog | pg_stat_sys_tables       | 视/xB9郾 | postgres
 pg_catalog | pg_stat_user_indexes     | 视/xB9郾 | postgres
 pg_catalog | pg_stat_user_tables      | 视/xB9郾 | postgres
 pg_catalog | pg_statio_all_indexes    | 视/xB9郾 | postgres
 pg_catalog | pg_statio_all_sequences  | 视/xB9郾 | postgres
 pg_catalog | pg_statio_all_tables     | 视/xB9郾 | postgres
 pg_catalog | pg_statio_sys_indexes    | 视/xB9郾 | postgres
 pg_catalog | pg_statio_sys_sequences  | 视/xB9郾 | postgres
 pg_catalog | pg_statio_sys_tables     | 视/xB9郾 | postgres
 pg_catalog | pg_statio_user_indexes   | 视/xB9郾 | postgres
 pg_catalog | pg_statio_user_sequences | 视/xB9郾 | postgres
 pg_catalog | pg_statio_user_tables    | 视/xB9郾 | postgres
 pg_catalog | pg_statistic             | 资料/xB1 | postgres
 pg_catalog | pg_stats                 | 视/xB9郾 | postgres
 pg_catalog | pg_tables                | 视/xB9郾 | postgres
 pg_catalog | pg_tablespace            | 资料/xB1 | postgres
 pg_catalog | pg_timezone_abbrevs      | 视/xB9郾 | postgres
 pg_catalog | pg_timezone_names        | 视/xB9郾 | postgres
 pg_catalog | pg_trigger               | 资料/xB1 | postgres
 pg_catalog | pg_ts_config             | 资料/xB1 | postgres
 pg_catalog | pg_ts_config_map         | 资料/xB1 | postgres
 pg_catalog | pg_ts_dict               | 资料/xB1 | postgres
 pg_catalog | pg_ts_parser             | 资料/xB1 | postgres
 pg_catalog | pg_ts_template           | 资料/xB1 | postgres
 pg_catalog | pg_type                  | 资料/xB1 | postgres
 pg_catalog | pg_user                  | 视/xB9郾 | postgres
 pg_catalog | pg_views                 | 视/xB9郾 | postgres
(74 笔资料列)

 

2.记录数据库信息的基本表pg_database

查看所有数据库名称

select datname from information_schema.database;

 

3.记录当前数据库所有表的表pg_tables

查询出用户表的SQL语句:

select table_name from information_schema.tables where table_schema = 'pub
lic' and table_type = 'BASE TABLE' and is_insertable_into = 'YES';

 

4.记录当前数据库所有表的所有字段的表pg_columns

查询出指定表article的字段的SQL语句:

select column_name, is_nullable, data_type from information_schema.columns where table_name = 'article';

 

注意,这些表使用时要注明schema,即information_schema

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值