1. Delete Constraints
Alter table table_name drop constraint constraint_name;
2. Create a primary key
Alter table table_name add constraint constraint_name primary key (column_name1, column_name2 );
3. Create a unique constraint
Alter table table_name add constraint constraint_name unique (column_name1, column_name2 );
4. Create a foreign key constraint
Alter table table_name1 add constraint constraint_name foreign key (column_name1) references table_name2 (column_name1 );
Enable/disable: Restrict/not restrict new data
Novalidate/validate: Incorrect/verification of old data
Alter table table_name add constraint constraint_name check (column_name like 'B %') enable/disable novalidate/validate;
5. Modify constraints, delay verification, and commit Verification
Alter table table_name modify constraint constraint_name initially deferred;
6. Modify constraints and verify now
Alter table table_name modify constraint constraint_name initially immediate;
7. Set constraints delay/verify now
Alter session set constraints = deferred/immediate;
8. Delete constraints when deleting a table
Drop a primary key table with foreign keys and cascade deletion with cascade constraints Parameters
Drop table table_name cascade constraints;
9. When the truncate foreign key table is used, the foreign key is set to invalid first, and then truncate;
Truncate table table_name;
Invalid constraint settings
Alter table table_name disable constraint constraint_name;
Alter table table_name enable novalidate constraint constraint_name;