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 :: describe table query in postgresql 
Sql :: alter table 
Sql :: mysql sysdate 
Sql :: mysql query unique column 
Sql :: Step 1: Installing MySQL Client You can install MySQL client directly through pip using the command pip install mysqlclient 
Sql :: create mysql user on all hosts 
Sql :: oracle ORA-00054 origin 
Sql :: how to delete git repo locally 
Sql :: psql client write to bash variable 
Sql :: mysql persistence.xml 
Sql :: postgresql change value in column 
Sql :: mysql data types 
Sql :: sql ends with string 
Sql :: create table like sql 
Sql :: sql add months to date 
Sql :: DB::transaction 
Sql :: check isolation level in mysql 
Sql :: how to create table in sql 
Sql :: foreign key sqlite3 python 
Sql :: postgres list all stored procedures query 
Sql :: create unique index postgres 
Sql :: media sql 
Sql :: ERROR 1451 (23000): Cannot delete or update a parent row: a foreign key constraint fails 
Sql :: postgres select max value 
Sql :: mysql query bulk insert 
Sql :: To count number of rows in SQL table 
Sql :: sql remove last 2 digit 
Sql :: how to get nearest location in mysql with latitude and longitude 
Sql :: create or replace table sql 
Sql :: convert money to varchar sql server 
ADD CONTENT
Topic
Content
Source link
Name
4+9 =