{"id":5448,"date":"2016-10-24T04:37:24","date_gmt":"2016-10-24T04:37:24","guid":{"rendered":"http:\/\/www.withdata.com\/blog\/?p=5448"},"modified":"2017-04-20T10:57:35","modified_gmt":"2017-04-20T10:57:35","slug":"how-to-get-primary-key-of-a-table-from-mysql","status":"publish","type":"post","link":"https:\/\/www.withdata.com\/blog\/mysql\/how-to-get-primary-key-of-a-table-from-mysql.html","title":{"rendered":"How to get primary key of a table from MySQL"},"content":{"rendered":"<p><code>select COLUMN_NAME,INDEX_NAME<br \/>\nfrom INFORMATION_SCHEMA.STATISTICS<br \/>\nwhere TABLE_SCHEMA = 'my_schema_name'<br \/>\nand TABLE_NAME='my_table_name'<br \/>\nand INDEX_NAME='PRIMARY'<\/code><br \/>\nSee 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\/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><a href=\"http:\/\/www.withdata.com\/blog\/oracle\/how-to-get-primary-key-of-a-table-from-oracle.html\">How to get primary key of a table from Oracle<\/a><\/p>\n<p>Some MySQL tools you can try: <a href=\"https:\/\/www.withdata.com\/mysql\/\"> https:\/\/www.withdata.com\/mysql\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>select COLUMN_NAME,INDEX_NAME from INFORMATION_SCHEMA.STATISTICS where TABLE_SCHEMA = &#8216;my_schema_name&#8217; and TABLE_NAME=&#8217;my_table_name&#8217; and INDEX_NAME=&#8217;PRIMARY&#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 a table from SQL Server How to get primary key of a table from DB2 [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[29],"tags":[1719,1323],"class_list":["post-5448","post","type-post","status-publish","format-standard","hentry","category-mysql","tag-get-primary-key","tag-mysql"],"_links":{"self":[{"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/posts\/5448","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=5448"}],"version-history":[{"count":3,"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/posts\/5448\/revisions"}],"predecessor-version":[{"id":6438,"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/posts\/5448\/revisions\/6438"}],"wp:attachment":[{"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/media?parent=5448"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/categories?post=5448"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/tags?post=5448"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}