標籤:
一、oracle中查看錶、欄位、約束和注釋
1,(1)查看目前使用者有哪些表
select table_name from user_tables;
(2)查看所有使用者的表
select table_name from all_tables;
(3)查看所有表包括系統資料表
select table_name from
2,查看s_emp中有哪些欄位
方法一:desc s_emp;
方法二:select column_name from user_tab_columns where table_name=‘S_EMP‘;
注意:在方法二中table_name後的‘ ‘中必須寫嚴格區分大小寫表名。oracle中分為兩種情況,單純的sql語句不區分大小寫,但是如果查詢某個字元的話就需要區分大小寫。如果寫成‘s_emp‘,則不能查詢出結果。當然還有一個方法是select column_name from user_tab_columns where table_name = upper(‘s_emp‘);
3,查看s_emp中一共有多少個欄位
select count(1)
from user_col_comments
where table_name = upper(‘s_emp‘);
4,查看目前使用者下所建立的約束的名字
select constraint_name
from user_constraints;
5,查看s_emp表中所建立的約束名字
select constraint_name
from user_constraints
where table_name=‘S_EMP‘;
6,查看s_emp表中約束的相關資訊
select constraint_name,constraint_type,search_condition
from user_constraints
where table_name=‘S_EMP‘;
7,查看s_emp表中的約束在哪列上起作用
select constraint_name,column_name
from user_cons_columns
where table_name = ‘S_EMP‘;
8,查看目前使用者的所有對象
select distinct object_type from user_objects;
9,查看目前使用者的表包括資源回收筒的表
select object_name
from user_objects
where object_type=‘TABLE‘;
10,(1)擷取s_emp表注釋
select comments
from user_tab_comments
where table_name =‘S_EMP‘;
(2)擷取欄位注釋
select comments
from user_col_comments
where table_name =‘S_EMP‘;
注意:
添加表注釋:
COMMENT ON table s_emp is ‘員工資訊‘;
添加欄位注釋:
comment on column s_emp.id is ‘員工號‘;
comment on column s_emp.last_name is‘姓‘;
comment on column s_emp.first_name is ‘名‘;
oracle 10g學習2