Oracle 常用表和查询

Oracle 常用表和查询

豆子 233 2022-05-06
-- 查询当前用户
SELECT user FROM dual;
-- 查询所有用户
SELECT * FROM all_users;
==============================================
-- 包括系统表
SELECT * FROM dba_tables;
-- 所有用户的表
SELECT * FROM all_tables;
-- 查询指定用户表
SELECT * FROM all_tables WHERE owner = 'user_name';
-- 当前用户表
SELECT * FROM user_tables;
-- 查询表结构
SELECT * FROM all_tab_columns WHERE table_name = 'table_name';
SELECT * FROM user_tab_columns WHERE table_name = 'table_name';
SELECT owner, table_name, column_name, data_type, data_length FROM  all_tab_columns WHERE table_name = 'table_name';
--模板
select t1.owner,t1.table_name,t1.column_name,t2.comments,t1.data_type from
(select * from all_tab_columns where owner = 'ECIF' and table_name = 'table_name') t1
left join
(select * from all_col_comments where owner = 'ECIF' and table_name = 'table_name') t2
on t1.column_name = t2.column_name
order by t1.column_id;

# ORACLE