关于PostgreSQL数据库中的information_schema
来源:互联网 发布:大数据预测股票 编辑:程序博客网 时间:2024/05/21 14:09
本文是转载,转自:http://blog.itpub.net/22818880/viewspace-1966636/
Information_schema自动的存在于每个database中,里面包含了数据库中所有对象的定义信息。
Information_schema默认不存在于任何用户的search_path中,所以对所有用户都是隐藏的。\dn看不到,通过pgAdmin等客户端工具也不会自动显示。因此访问这个schema的任何视图都需要加上schema名。当然也可以通过修改search_path参数来访问。但PG不推荐这样做,因为里面的视图名称可能会跟用户应用程序中的对象名冲突。
Information_schema中的视图使用了几种特别的数据类型,如:cardinal_number 非负整数,yes_or_no相当于boolean
Information_schema中的视图基本都有权限校验,特定的用户只能看到特定的信息,也就是相当于Oracle中all_*开头的视图。其中几个重要的视图如下:
表信息:
information_schema.tables ,相当于Oracle中的all_tables
字段信息:
information_schema.columns,相当于Oracle中的all_tab_cloumns
procedure/function:
routines, 不包括package,因为pg不支持package
约束信息:
information_schema.table_constraints。另外在constraint_column_usage视图中有约束相关的字段信息;在referential_constraints中有关于外键约束的进一步的信息;在check_constraints中有关于check约束的进一步信息。key_column_usage记录了除check约束之外的其他约束相关的字段信息(check约束在check_constraints中已有记录)。
注意这个table_constraints不要跟constraint_table_usage搞混了。前者是记录了所有约束;而后者是记录了所有有相关约束的表(当然也有约束名显示),但不包括check约束。所以后者在我看来是没什么用的
权限信息:
table_privileges中记录了表权限,column_privileges中记录了列上的权限,routine_privileges上记录了function/procedure的权限,role_usage_grants记录了sequence/domain等类型的对象的usage权限,跟usage_privileges类似
在命令号里,\dp或\z也可以看到相关对象的授权信息
视图信息:
Views中记录视图基础信息,view_table_usage记录视图所依赖的表,view_routine_usage记录所依赖的function, view_column_usage记录所涉及的字段
另外sequece/trigger/schema等都有相关视图,要用到时直接查就好了。所以现在整个逻辑结构都差不多有答案了==============================至此,转载结束====================================================
另外的参考网址:
https://www.postgresql.org/docs/9.6/static/information-schema.html
- 关于PostgreSQL数据库中的information_schema
- 关于information_schema数据库
- 关于MySQL中的information_schema
- MySQL中的information_schema数据库详解
- 关于mysql中的information_schema.tables和information_schema.columns详解
- mysql数据库中的information_schema数据库介绍
- mysql数据库中的information_schema数据库详解
- mysql中的information_schema数据库表说明:
- INFORMATION_SCHEMA数据库
- 关于MySQL数据库的information_schema等的解释
- 服务器: localhost 数据库: information_schema
- 服务器: localhost 数据库: information_schema
- MySQL的information_schema数据库
- 23. INFORMATION_SCHEMA信息数据库
- MySQL的information_schema数据库
- mysql的information_schema数据库
- MySQL的information_schema数据库
- [mysql] information_schema数据库表
- Android studio出现:Your project path contains non-ASCII characters.
- GoogLeNet计算量大小估算
- oracle数据库学习笔记(二)之分组统计查询
- Kali linux 挂载Windows的ntfs分区简解
- 什么是离散化 NOIP
- 关于PostgreSQL数据库中的information_schema
- 线程管理之pthread_equal
- 影像平滑(blur、GaussianBlur)
- (22)Air Band OpenCV2.4.13_图像金字塔
- Html5 基础----列表详述
- 【Javascript】实现快速,选择,冒泡,插入排序
- 常见的 POST 提交数据方式
- try中有return语句,先执行return还是finally,执行顺序怎样的
- C#中静态与非静态方法比较