数据库添加自增属性列

搭建测试平台,需要收集测试数据,当时建表时没有考虑加入id列作为自增列,现在需要增加,这里做个笔记

1. 增加id属性列

语法:ALTER  table <table_name> add <列名> int;

-- 增加列
ALTER table test_result_collect.statistics_time add id int;

2.给id属性赋予自增和主键属性

语法:ALTER  table <table_name>  change <列名> <列名> int not null  auto_increment primary key;

-- 自增属性和主键
ALTER table test_result_collect.statistics_time change id id int not null auto_increment primary key;

posted @ 2022-10-26 11:52  萧拾二  阅读(293)  评论(0)    收藏  举报