开发者

Add auto_increment to primary key in SQL

开发者 https://www.devze.com 2023-02-12 01:33 出处:网络
I have table named A with column B definedint not null Primary Key and there are 4-5 foreign keys that point to this column already. With what syntax of Alter to make this primary ke开发者_如何学Pytho

I have table named A with column B defined int not null Primary Key and there are 4-5 foreign keys that point to this column already. With what syntax of Alter to make this primary ke开发者_如何学Pythony column be AUTO_INCREMENT ?


ALTER TABLE A AUTO_INCREMENT=1


Hi does something like this work?

alter table A B int NOT NULL AUTO_INCREMENT

I believe you should use something similar, if you use SQLYog to do it with the user interface then you see in the history tab the corresponding alter command generated.


If its a primary column go to the table defination, there u can set the auto increment value in the column properties. go to the Column Properties ----> click on identity Specification -----> give the identity increment value and the identity seed value. then for every new row the value will be auto incremented.

0

精彩评论

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