Altering Table Information in MySQL
I'm relatively new to MySQL.
So, let's say I make a table and my table utilizes an "id" column to keep track of a unique identification number. However, when creating my table, I neglected to specify that I wanted the column to be auto-incremented, not null, and the primary key 开发者_如何学JAVAof the table. What MySQL statement can I use to alter the information of this table so that it is correct for what I want? I have tried some variations of the "ALTER TABLE" command, don't seem to understand the syntax.
use this:
ALTER TABLE `table_name`
MODIFY COLUMN `id` BIGINT( 20 ) PRIMARY KEY AUTO_INCREMENT
ALTER TABLE `yourTable`
CHANGE COLUMN `id` `id` INT(10) NOT NULL AUTO_INCREMENT FIRST,
ADD PRIMARY KEY (`id`);
精彩评论