日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程资源 > 编程问答 >内容正文

编程问答

oralce10g中约束与列属性NULLABLE的关系

發(fā)布時(shí)間:2024/4/15 编程问答 43 豆豆
生活随笔 收集整理的這篇文章主要介紹了 oralce10g中约束与列属性NULLABLE的关系 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

?

?

結(jié)論:

columname type not null與check (columnname is not null)的結(jié)果是不一樣的

?

因此:

1、不需要手工去匹配NULLABLE屬性,當(dāng)所有顯式導(dǎo)致NULLABLE由Y變N的約束被刪除后,NULLABLE自然會(huì)恢復(fù)為Y。

2、盡量不要使用CHECK來(lái)實(shí)現(xiàn)NOT NULL,可以使用MODIFY或直接在字段后聲明

?

?

?

drop table zwxtest04;
create table zwxtest04
(

?id integer
);
alter table zwxtest04 add constraint zwxtest04c2 check (id is not null);
select * from user_tab_columns where table_name='ZWXTEST04';
select * from user_constraints where table_name='ZWXTEST04';

?

?

--NULLABLE 為Y ,約束并不會(huì)導(dǎo)致NULLABLE變動(dòng)

?

?

drop table zwxtest04;
create table zwxtest04
(

?id integer not null
);

select * from user_tab_columns where table_name='ZWXTEST04';
select * from user_constraints where table_name='ZWXTEST04';

?

-- NULLABLE 為N ,同時(shí)自動(dòng)添加一個(gè)C型的NOT NULL的約束

?

?

drop table zwxtest04;
create table zwxtest04
(

?id integer?

);
alter table zwxtest04 id not nul;
select * from user_tab_columns where table_name='ZWXTEST04';
select * from user_constraints where table_name='ZWXTEST04';

?

-- NULLABLE 為N ,同時(shí)自動(dòng)添加一個(gè)C型的NOT NULL的約束

?

?

?

?

drop table zwxtest04;
create table zwxtest04
(

?id integer
);
alter table zwxtest04 add constraint zwxtest04c3 primary key (id? );
select * from user_tab_columns where table_name='ZWXTEST04';
select * from user_constraints where table_name='ZWXTEST04';

?

-- NULLABLE 為N ,創(chuàng)建P型約束,創(chuàng)建UNIQUE索引

alter table zwxtest04 drop constraint zwxtest04c3 ;

?

--NULLABLE為Y

轉(zhuǎn)載于:https://www.cnblogs.com/QinQouShui/archive/2010/11/05/1869950.html

超強(qiáng)干貨來(lái)襲 云風(fēng)專訪:近40年碼齡,通宵達(dá)旦的技術(shù)人生

總結(jié)

以上是生活随笔為你收集整理的oralce10g中约束与列属性NULLABLE的关系的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。