在oracle中,可以利用“select”語句查詢指定用戶下的所有表,語法“select * from all_tables a where a.OWNER = upper('數(shù)據(jù)庫用戶名');”。
本教程操作環(huán)境:Windows7系統(tǒng)、Oracle 11g版、Dell G3電腦。
1.查詢當(dāng)前用戶下都有哪些表
標(biāo)準(zhǔn)查詢語句:
select * from all_tables a where a.OWNER = upper('數(shù)據(jù)庫用戶名');
示例: (說明: HDRV2是我使用的數(shù)據(jù)庫用戶名,在此你修改你的用戶名即可,用戶名切記要大寫,查詢成功后可以了解一下
all_tables表的每個(gè)字段的作用)
2.查詢當(dāng)前用戶下所有表的所有字段信息
標(biāo)準(zhǔn)查詢語句:
select * from all_tab_columns c where c.OWNER = upper('數(shù)據(jù)庫用戶名');
示例:(說明: HDRV2是我使用的數(shù)據(jù)庫用戶名,在此你修改你的用戶名即可,用戶名切記要大寫;再用and做了一個(gè)條件查詢)
3.查看當(dāng)前用戶屬于的表空間
標(biāo)準(zhǔn)查詢語句(用戶名一定要大寫,oracle對大小寫敏感):
select * from dba_users where username=upper('用戶名');
示例:
select default_tablespace from dba_users where username='HDRV2';
4.查詢當(dāng)前用戶下的表的數(shù)據(jù)條數(shù)(沒查到數(shù))、表名、中文表名
select a.num_rows as '數(shù)據(jù)條數(shù)', a.TABLE_NAME as '表名', b.COMMENTS as '中文表名' from user_tables a, user_tab_comments b where a.TABLE_NAME = b.TABLE_NAME order by TABLE_NAME;
5. 查詢當(dāng)前用戶下的所有表名:
select t.table_name from user_tables t;
6.查詢當(dāng)前用戶下所有表的字段名:
select t.column_name from user_col_comments t;
7.查詢當(dāng)前用戶下所有表的表名和表說明:
select t.table_name,f.comments from user_tables t inner join user_tab_comments f on t.table_name = f.table_name;
推薦教程:《Oracle教程》