数据重新补充
这里使用alter table Bookbought.bookuser add userage INT after userphone;
为用户表bookuser
在userphone
列后边添加一个类型为INT
的新列userage
。
使用alter table Bookbought.bookuser add sex varchar(6) after userage ;
为用户表bookuser
在userage
列后边添加一个类型为INT
的新列sex
。
describe Bookbought.bookuser;
查看数据库中的表结构,可以查看插入之后的数据字段。
update更新数据
使用格式如下:
update 数据库.表名
set 字段 = 字段值
where 判断条件
使用下方的update
语句把以前没有填上去的年龄填上去。
update Bookbought.bookuser set userage = 31,sex='male' where id = 1;
update Bookbought.bookuser set userage = 32,sex='female' where id = 2;
update Bookbought.bookuser set userage = 33,sex='male' where id = 3;
update Bookbought.bookuser set userage = 34,sex='female' where id = 4;
update Bookbought.bookuser set userage = 35,sex='male' where id = 5;
update Bookbought.bookuser set userage = 36,sex='male' where id = 6;
update Bookbought.bookuser set userage = 37,sex='female' where id = 7;
update Bookbought.bookuser set userage = 38,sex='male' where id = 8;
update Bookbought.bookuser set userage = 45,sex='male' where id = 9;
update Bookbought.bookuser set userage = 50,sex='female' where id = 10;