开发者

Altering Table Information in MySQL

开发者 https://www.devze.com 2023-03-14 03:04 出处:网络
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 spe

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`);
0

精彩评论

暂无评论...
验证码 换一张
取 消