云服务器网:购买云服务器和VPS必上的网站!

oracle中添加删除主键的方法

1、创建表的同时创建主键束缚
(1)无命名create table student (studentid int primary key not null,studentname varchar(8),age int);(2)有命名create table s

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中添加删除主键的方法,大家如有疑问可以留言,或联系站长。感谢亲们支持!!!

本文来源:https://www.yuntue.com/post/153688.html | 云服务器网,转载请注明出处!

关于作者: yuntue

云服务器(www.yuntue.com)是一家专门做阿里云服务器代金券、腾讯云服务器优惠券的网站,这里你可以找到阿里云服务器腾讯云服务器等国内主流云服务器优惠价格,以及海外云服务器、vps主机等优惠信息,我们会为你提供性价比最高的云服务器和域名、数据库、CDN、免费邮箱等企业常用互联网资源。

为您推荐

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注