PL/SQL includes conditional statements, and one of the fundamental conditional constructs is the IF-THEN statement. The IF-THEN statement in PL/SQL is used for conditional execution of a block of code. It allows you to specify a condition, and if that condition evaluates to true, then a specified block of code is executed. Syntax Here’s a…(Continue Reading)
Category: PL/SQL
Learn PLSQL Tutorial
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)