About constraint's disable and enable

Source: Internet
Author: User

Establish the constraint of the primary foreign key

CREATE TABLE EMP1 (emp_no number (2) Constraint EMP_EMP_NO_PK primary key,
ename VARCHAR2 (15),
Salary number (8,2),
Mgr_no number (2) constraint EMP_MGR_FK references emp1);

Query status

Sql> Select Constraint_name,constraint_type, status from User_constraints where Table_name= ' EMP1 '
2;

Constraint_name C STATUS
------------------------------ - --------
EMP_EMP_NO_PK P ENABLED
EMP_MGR_FK R ENABLED

ALTER TABLE EMP1 disable constraint EMP_EMP_NO_PK cascade;

Sql> Select Constraint_name,constraint_type, status from User_constraints where table_name= ' EMP1 ';

Constraint_name C STATUS
------------------------------ - --------
EMP_EMP_NO_PK P DISABLED
EMP_MGR_FK R DISABLED

ALTER TABLE EMP1 enable constraint emp_emp_no_pk;

Sql> Select Constraint_name,constraint_type, status from User_constraints where table_name= ' EMP1 ';

Constraint_name C STATUS
------------------------------ - --------
EMP_EMP_NO_PK P ENABLED
EMP_MGR_FK R DISABLED

Still need manual enable foreign KEY constraint

ALTER TABLE EMP1 enable constraint EMP_MGR_FK;

Sql> Select Constraint_name,constraint_type, status from User_constraints where Table_name= ' EMP1 '
2;

Constraint_name C STATUS
------------------------------ - --------
EMP_EMP_NO_PK P ENABLED
EMP_MGR_FK R ENABLED

About constraint's disable and enable

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.