Withdata Software

Producing high-quality database tools

Main menu

Skip to primary content
Skip to secondary content
  • Withdata Software
  • Blog
  • Categories
  • Tags

Tag Archives: get primary key

How to get primary key of a table from Oracle

Posted on October 24, 2016 by Shiji Pan

SELECT cols.column_name FROM all_constraints cons, all_cons_columns cols WHERE cons.constraint_type = 'P' AND cons.constraint_name = cols.constraint_name AND cons.table_name = cols.table_name AND cons.owner = cols.owner AND cons.table_name='my_table_name' AND cons.owner='my_schema_name' See ... Read more

Posted in Oracle | Tagged get primary key, Oracle

How to get primary key of a table from DB2

Posted on October 24, 2016 by Shiji Pan

SELECT COLNAME FROM syscat.COLUMNS WHERE tabschema='my_schema_name' AND tabname='my_table_name' AND KEYSEQ=1 See also: How to get primary key of a table from PostgreSQL How to get primary key of a table from SQLite How to get primary key of a table from MySQL How to get primary key of a table ... Read more

Posted in DB2 | Tagged DB2, get primary key

How to get primary key of a table from SQL Server

Posted on October 24, 2016 by Shiji Pan

SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE WHERE OBJECTPROPERTY(OBJECT_ID(CONSTRAINT_SCHEMA + '.' + CONSTRAINT_NAME), 'IsPrimaryKey') = 1 AND TABLE_NAME = 'my_table_name' AND TABLE_SCHEMA = 'my_schema_name' See also: How to get primary key of a table from PostgreSQL How to get ... Read more

Posted in Sql Server | Tagged get primary key, Sql Server

How to get primary key of a table from MySQL

Posted on October 24, 2016 by Shiji Pan

select COLUMN_NAME,INDEX_NAME from INFORMATION_SCHEMA.STATISTICS where TABLE_SCHEMA = 'my_schema_name' and TABLE_NAME='my_table_name' and INDEX_NAME='PRIMARY' See also: How to get primary key of a table from PostgreSQL How to get primary key of a table from SQLite How to get primary key of a ... Read more

Posted in Mysql | Tagged get primary key, Mysql

How to get primary key of a table from SQLite

Posted on October 24, 2016 by Shiji Pan

Run PRAGMA table_info('my_table_name') find the record that column ‘pk’ is 1, it’s the primary key. See also: How to get primary key of a table from PostgreSQL How to get primary key of a table from MySQL How to get primary key of a table from SQL Server How to get primary key ... Read more

Posted in Sqlite | Tagged get primary key, Sqlite

How to get primary key of a table from PostgreSQL

Posted on October 24, 2016 by Shiji Pan

SELECT pg_attribute.attname, format_type(pg_attribute.atttypid, pg_attribute.atttypmod) FROM pg_index, pg_class, pg_attribute, pg_namespace WHERE pg_class.oid = 'my_table_name'::regclass AND indrelid = pg_class.oid AND nspname = 'my_schema_name' AND pg_class.relnamespace = pg_namespace.oid ... Read more

Posted in PostgreSQL | Tagged get primary key, PostgreSQL

Recent Posts

  • Use Cases for Dumping to CSV
  • Convert Text to Speech by CSV / TSV
Withdata Software. ©2004 - 2025 All rights reserved.