我正在开发一个 Oracle 数据库模式可视化工具。因此,作为第一步,我想,我首先需要获取所有模式详细信息(表和表之间的关系,也可能是约束)。
要获取该信息,返回结果的 SQL 命令是什么?
(该DESCRIBE命令不返回所有表的信息)
编辑#1:
实际上,我想做的是获取我提到的所有表的所有信息(列、行、外键、约束),将它们存储在 MongoDB 数据库中,然后创建可视化(不包括图表)
Mag*_*ier 10
我做了类似的事情。我直接从 Oracle DB 通过 OPENQUERY 语句从 SQL Server 读取这些内容,并将结果保存到 SQL Server 表中,以便分析历史比较模式信息和更改。
因此,您需要对以下查询的结果集做的是以某种方式存储它们(定期)并向其添加某种唯一/主键或时间戳,以便区分不同的扫描。
抛开 SQL Server 特定的代码内容,这些是我迄今为止使用的基本 Oracle SQL 查询:
--Tables
SELECT table_name, owner, Tablespace_name, Num_Rows
FROM all_tables WHERE tablespace_name is not NULL
AND owner not in ('SYS', 'SYSTEM')
ORDER BY owner, table_name;
--Columns
SELECT OWNER, TABLE_NAME, Column_name, Data_type, data_length, data_precision, NULLABLE, character_Set_Name
From all_tab_cols
where USER_GENERATED = 'YES'
AND owner not in ('SYS', 'SYSTEM');
--Indexes
select Owner, index_name, table_name, uniqueness,BLEVEL,STATUS from ALL_INDEXES
WHERE owner not in ('SYS', 'SYSTEM')
--Constraints
select owner, constraint_name, constraint_type, table_name, search_condition, status, index_name, index_owner
From all_constraints
WHERE generated = 'USER NAME'
AND owner not in ('SYS', 'SYSTEM')
--Role Previleges
select grantee, granted_role, admin_option, delegate_option, default_role, common
From DBA_ROLE_PRIVS
--Sys Privileges
select grantee, privilege, admin_option, common
From DBA_SYS_PRIVS
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
31464 次 |
| 最近记录: |