Search
 
SCRIPT & CODE EXAMPLE
 

SQL

oracle list primary key

-- Primary key in a table
SELECT * FROM ALL_CONSTRAINTS 		-- or DBA_CONSTRAINTS or UESR_CONSTRAINTS
WHERE TABLE_NAME= 'table_name' AND CONSTRAINT_TYPE = 'P';
-- With columns names:
SELECT c.OWNER, c.TABLE_NAME, c.CONSTRAINT_NAME, c.CONSTRAINT_TYPE, 
	col.COLUMN_NAME
FROM ALL_CONSTRAINTS c
JOIN ALL_CONS_COLUMNS col ON c.TABLE_NAME = col.TABLE_NAME 
    AND c.CONSTRAINT_NAME = col.CONSTRAINT_NAME
WHERE c.TABLE_NAME= 'table_name' AND c.CONSTRAINT_TYPE = 'P'
ORDER BY c.TABLE_NAME, c.CONSTRAINT_NAME, col.COLUMN_NAME;
Comment

PREVIOUS NEXT
Code Example
Sql :: if null put 0 sql 
Sql :: functions with parameters SQL 
Sql :: group by clause with join in sql 
Sql :: truncate table in sql 
Sql :: select only the month-day from date in PL-SQL 
Sql :: oracle avg 
Sql :: oracle generate list of dates in between a date range 
Sql :: sqlalchemy bulk delete 
Sql :: SQL print multiple variable 
Sql :: update value sql 
Sql :: sql query inner join 3 tables 
Sql :: create a PostgreSQL user django on mac 
Sql :: convert rows into columns in oracle 
Sql :: sql rename table 
Sql :: set mysql password 
Sql :: symfony Integrity constraint violation: 1451 Cannot delete or update a parent row: a foreign key constraint fails 
Sql :: declare temp table in sql 
Sql :: 2nd highest value in sql 
Sql :: Mysql Selected All Duplicate Rows 
Sql :: multiple order by sql 
Sql :: python get backup of sql 
Sql :: sqlite modify row 
Sql :: sqlalchemy get ids 
Sql :: SELECT everything from a sql table 
Sql :: how to get table id sequence postgres 
Sql :: what data type to use for phone number in sql 
Sql :: select count distinct multiple columns sql server 
Sql :: trigger sql 
Sql :: openquery join two tables 
Sql :: SQLSTATE[42000]: Syntax error or access violation: 1140 Mixing of GROUP columns (MIN(),MAX(),COUNT(),...) with no GROUP columns is illegal if there is no GROUP BY clause 
ADD CONTENT
Topic
Content
Source link
Name
8+4 =