oracle删除主键约束的问题m
来源:互联网 发布:国外英语交流软件 编辑:程序博客网 时间:2024/05/01 12:35
oracle“删除”主键约束的方法有两个<write by SnowShana / qq:449394683>
1:alter table 表名 drop primary key;
这个是把主键从表中去除,而不是真正的删除主键
例子:
创建表:create table test_table_students (student_id number not null,student_name varchar(20) not null,student_telephone long not null);
创建主键:alter table test_table_students add constraint test_key_students primary key (student_id,student_name);
第一次插入数据:insert into test_table_students (student_id,student_name,student_telephone) values (1,'alice',136133);
第二次插入数据:insert into test_table_students (student_id,student_name,student_telephone) values (1,'peter',136133); 提示主键约束
第三次插入数据:insert into test_table_students (student_id,student_name,student_telephone) values (2,'alice',136133); 提示主键约束
删除主键约束:alter table test_table_students drop primary key;
第四次插入数据:insert into test_table_students (student_id,student_name,student_telephone) values (1,'peter',136134); 插入成功
第五次插入数据:insert into test_table_students (student_id,student_name,student_telephone) values (2,'alice',136135); 插入成功
删除刚才两行数据:delete from test_table_students where student_telephone=136134;delete from test_table_students where student_telephone=136135;
第二次添加主键约束:alter table test_table_students add constraint test_key_students primary key (student_id,student_name);约束名被占用
2:alter table 表名 drop constraint 约束名;
这个是把主键删除,可以再次添加同名主键
例子:
创建表:create table new_table_students (student_id number not null,student_name varchar(20) not null,student_telephone long not null);
创建主键:alter table new_table_students add constraint new_key_students primary key (student_id,student_name);
第一次插入数据:insert into new_table_students (student_id,student_name,student_telephone) values (1,'alice',136133);
第二次插入数据:insert into new_table_students (student_id,student_name,student_telephone) values (1,'peter',136133); 提示主键约束
第三次插入数据:insert into new_table_students (student_id,student_name,student_telephone) values (2,'alice',136133); 提示主键约束
删除主键约束:alter table new_table_students drop constraint new_key_students;
第四次插入数据:insert into new_table_students (student_id,student_name,student_telephone) values (1,'peter',136134); 插入成功
第五次插入数据:insert into new_table_students (student_id,student_name,student_telephone) values (2,'alice',136135); 插入成功
删除刚才两行数据:delete from new_table_students where student_telephone=136134;delete from new_table_students where student_telephone=136135;
第二次添加主键约束:alter table new_table_students add constraint new_key_students primary key (student_id,student_name);再次添加成功
- oracle删除主键约束的问题m
- oracle的主键约束添加删除
- oracle的主键约束添加删除
- Oracle删除约束和主键的语句
- Oracle 10g删除主键约束后无法删除唯一约束索引问题的模拟与分析
- Oracle 10g删除主键约束后无法删除唯一约束索引问题的模拟与分析
- Oracle如何删除主键约束的同时也删除索引
- oracle的主键约束的添加和删除
- Oracle主键外键 约束的 创建,添加和删除
- Oracle主键约束的创建,添加和删除
- Oracle主键外键 约束的 创建,添加和删除
- Oracle主键约束自动建立索引问题
- oracle的primary key主键约束
- oracle命名主键约束的原因
- oracle 主键删除,联合主键的创建
- Oracle中如何创建约束,查询约束和删除约束(check约束,外键和主键约束)
- Oracle主键约束和主键索引的重命名
- Oracle主键约束和主键索引的重命名
- HDU 4771 BFS + 状压
- ndklog
- OCP-1Z0-053-V12.02-582题
- ZOJ 1108 FatMouse's Speed (HDU 1160) DP
- Linux NIS服务
- oracle删除主键约束的问题m
- Android_ContentProvider_访问通讯录
- 卡特兰数在多种问题下的应用 组合数学-Catalan数
- lightoj 1147 - Tug of War 动态规划
- safari中不能响应click()的问题
- js中sleep的问题
- HDU 4772 模拟题
- 对浮点异常值NAN、QNAN、 SNAN、 IND、 INF的处理
- OCP-1Z0-053-V12.02-581题