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.

Add primary key

To add primary key on a table of Oracle database you must use the alter table command. Syntax ALTER TABLE table_name ADD CONSTRAINT constraint_name PRIMARY KEY(col_name); Add primary key example ALTER TABLE test ADD CONSTRAINT pk_test_id PRIMARY KEY(id); Output: table TEST altered. Check constraints SELECT OWNER, CONSTRAINT_NAME, STATUS FROM user_constraints WHERE table_name = ‘TEST’; Output:…(Continue Reading)

Drop index oracle

Drop index oracle example You can remove unnecessary indexes from oracle database using pl/sql command drop index. Syntax: DROP INDEX index_name; Example: — drop index DROP INDEX AMOUNT_IDX; Output: index AMOUNT_IDX dropped.

Alter index oracle

Alter index oracle examples Below are a list of oracle pl/sql alter index examples. You can learn how to alter indexes using commands like: rename an index, disable an index, drop index partition, rebuild index, collect statistics. Rename an Index Disable an Index Enable an Index Disable an Function-Based Index Enable an Function-Based Index Rename…(Continue Reading)