sql find tables primary keys

Solutions on MaxInterview for sql find tables primary keys by the best coders in the world

showing results for - "sql find tables primary keys"
Niko
17 Jan 2020
1-- NOTE: this is for SQL-Oracle specifically
2
3-- syntax:
4SELECT cols.table_name, cols.column_name, cols.position, cons.status, cons.owner
5FROM all_constraints cons, all_cons_columns cols
6WHERE cols.table_name = '<table-name>' -- Replace <table-name> with your table-name
7AND cons.constraint_type = 'P'
8AND cons.constraint_name = cols.constraint_name
9AND cons.owner = cols.owner
10
11
12-- example:
13SELECT cols.table_name, cols.column_name, cols.position, cons.status, cons.owner
14FROM all_constraints cons, all_cons_columns cols
15WHERE cols.table_name = 'CUSTOMERS' 
16AND cons.constraint_type = 'P'
17AND cons.constraint_name = cols.constraint_name
18AND cons.owner = cols.owner
queries leading to this page
how to find key in sql tablehow to check which column is primary key in sqlhow to find primary key of a table in sqlhow to check primary key in view sql serverget key details of table in sqlget primary key of current tablesql server check table primary keymssql get all primary keyshow to check for primary key in sqlsql table get primary keyget primary key column name sql serversql query for keysfind a primary key sqlsql view all primary key in tablesql server select table primary keyhow to see primary key in sqlsql select by primary keyquery to find primary key of a table in sqlfind sql primary keysql server studio check primary keyprimary key in sqlsql server show table primary keyshow primary key in sql tableget primary column from table sql serverhow to see primary key in sql commandsql query to find primary key of a tablesql command to show primary keymssql query to get table column with keyscheck table is primary key sqlhow to get the primary key column of a table using sqlget all key in sqlhow checking table have a primary kleysql search keyshow primary key in sqlselect primary key on table of sql serversql get table primary keysql server get keys of a tablehow to find primary key table in sql serverhow to list the keys of a table in sqlhow to get primary key from sql tablesql check primary keyfind primary key in sql tablesql find tables which are using a column as primary keyhow to know what table has primary key in sqlshow sql keys of a tablesql how to see primary keyget key from sql statementsql check primary keys on tablehow to get sql primary keyhow to check primary key in table sql serverhow to find the primary key in sql serverhow to find primary key sqlselect primary key from table sql serverfind primary key of a table in sqlhow to check primary key in sql tbalesql find tables using a column as primary keysql get record by primary keyget the table from a keyt sql find primary keyssql query to get table column data by keysql show primary keysql find tables primary keysql view all primary keysqlserver find primary key of tableget primary key of table in sql serverfind primary key of a tablehow to find primary key of a tableretrieve primary keyselect keys in table mssqlhow to get a list of primary key in sqlselect column is primary key sql serversql find tables primary keyshow to check primary key of a table in sql serverget primary key from table sql serverhow to get primary key of a table by sqlhow to find a primary key in a table sqlhow to check if a column is primary key in sqlhow to view primary key in sqlsql find table primary keyget table primary key sql serversql how to tell what table key isget column primary key in table sql serversearching sql table by keyhow to get primary key of table in sql serversql see primary keyget primary key sqlsql find tables primary keys