关于网友提出的“ oracle中如何在有check和default约束的字段后加not null约束???”问题疑问,本网通过在网上对“ oracle中如何在有check和default约束的字段后加not null约束???”有关的相关答案进行了整理,供用户进行参考,详细问题解答如下:
问题: oracle中如何在有check和default约束的字段后加not null约束???
解决方案1: 另外,如果对语法什么的不太清楚,又非想用命令行来处理的,可以查oracle对应版本的在线文档Database SQL Language Reference,低版本的可能叫SQL Language Reference。
如果嫌麻烦,那就利用好手头的图形工具,plsql developer等等……
解决方案2:
手快了……
加not null约束: alter table title_copy modify status not null; 如果不行,具体报错信息是什么?不是语法错误就是比较少见的问题了,没报错信息那是瞎猫抓耗子,连毛可能都碰不到一根。
删除约束:select * from user_constraints where table_name='TITLE_COPY'; 具体要找什么样的约束,查了这个视图你就应该知道了,接下来就是删除: alter table title_copy drop constraint 约束名;
解决方案3:
alter table title_copy modify status not null;
解决方案4:解决方法有2种:
--方法1:
create table title_copy(
id number(3) not null,
t_id number(3) not null,
status char(9) default '未借出' not null,
constraint title_copy_primary primary key(id),
constraint title_copy_foreign foreign key(t_id) references title(id),
constraint title_copy_status check(status in('已借出','未借出') )
);
--方法2:
create table title_copy(
id number(3) not null,
t_id number(3) not null,
status char(9) not null,
constraint title_copy_primary primary key(id),
constraint title_copy_foreign foreign key(t_id) references title(id)
);
alter table title_copy modify status default '未借出' constraint title_copy_status check(status in ('已借出','未借出'));
经过测试,上面两种解决方法都可以。
以上介绍了“ oracle中如何在有check和default约束的字段后加not null约束???”的问题解答,希望对有需要的网友有所帮助。
本文网址链接:http://www.codes51.com/itwd/4531801.html