Oracle資料表建立、查詢、約束等操作

來源:互聯網
上載者:User

標籤:mod   foreign   結構   cat   多列   rac   number   name   constrain   

1、建立表、刪除表、複製表

    create  table stuInfo    ——建立學員資訊表

    ( 

         stuNo char(6) not null

         stuName varchar(2) not nul,

         stuAge number(3,0) not null

      )

      建立一張表複製學員資訊表則是:create table stuInfo2 as select * from stuInfo;

      刪除表:1、drop table 表    2、truncate  表;

2、對錶結構的查詢:desc 表名;

3、改表名:alter table old表名 rename to new表名;

增加列:alter table 表 add(列名 類型,列名 類型);

修改列:alter table 表 modify (列名 類型,列名 類型);

刪除一列:alter table 表 drop column 列名; 刪除多列:alter table 表 drop(列1,列2);

4、向表中添加約束,emp表的deptno作為外鍵引用dept表的deptno

alter table emp add constraint pk_test foreign KEY(deptno) references dept(deptno);

5、向表中添加主鍵約束

alter table emp add constraint pk_emp_deptno primary key(deptno);

6、刪除約束:

alter table emp drop constraint pk_emp_deptno;

7、禁用和啟用約束:

alter table 表 Dsable||Enable constraint 約束名;

 

Oracle資料表建立、查詢、約束等操作

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.