阅读量:0
Oracle的all_objects
视图包含了当前用户可访问的所有对象的信息,包括表、视图、索引、存储过程等
查看所有对象:
SELECT object_name, object_type, owner FROM all_objects;
根据对象类型筛选:
SELECT object_name, object_type, owner FROM all_objects WHERE object_type = 'TABLE';
根据对象名称搜索:
SELECT object_name, object_type, owner FROM all_objects WHERE object_name LIKE '%EMP%';
查看指定用户下的所有对象:
SELECT object_name, object_type FROM all_objects WHERE owner = 'SCOTT';
查看表结构:
SELECT column_name, data_type, data_length, nullable FROM all_tab_columns WHERE table_name = 'EMPLOYEES';
查看存储过程或函数的源代码:
SELECT text FROM all_source WHERE name = 'MY_PROCEDURE' AND type = 'PROCEDURE';
查看索引信息:
SELECT index_name, table_name, index_type, uniqueness FROM all_indexes WHERE table_owner = 'SCOTT';
查看约束信息:
SELECT constraint_name, constraint_type, table_name FROM all_constraints WHERE owner = 'SCOTT';
查看触发器信息:
SELECT trigger_name, table_name, trigger_type, triggering_event FROM all_triggers WHERE owner = 'SCOTT';
通过这些示例,你可以利用all_objects
视图和其他相关视图来管理和查询Oracle数据库中的元数据。在实际应用中,你可能需要根据自己的需求编写更复杂的查询语句。