{"id":12054,"date":"2022-03-15T18:09:51","date_gmt":"2022-03-15T22:09:51","guid":{"rendered":"http:\/\/local.brightwhiz\/?post_type=snippets&p=12054"},"modified":"2022-03-15T18:09:53","modified_gmt":"2022-03-15T22:09:53","slug":"add-primary-key-to-existing-table-sql","status":"publish","type":"snippets","link":"http:\/\/local.brightwhiz\/snippets\/add-primary-key-to-existing-table-sql\/","title":{"rendered":"Add Primary Key to Existing Table SQL"},"content":{"rendered":"\n
Code to add a primary key to existing table SQL.<\/p>\n\n\n\n
ALTER TABLE table_name ADD PRIMARY KEY ( the_id, the_name, PMID );<\/code><\/pre>\n\n\n\nSyntax.<\/p>\n\n\n\n
ALTER TABLE <Table_Name> DROP CONSTRAINT <constraint_name>;\n\nALTER TABLE <Table_Name> ADD CONSTRAINT <constraint_name> PRIMARY KEY ( <Column1>, <Column2> )<\/code><\/pre>\n\n\n\nLive example.<\/p>\n\n\n\n
ALTER TABLE table_name ADD PRIMARY KEY ( id );<\/code><\/pre>\n","protected":false},"comment_status":"open","ping_status":"closed","template":"","meta":[],"categories":[953,27,15,16,18],"tags":[177,180,350,424,449,549,591],"yoast_head":"\nAdd Primary Key to Existing Table SQL [Snippet]<\/title>\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\t\n