Relationship between constraints and column attributes NULLABLE in Oracle 10 GB

Source: Internet
Author: User

Relationship between constraints and column attributes NULLABLE in Oracle 10 GB

Conclusion:

The columname type not null and check (columnname is not null) results are different.

Therefore:

1. You do not need to manually match the NULLABLE attribute. When all constraints explicitly causing NULLABLE to be changed from Y to N are deleted, NULLABLE is naturally restored to Y.

2. Do NOT use CHECK to implement not null. You can use MODIFY or directly declare it after the field.

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 is Y, and the constraint does not cause NULLABLE changes.

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 is N, and a C-type not null constraint is automatically added.

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 is N, and a C-type not null constraint is automatically added.

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 is N. Create a P-type constraint and a UNIQUE index.

Alter table zwxtest04 drop constraint zwxtest04c3;

-- NULLABLE is Y

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.