Tag: foreign

How does cascade work in cases of delete/update for foreign key?

The following example shows how to setup and cascade works when deleting record from parent table. 1) Shows how DELETE cascade works -- Parent table CREATE TABLE supplier ( supplier_id numeric(10) not null, supplier_name varchar2(50), contact_name varchar2(50), CONSTRAINT supplier_pk PRIMARY KEY (supplier_id) ); -- children table with foreign key CREATE TABLE products ( product_id numeric(10) … Continue reading How does cascade work in cases of delete/update for foreign key?

Lists foreign key(s) on a table

Using the following anonymous store procedure one can list the foreign key on a table and it's column. It also recursively traverses tables to see if there are other tables dependent on it's primary key. set serveroutput on format wrapped DECLARE l_vc2_table_owner VARCHAR2(30) := upper('&1'); l_vc2_table_name VARCHAR2(30) := upper('&2'); PROCEDURE get_ind_columns(l_vc2_owner IN VARCHAR2, l_vc2_index_name IN … Continue reading Lists foreign key(s) on a table