identify primary key in oracle table

Solutions on MaxInterview for identify primary key in oracle table by the best coders in the world

showing results for - "identify primary key in oracle table"
Fletcher
28 Jan 2017
1-- Primary key in a table
2SELECT * FROM ALL_CONSTRAINTS 		-- or DBA_CONSTRAINTS or UESR_CONSTRAINTS
3WHERE TABLE_NAME= 'table_name' AND CONSTRAINT_TYPE = 'P';
4-- With columns names:
5SELECT c.OWNER, c.TABLE_NAME, c.CONSTRAINT_NAME, c.CONSTRAINT_TYPE, 
6	col.COLUMN_NAME
7FROM ALL_CONSTRAINTS c
8JOIN ALL_CONS_COLUMNS col ON c.TABLE_NAME = col.TABLE_NAME 
9    AND c.CONSTRAINT_NAME = col.CONSTRAINT_NAME
10WHERE c.TABLE_NAME= 'table_name' AND c.CONSTRAINT_TYPE = 'P'
11ORDER BY c.TABLE_NAME, c.CONSTRAINT_NAME, col.COLUMN_NAME;
Diego
22 Jan 2019
1-- syntax:
2SELECT cols.table_name, cols.column_name, cols.position, cons.status, cons.owner
3FROM all_constraints cons, all_cons_columns cols
4WHERE cols.table_name = '<table-name>' -- Replace <table-name> with your table-name
5AND cons.constraint_type = 'P'
6AND cons.constraint_name = cols.constraint_name
7AND cons.owner = cols.owner
8
9
10-- example:
11SELECT cols.table_name, cols.column_name, cols.position, cons.status, cons.owner
12FROM all_constraints cons, all_cons_columns cols
13WHERE cols.table_name = 'CUSTOMERS' 
14AND cons.constraint_type = 'P'
15AND cons.constraint_name = cols.constraint_name
16AND cons.owner = cols.owner
17
Ilyas
05 Feb 2016
1CREATE TABLE table_name
2(
3  column1 datatype null/not null,
4  column2 datatype null/not null,
5  ...
6  CONSTRAINT constraint_name PRIMARY KEY (column1, column2, ... column_n)
7);
queries leading to this page
primary key in oracle sqlcomposite primary key in oracleprimary key sql oracleoracle sql constraint primary keyoracle query select as keyhow to check primary key in oracle databasehow to add primary key to oracle tablehow to display primary key of a table in oraclehow to make a composite primary key in oracleoracle primary key table createadd primary key in oraclefinding primary key of a table in oracleget all primary key of a table oraclefind primary key of a table oracleoracle view primary keyadd primary key in create table oracledesc table in oracle sqlprimary key on oraclecreate primary key for table oracleoracle sql create table with primary keyprimary key in oracle tablehow to apply primary key in oracle 5doracle sql generate primary keyoracle sql primary keyoracle sql check table primary keynew primary key oracle sqlprimary key in oracleprimary key constraint oracleget primary key of a table oracleget primary key of oracle table queryoracle primary key constrainthow to know what coulumn is primary key in oraclehow to insert primary key in oracle tableoracle sql developer check table primary keyoracle check primary keyadd primary key constraint oracleoracle query column primary keyhow to make primary key in oracleprimary key table oracleoracle get pk tableshow to check which column is primary key in oracleprimary key syntax in oracleget primary key of table oracleoracle get primary keyhow to get the primary key in oraclecreate table with primary key in oracleprimary key oraclehow to identify primary key in oracle tablecreate table in oracle with primary keyadd primary key to oracle dboracle sql query primary keyprimary key oracle sqldefine primary key in oraclecreate composite primary key constraint oraclecreate table oracle primary keyoracle create table with primary keyoracle generate primary key using oracle primary key referenceshow to get primary key of table in oracleoracle find available primary key of tableidentify primary key oracle tablehow to create a primary key in oracle sqlmake primary key in oracle while creating tableget unique primary key not already in table oracle sqlprimary key oracle syntaxtable primary key oracleoracle create table primary keyoracle primary key constraint querycreate primary key oracle sqladd primary key to a oracle tableget column names of primary key oracleoracle constraint primary keycreate table in oracle with primary key examplemodify table primary key to identify oracleoracle list primary keyconstraint primary key oracleoracle select primary keys tablehow to add primary key after creating table in oraclecreate table with primary key oracle sqlset primary key in oracle sqlfind primary key in a table oraclehow to find the primary key of a table in oracle sqloracle desc table primary keyoracle sql check primary keyhow to add primary key in oracle tableidentify primary key in oracle tableoracle sql composite primary keyhow to use primary key in oraclewrite primary key on oracleget primary key in oracle tableget primary keys of oracle databasefind primary key for a table in oracle c2 bahow to see the primary ket of a table in oraclequery to show primary key of table sql server oraclehow to primary key in oracle sqlalter table add primary key oraclehow to see primary key in sql developeroracle table primary keyprimary key in oracle create tableget table column identity in oracle all cons columns columnsoracle get field pkadd primary key oracleoracle sql developer create table primary key constraint syntaxhow to give primary key in oracleoracle primary keyoracle how to find primary key in a tablequery to check primary key of a table in oracleoracle get primary key of tablehow to find primary key in oracleoracle select primary key from tableoracle find primary keys in a tableidentify primary key in oracle table