1、創建表的同時創建主鍵約束
(1)無命名
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)無命名
可用
SELECT * from user_cons_columns;
查找表中主鍵名稱得student表中的主鍵名為SYS_C002715
alter table student drop constraint SYS_C002715;
3、向表中添加主鍵約束
alter table student add constraint pk_student primary key(studentid);
以上所述是小編給大家介紹的oracle中添加刪除主鍵的方法,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復大家的。在此也非常感謝大家對腳本之家網站的支持!
您可能感興趣的文章:- Oracle數據庫中創建自增主鍵的實例教程
- Oracle學習記錄之使用自定義函數和觸發器實現主鍵動態生成
- oracle刪除主鍵查看主鍵約束及創建聯合主鍵
- 深入Mysql,SqlServer,Oracle主鍵自動增長的設置詳解
- Oracle 數據庫針對表主鍵列并發導致行級鎖簡單演示
- Oracle與Mysql主鍵、索引及分頁的區別小結
- Oracle創建主鍵自增表(sql語句實現)及觸發器應用