Search
 
SCRIPT & CODE EXAMPLE
 

SQL

mysql change primary key

ALTER TABLE tableName MODIFY COLUMN id INT; /* First you should drop auto increment */
ALTER TABLE tableName DROP PRIMARY KEY; /* Dop primary key */
ALTER TABLE tableName ADD PRIMARY KEY (new_id); /* Set primary key to the new column */
ALTER TABLE tableName MODIFY COLUMN new_id INT AUTO_INCREMENT; /* Set auto increment to the new primary key */
Comment

PREVIOUS NEXT
Code Example
Sql :: oracle list of long running queries 
Sql :: MySql get primary keys of table 
Sql :: mysql sysdate - 1 day 
Sql :: mysql time ago difference 
Sql :: sql create table with datetime automatically 
Sql :: create mysql user 
Sql :: ora-00054 resource busy and acquire with nowait 
Sql :: query concatenate 
Sql :: postgresql restore from dump 
Sql :: access mysql command mac xampp 
Sql :: sql delete multiple conditions 
Sql :: data types sql 
Sql :: mysql backup skip table 
Sql :: mysql create table like 
Sql :: How to reset forgotten postgresql password 
Sql :: How to get todays date and current time in mysql 
Sql :: mysql add fields 
Sql :: how to pass password mysql command line 
Sql :: sql delete join 
Sql :: xml path sql server 
Sql :: oracle tables with column name 
Sql :: sql limit decimal places 
Sql :: pl sql ptint 
Sql :: mysql check if not null 
Sql :: restore postgres database from dump 
Sql :: what is integrity constraints 
Sql :: postgresql extract hour and minutes from timestamp 
Sql :: postgres copy table from one schema to another 
Sql :: mysql insert value date 
Sql :: how to connect to xampp sql server on windows cmd 
ADD CONTENT
Topic
Content
Source link
Name
4+2 =