檢視ORACLE 資料庫及表資訊

2022-08-29 21:45:28 字數 1732 閱讀 1274

-- 檢視oracle 資料庫中本使用者下的所有表

select table_name from user_tables;

-- 檢視oracle 資料庫中所有使用者下的所有表

select user,table_name from all_tables;

-- 檢視oracle 資料庫中本使用者下的所有列

select table_name,column_name from user_tab_columns;

-- 檢視oracle 資料庫中本使用者下的所有列

select user,table_name,column_name from all_tab_columns;

-- 檢視oracle 資料庫中的序列號

select * from user_sequences;

-- 上面的所有物件,都可以通過下面的sql語句查詢得到

-- 查詢所有的使用者生成的oracle物件

select * from user_objects;

-- 檢視oracle 資料庫中所有表的注釋

select table_name,comments from user_tab_comments;

-- 檢視oracle 資料庫中所有列的注釋

select table_name,column_name,comments from user_col_comments;

-- 給表加oracle的注釋

comment on table aa10 is '系統參數列';

-- 給列加oracle的注釋

comment on column aa10.aaa100 is '引數類別';

-- 檢視表中列的屬性,包括 資料型別,是否非空等

desc aa10; 

-- 通過系統表,檢視表中列的屬性,包括 資料型別,是否非空等

select table_name,column_id,column_name,data_type,data_length,data_precision,nullable 

from user_tab_columns 

order by table_name,column_id;

--檢視所有表空間

selecttablespace_name,sum(bytes)/1024/1024 from dba_data_files  group by tablespace_name

--檢視未使用表空間大小

selecttablespace_name,sum(bytes)/1024/1024 from dba_free_space group bytablespace_name;

-- 檢視資料庫中表、索引占用的資料庫空間大小

select * from user_segments;

-- 檢視所有表的記錄數

create table table_count(table_name varchar2(50),columns number(20)); 

-- 通過pb執行下面的語句,得到結果集,將結果集在pb下執行,最後提交

select 'insert into table_count values('''||table_name||''', (select count(1)from '||table_name||'));//'||comments from user_tab_comments; 

-- 所有表的記錄都在table_count了

select * from table_count;

檢視ORACLE 資料庫及表資訊

檢視oracle 資料庫中本使用者下的所有表 select table name from user tables 檢視oracle 資料庫中所有使用者下的所有表 select user,table name from all tables 檢視oracle 資料庫中本使用者下的所有列 select...

檢視ORACLE 資料庫及表資訊

檢視oracle 資料庫中本使用者下的所有表 select table name from user tables 檢視oracle 資料庫中所有使用者下的所有表 select user,table name from all tables 檢視oracle 資料庫中本使用者下的所有列 select...

檢視ORACLE 資料庫及表資訊

檢視oracle 資料庫中本使用者下的所有表 select table name from user tables 檢視oracle 資料庫中所有使用者下的所有表 select user,table name from all tables 檢視oracle 資料庫中本使用者下的所有列 select...