Search
 
SCRIPT & CODE EXAMPLE
 

SQL

oracle desc table primary key

SELECT cols.table_name, cols.column_name, cols.position, cons.status, cons.owner
FROM all_constraints cons, all_cons_columns cols
WHERE cols.table_name = 'TABLE_NAME'
AND cons.constraint_type = 'P'
AND cons.constraint_name = cols.constraint_name
AND cons.owner = cols.owner
ORDER BY cols.table_name, cols.position;
Comment

oracle desc table 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 :: min salary in sql 
Sql :: how to truncate table with foreign key constraint postgresql 
Sql :: t-sql merge example 
Sql :: change auto increment mysql 
Sql :: rename field name in mysql 
Sql :: postgresql export database 
Sql :: How do I modify a MySQL column to allow NULL? 
Sql :: run sql command line download for windows 10 
Sql :: How to drop a foreign key constraint in mysql ? 
Sql :: Get monday of week date is in SQL 
Sql :: row number mssql 
Sql :: check if database exists sql 
Sql :: clear screen command on mysql 
Sql :: sql get month from date 
Sql :: sql update where id 
Sql :: sql percentage 
Sql :: create view in sql 
Sql :: how to combine first and last nae into one columb sql 
Sql :: t-sql drop function if exists 
Sql :: sql table 
Sql :: mysql get latest duplicate rows 
Sql :: check if value is equal to something sql 
Sql :: Get first 10 in sql 
Sql :: The local psql command could not be located 
Sql :: how to connect sql database in python 
Sql :: oracle drop job if exists 
Sql :: mysql grant select update insert delete 
Sql :: add multiple row table pl sql 
Sql :: oracle index hint 
Sql :: como consultar registros duplicados en mysql 
ADD CONTENT
Topic
Content
Source link
Name
7+6 =