Answers for "constraints in oracle"

SQL
0

oracle table constraints

SELECT
 	c_list.CONSTRAINT_NAME as NAME,
 	c_src.TABLE_NAME as SRC_TABLE,
 	c_src.COLUMN_NAME as SRC_COLUMN,
 	c_dest.TABLE_NAME as DEST_TABLE,
 	c_dest.COLUMN_NAME as DEST_COLUMN
FROM ALL_CONSTRAINTS c_list, 
    ALL_CONS_COLUMNS c_src, 
    ALL_CONS_COLUMNS c_dest
WHERE c_list.CONSTRAINT_NAME = c_src.CONSTRAINT_NAME
    AND c_list.R_CONSTRAINT_NAME = c_dest.CONSTRAINT_NAME
    AND c_list.CONSTRAINT_TYPE = 'R'
GROUP BY c_list.CONSTRAINT_NAME,
    c_src.TABLE_NAME,
    c_src.COLUMN_NAME,
    c_dest.TABLE_NAME,
    c_dest.COLUMN_NAME;
Posted by: Guest on August-15-2021
2

how to find constraints on a table in oracle

SELECT cons.OWNER 			AS CHILD_OWNER,
       cons.TABLE_NAME 		AS CHILD_TABLE,
       cons.CONSTRAINT_NAME AS CONSTAINT_NAME,
       cons.CONSTRAINT_TYPE AS CONSTRAINT_TYPE,
       col.OWNER 			AS PARENT_OWNER,
       col.TABLE_NAME 		AS PARENT_TABLE,
       col.COLUMN_NAME 		AS COLUMN_NAME
FROM DBA_CONS_COLUMNS col, DBA_CONSTRAINTS cons
WHERE cons.R_OWNER = col.OWNER
  AND cons.R_CONSTRAINT_NAME = col.CONSTRAINT_NAME
  AND cons.TABLE_NAME = 'table_name';
Posted by: Guest on July-11-2021
0

sql constarint

It creates a new constraint on an existing table, which is used to specify
rules for any data in the table.
Example: Adds a new PRIMARY KEY constraint named ‘user’ on columns
ID and SURNAME.
ALTER TABLE users
ADD CONSTRAINT user PRIMARY KEY (ID, SURNAME);
Posted by: Guest on January-07-2021

Code answers related to "SQL"

Browse Popular Code Answers by Language