数据字典的结构
数据字典命名规则
前缀 | 说明 |
USER | 用户自己的 |
ALL | 用户可以访问到的 |
DBA | 管理员视图 |
V$ | 性能相关的数据 |
如何使用数据字典视图
从DICTIONARY开始,这个数据对象包含了数据字典的表名和说明
DESCRIBE DICTIONARY
SELECT*
FROM dictionary
WHERE table_name= 'USER_OBJECTS';
USER_OBJECTS和ALL_OBJECTS
USER_OBJECTS:
USER_OBJECTS视图:
SELECTobject_name,object_type,created, status
FROM user_objects
ORDERBY object_type;
ALL_OBJECTS:
表的信息
USER_TABLES 用户自己的表:
DESCRIBE user_tables
SELECTtable_name
FROM user_tables;
列的信息
DESCRIBEuser_tab_columns
SELECT column_name,data_type,data_length,
data_precision,data_scale,nullable
FROM user_tab_columns
WHERE table_name= 'EMPLOYEES';
约束
DESCRIBE user_constraints
SELECT constraint_name,constraint_type,
search_condition,r_constraint_name,
delete_rule,status
FROM user_constraints
WHERE table_name= 'EMPLOYEES';
DESCRIBE user_cons_columns
SELECT constraint_name,column_name
FROM user_cons_columns
WHERE table_name= 'EMPLOYEES';
视图
DESCRIBE user_views
SELECTDISTINCT view_nameFROM user_views;
SELECT text FROM user_views
WHERE view_name= 'EMP_DETAILS_VIEW';
序列
DESCRIBE user_sequences
SELECT sequence_name,min_value,max_value,
increment_by,last_number
FROM user_sequences;
同义词
DESCRIBE user_synonyms
SELECT*
FROM user_synonyms;
给表添加注释
COMMENTON TABLE employees
IS 'Employee Information';
Commentcreated.