取Oracle 表名 欄位名

2021-05-27 18:32:08 字數 3053 閱讀 6921

--檢視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;

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

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資料庫的注釋同步到pb中 **開始

delete from pbcatcol where pbc_tnam like '%';

delete from pbcattbl where pbt_tnam like '%';

insert into pbcattbl

( pbt_tnam,

pbt_ownr ,

pbt_cmnt)

select all_tab_comments.table_name,

all_tab_comments.owner,

all_tab_comments.comments

from all_tab_comments

where all_tab_comments.owner = 'lh'

and table_name like '%';

//同步欄位名

insert into pbcatcol

( pbc_tnam,

pbc_ownr,

pbc_cnam,

pbc_labl,

pbc_cmnt,

pbc_hdr)

select all_col_comments.table_name,

all_col_comments.owner,

all_col_comments.column_name,

all_col_comments.comments ,

all_col_comments.comments ,

all_col_comments.comments

from all_col_comments

where all_col_comments.owner = 'lh'

and table_name like '%';

commit;

-- 將oracle資料庫的注釋同步到pb中 **結束

--將pb注釋同步到oracle中

select 'comment on table '||pbt_tnam||' is '''||pbt_cmnt||''';' from pbcattbl where pbt_tnam not like 'pb%'

union

select 'comment on column '||pbc_tnam||'.'||pbc_cnam||' is '''||pbc_cmnt||''';' from pbcatcol where pbc_tnam not like 'pb%';

--查程序

select object_id,session_id,locked_mode from v$locked_object;

select t2.username,t2.sid,t2.serial#,t2.logon_time

from v$locked_object t1,v$session t2

where t1.session_id=t2.sid order by t2.logon_time;

--殺程序

alter system kill session '3,6666';

取Oracle 表名 欄位名

取 oracle 表名 欄位名 注釋等實用語句 sql 檢視oracle 資料庫中本使用者下的所有表 select table name from user tables 檢視oracle 資料庫中所有使用者下的所有表 select user,table name from all tables 檢...

取Oracle 表名 欄位名

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

Oracle 取Oracle 表名 欄位名

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