1、創(chuàng)建表的同時(shí)創(chuàng)建主鍵約束
(1)無(wú)命名
create table student (
studentid int primary key not null,
studentname varchar(8),
age int);
(2)有命名
create table students (
studentid int ,
studentname varchar(8),
age int,
constraint yy primary key(studentid));
2、刪除表中已有的主鍵約束
(1)有命名
alter table students drop constraint yy;
(2)無(wú)命名
可用
SELECT * from user_cons_columns;
查找表中主鍵名稱(chēng)得student表中的主鍵名為SYS_C002715
alter table student drop constraint SYS_C002715;
3、向表中添加主鍵約束
alter table student add constraint pk_student primary key(studentid);
以上所述是小編給大家介紹的oracle中添加刪除主鍵的方法,希望對(duì)大家有所幫助,如果大家有任何疑問(wèn)請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!
您可能感興趣的文章:- Oracle數(shù)據(jù)庫(kù)中創(chuàng)建自增主鍵的實(shí)例教程
- Oracle學(xué)習(xí)記錄之使用自定義函數(shù)和觸發(fā)器實(shí)現(xiàn)主鍵動(dòng)態(tài)生成
- oracle刪除主鍵查看主鍵約束及創(chuàng)建聯(lián)合主鍵
- 深入Mysql,SqlServer,Oracle主鍵自動(dòng)增長(zhǎng)的設(shè)置詳解
- Oracle 數(shù)據(jù)庫(kù)針對(duì)表主鍵列并發(fā)導(dǎo)致行級(jí)鎖簡(jiǎn)單演示
- Oracle與Mysql主鍵、索引及分頁(yè)的區(qū)別小結(jié)
- Oracle創(chuàng)建主鍵自增表(sql語(yǔ)句實(shí)現(xiàn))及觸發(fā)器應(yīng)用