获取用户
-- 获取所有用户信息
select * from all_users;
-- 筛除系统用户
select * from all_users where common = 'NO';
-- 其他需求按条件查找
获取表
-- 获取所有表
select * from all_tables;
-- 获取A用户下的所有表信息
select * from all_tables where owner = 'A';
--
注释信息
-- 获取当前用户下所有表及注释
select * from user_tab_comments;
-- 某个表的注释
select * from user_tab_comments where table_name = 'AAAA';
-- 比user_tab_comments 多一个owner列,同时也是查的所有用户,所有表
select * from all_tab_comments;
-
判断表中某字段是否存在
SELECT COUNT(*) FROM all_tab_columns WHERE owner IN ( SELECT USERNAME FROM all_users WHERE common = 'NO' ) AND table_name = 'SJ_JCJLB' AND column_name = 'GZID' -- 注意:在Oracle中字段、表名等全部用大写匹配。 -- all_tab_columns 代表全部字段 user_tab_columns 当前用户字段 -- 直接用 all_tab_columns查询会特别慢(数据量很大),就把系统用户排除掉
-
检测表是否有注释
SELECT * FROM all_tab_comments WHERE OWNER IN ( SELECT USERNAME FROM ALL_USERS WHERE COMMON = 'NO' ) AND COMMENTS IS NULL;
-
查找字段注释为空的用户和表信息
SELECT * FROM ( SELECT owner, table_name FROM all_col_comments WHERE owner IN ( SELECT USERNAME FROM all_users WHERE common = 'NO' ) AND COMMENTS IS NULL ORDER BY owner ASC ) GROUP BY owner, table_name;
-
查询字段中值是否有中文
SELECT * FROM columnName WHERE ASCIISTR(columnName) LIKE '%\%'; -- columnName 字段名
持续更新记录