{"id":5456,"date":"2016-10-24T04:59:33","date_gmt":"2016-10-24T04:59:33","guid":{"rendered":"http:\/\/www.withdata.com\/blog\/?p=5456"},"modified":"2017-04-20T10:47:43","modified_gmt":"2017-04-20T10:47:43","slug":"how-to-get-primary-key-of-a-table-from-oracle","status":"publish","type":"post","link":"https:\/\/www.withdata.com\/blog\/oracle\/how-to-get-primary-key-of-a-table-from-oracle.html","title":{"rendered":"How to get primary key of a table from Oracle"},"content":{"rendered":"<p><code>SELECT cols.column_name<br \/>\nFROM all_constraints cons, all_cons_columns cols<br \/>\nWHERE cons.constraint_type = 'P'<br \/>\nAND cons.constraint_name = cols.constraint_name<br \/>\nAND cons.table_name = cols.table_name<br \/>\nAND cons.owner = cols.owner<br \/>\nAND cons.table_name='my_table_name'<br \/>\nAND cons.owner='my_schema_name'<\/code><\/p>\n<p>See also:<\/p>\n<p><a href=\"http:\/\/www.withdata.com\/blog\/postgresql\/how-to-get-primary-key-of-a-table-from-postgresql.html\">How to get primary key of a table from PostgreSQL<\/a><\/p>\n<p><a href=\"http:\/\/www.withdata.com\/blog\/sqlite\/how-to-get-primary-key-of-a-table-from-sqlite.html\">How to get primary key of a table from SQLite<\/a><\/p>\n<p><a href=\"http:\/\/www.withdata.com\/blog\/mysql\/how-to-get-primary-key-of-a-table-from-mysql.html\">How to get primary key of a table from MySQL<\/a><\/p>\n<p><a href=\"http:\/\/www.withdata.com\/blog\/sql-server\/how-to-get-primary-key-of-a-table-from-sql-server.html\">How to get primary key of a table from SQL Server<\/a><\/p>\n<p><a href=\"http:\/\/www.withdata.com\/blog\/db2\/how-to-get-primary-key-of-a-table-from-db2.html\">How to get primary key of a table from DB2<\/a><\/p>\n<p>Some Oracle tools you can try: <a href=\"https:\/\/www.withdata.com\/oracle\/\"> https:\/\/www.withdata.com\/oracle\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>SELECT cols.column_name FROM all_constraints cons, all_cons_columns cols WHERE cons.constraint_type = &#8216;P&#8217; AND cons.constraint_name = cols.constraint_name AND cons.table_name = cols.table_name AND cons.owner = cols.owner AND cons.table_name=&#8217;my_table_name&#8217; AND cons.owner=&#8217;my_schema_name&#8217; 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 [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[32],"tags":[1719,1325],"class_list":["post-5456","post","type-post","status-publish","format-standard","hentry","category-oracle","tag-get-primary-key","tag-oracle"],"_links":{"self":[{"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/posts\/5456","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/comments?post=5456"}],"version-history":[{"count":3,"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/posts\/5456\/revisions"}],"predecessor-version":[{"id":6423,"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/posts\/5456\/revisions\/6423"}],"wp:attachment":[{"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/media?parent=5456"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/categories?post=5456"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/tags?post=5456"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}