oracle 10g學習2

來源:互聯網
上載者:User

標籤:

一、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

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.