跳到主要内容

Oracle 视图

DBA_SEGMENTS​

DBA_SEGMENTS 视图描述的是数据库中所有段的存储和分配信息。

oracle=# \dS dba_segments
视图 "oracle.dba_segments"
栏位 | 类型 | 校对规则 | 可空的 | 预设
-----------------+-----------------------+----------+--------+------
owner | name | | |
segment_name | name | | |
segment_type | character varying(18) | | |
tablespace_name | name | | |
header_file | oid | | |
header_block | oid | | |
bytes | bigint | | |
blocks | integer | | |

备注:

  • owner:段所有者的用户名
  • segment_name:段名
  • segment_type:段的类型,可能是 table、index、logindex、lobsegment 等
  • tablespace_name:包含段的表空间名称
  • header_file:包含段头的文件的 ID
  • header_block:包含段头的块 ID
  • bytes:段的大小,以字节为单位
  • blocks:段的大小,以 Oracle 块为单位

PRODUCT_COMPONENT_VERSION​

PRODUCT_COMPONENT_VERSION 包含组件产品的版本和状态信息。

oracle=# \dS product_component_version
视图 "oracle.product_component_version"
栏位 | 类型 | 校对规则 | 可空的 | 预设
---------+------+----------+--------+------
product | text | C | |
version | text | C | |
status | text | | |

备注:

  • product:产品的名称
  • version:产品的版本号
  • status:产品状态,包括兼容性、高可用性

USER_CONS_COLUMNS​

user_cons_columns 视图提供了当前用户拥有的表中的约束中包含的所有列的信息。

oracle=# \dS user_cons_columns
视图 "oracle.user_cons_columns"
栏位 | 类型 | 校对规则 | 可空的 | 预设
-----------------+---------+----------+--------+------
owner | text | C | |
schema_name | text | C | |
constraint_name | text | C | |
table_name | text | C | |
column_name | text | C | |
position | integer | | |
constraint_def | text | | |

备注:

  • owner:约束的所有者
  • schema_name:约束所属的 schema
  • constraint_name:约束的名称
  • table_name:约束所属的表的名称
  • column_name:约束中引用的列的名称
  • position:列在约束中的位置(从 1 开始)
  • constraint_def:约束的定义文本

USER_CONSTRAINTS​

USER_CONSTRAINTS 视图提供了关于放置在当前用户拥有的表上的所有约束的信息。

oracle=# \dS user_constraints
视图 "oracle.user_constraints"
栏位 | 类型 | 校对规则 | 可空的 | 预设
-------------------+---------+----------+--------+------
owner | text | C | |
schema_name | text | C | |
constraint_name | text | C | |
constraint_type | text | | |
table_name | text | C | |
search_condition | text | | |
r_owner | text | C | |
r_constraint_name | text | C | |
delete_rule | text | | |
deferrable | boolean | | |
deferred | boolean | | |
index_owner | text | C | |
index_name | text | C | |
constraint_def | text | | |

备注:

  • owner:约束的所有者
  • schema_name:约束所属的 schema
  • constraint_name:约束的名称
  • constraint_type:约束类型:P—主键约束;U—唯一键约束;R—引用完整性约束;V—视图上的约束;O—视图只读
  • table_name:约束所属表的名称
  • search_condition:CHECK 约束的搜索条件文本
  • r_owner:被引用约束(外键引用的约束)的所有者
  • r_constraint_name:引用表的约束定义的名称
  • delete_rule:外键的删除规则(如 CASCADE、SET NULL)
  • deferrable:约束是否可延迟(是否允许推迟到事务结尾检查)
  • deferred:约束是否延迟到事务结尾检查
  • index_owner:索引的所有者
  • index_name:索引的名称
  • constraint_def:约束的定义文本

USER_IND_COLUMNS​

USER_IND_COLUMNS 描述当前用户拥有的索引的列和当前用户拥有的表上的索引的列。

oracle=# \dS user_ind_columns
视图 "oracle.user_ind_columns"
栏位 | 类型 | 校对规则 | 可空的 | 预设
-----------------+--------------+----------+--------+------
schema_name | text | C | |
index_name | text | C | |
table_name | text | C | |
column_name | text | C | |
column_position | smallint | | |
column_length | smallint | | |
char_length | numeric | | |
descend | character(1) | | |

备注:

  • schema_name:索引所属的 schema
  • index_name:索引名称
  • table_name:表或集群的名称
  • column_name:对象类型列的列名或属性
  • column_position:列在索引中的位置(从 1 开始)
  • column_length:列的长度(字节数)
  • char_length:列的字符长度
  • descend:该列在索引中是否降序排序(DESC 为降序,ASC 为升序)

USER_OBJECTS​

USER_OBJECTS 视图提供了当前用户拥有的所有对象的信息。

oracle=# \dS user_objects
视图 "oracle.user_objects"
栏位 | 类型 | 校对规则 | 可空的 | 预设
-------------+-------------------+----------+--------+------
schema_name | text | C | |
object_name | text | C | |
object_type | text | | |
status | character varying | | |
temporary | text | | |

备注:

  • schema_name:对象所属的 schema
  • object_name:对象的名称
  • object_type:对象的类型,可能的值是:索引、函数、包、包体、过程、序列、同义词、表、触发器和视图对象类型
  • status:对象的状态(VALID 表示有效)
  • temporary:对象是否为临时对象(Y 是临时对象,N 不是)

USER_PROCEDURES​

USER_PROCEDURES 列出当前用户拥有的所有函数和过程,以及它们的相关属性。

oracle=# \dS user_procedures
视图 "oracle.user_procedures"
栏位 | 类型 | 校对规则 | 可空的 | 预设
-------------+------+----------+--------+------
object_name | name | | |

备注:

  • object_name:对象的名称

USER_SOURCE​

USER_SOURCE 描述当前用户拥有的存储对象的文本源。

oracle=# \dS user_source
视图 "oracle.user_source"
栏位 | 类型 | 校对规则 | 可空的 | 预设
-------------+--------+----------+--------+------
schema_name | text | C | |
name | text | C | |
type | text | | |
line | bigint | | |
text | text | C | |

备注:

  • schema_name:对象所属的 schema
  • name:对象的名称
  • type:对象的类型:函数、JAVA 源代码、包、包体、过程、触发器、类型、类型体
  • line:源文件的行号
  • text:存储对象的文本源

USER_TAB_COLUMNS​

USER_TAB_COLUMNS 视图显示当前用户拥有的表和视图中所有列的信息。

oracle=# \dS user_tab_columns
视图 "oracle.user_tab_columns"
栏位 | 类型 | 校对规则 | 可空的 | 预设
----------------+-------------------+----------+--------+------
schema_name | character varying | C | |
table_name | character varying | C | |
column_name | character varying | C | |
data_type | character varying | | |
data_length | numeric | | |
data_precision | numeric | | |
data_scale | numeric | | |
nullable | character(1) | | |
column_id | numeric | | |
data_default | character varying | C | |

备注:

  • schema_name:表所属的 schema
  • table_name:列所在的表或视图的名称
  • column_name:列的名称
  • data_type:列的数据类型
  • data_length:文本列的长度
  • data_precision:NUMBER 列的精度(位数)
  • data_scale:NUMBER 列的比例
  • nullable:列是否为空,可能的值是:Y—列为空;N—列不允许为空
  • column_id:列在表中的相对位置
  • data_default:列的默认值表达式

USER_TABLES​

USER_TABLES 视图显示当前用户拥有的所有表的信息。

oracle=# \dS user_tables
视图 "oracle.user_tables"
栏位 | 类型 | 校对规则 | 可空的 | 预设
-----------------+-----------------------+----------+--------+------
schema_name | text | C | |
table_name | text | C | |
tablespace_name | text | C | |
status | character varying(5) | | |
degree | character varying(10) | | |
temporary | character(1) | | |

备注:

  • schema_name:表所属的 schema
  • table_name:表的名称
  • tablespace_name:表所在的表空间
  • status:表的状态(VALID 表示有效)
  • degree:表的并行度
  • temporary:表是否为临时表(Y 是临时表,N 不是)

USER_VIEWS​

USER_VIEWS 视图提供了当前用户拥有的所有视图的信息。

oracle=# \dS user_views
视图 "oracle.user_views"
栏位 | 类型 | 校对规则 | 可空的 | 预设
-------------+------+----------+--------+------
schema_name | text | C | |
view_name | text | C | |
text | text | | |

备注:

  • schema_name:视图所属的 schema
  • view_name:视图的名称
  • text:视图的文本定义(CREATE VIEW 的查询语句)

DUAL​

dual 是单行、单列表,仅为兼容 Oracle 数据库而提供。

oracle=# \dS dual
视图 "public.dual"
栏位 | 类型 | 校对规则 | 可空的 | 预设
-------+-------------------+----------+--------+------
dummy | character varying | | |

备注:

  • dummy:仅为兼容性提供