简体   繁体   中英

Alter table add column and set value

I have table in mysql, it's sutructure:

ID|    text|    content
1 |     bla|     sadas|
2 |     bla|     sadas|
3 |     bla|     sadas|
4 |     bla|     sadas|

I want to add new column "UID" with "alter table" and set ID's value to UID.

I added a new column but I dont know how I can set ID's value to UID with alter.

UID|    ID|    text|    content
 1 |    1 |     bla|     sadas|
 2 |    2 |     bla|     sadas|
 3 |    3 |     bla|     sadas|
 4 |    4 |     bla|     sadas|

Sorry, if I have written something wrong in the question, my english not good.

Thanks.

update your_table
set uid = id

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM