Oracle PL/SQL constraints

An Oracle PL/SQL constraint is a rule that must be followed by the data in a database table. PL/SQL constraints can be used to enforce data integrity, prevent duplicate data, and ensure that data is valid. Benefits of using PL/SQL constraints on a table include: – Enforcing data integrity – Preventing duplicate data – Ensuring…(Continue Reading)

Disable foreign key

To disable a foreign key on a table of Oracle database you must use the alter table command and disable constraint keyword. Syntax ALTER TABLE table_name DISABLE CONSTRAINT constraint_name; Disable foreign key example ALTER TABLE ORDERS DISABLE CONSTRAINT fk_course; Output: table ORDERS altered. Check constraints SELECT OWNER, CONSTRAINT_NAME, STATUS FROM user_constraints WHERE table_name = ‘ORDERS’;…(Continue Reading)

Enable a foreign key

To enable a foreign key on a table of Oracle database you must use the alter table command and enable constraint keyword. Syntax ALTER TABLE table_name ENABLE CONSTRAINT constraint_name; Enable foreign key example ALTER TABLE ORDERS ENABLE CONSTRAINT fk_course; Output: table ORDERS altered. Check constraints SELECT OWNER, CONSTRAINT_NAME, STATUS FROM user_constraints WHERE table_name = ‘ORDERS’;…(Continue Reading)

Add constraint foreign key

To add constraint foreign key on a table of Oracle database you must use the alter table command and add constraint keyword. Syntax ALTER TABLE table_name1 ADD CONSTRAINT constraint_name FOREIGN KEY (coll_name) REFERENCES table_name2(coll_name); Add constraint foreign key example ALTER TABLE orders ADD CONSTRAINT fk_course FOREIGN KEY (course_id) REFERENCES course(course_id); Output: table ORDERS altered. Check…(Continue Reading)

Drop constraint key

To drop constraint key on a table of Oracle database you must use the alter table command. Syntax ALTER TABLE table_name DROP CONSTRAINT constraint_name; Drop constraint key example ALTER TABLE test DROP CONSTRAINT pk_test_id; Output: table TEST altered.