Mysql 常用基本sql语句(2)
发布时间:2021-06-07
发布时间:2021-06-07
10、修改表的字段名,把字段name改为username
alter table one change name username varchar(20);
11、修改表名
Alter table 旧表名 rename 新表名;
12、修改引擎
Alter table 表名 engine=innodb|myisam;
13、在one表中插入一条语句,字段名id、username、password Insert into one(id,username,password) values (1,’test’,’a’);
14、更新表one中id>1、id<3时的字段age、password
Update one set age=100,password=’12a’ where id>1 and id<3;
15、删除表one中id=5的语句
Delete from one where id=5 ;
16、查询表one,先按照istop字段来排序,按id降序排序
Select * from one order by istop,id desc;
17、查询表one中id在4和8之间的语句
Select * from one where id between 4 and 8;
18、查询表one中id=2,5,8,10的语句,用in方法
Select * from one where id in(2,5,8,10);
19、删除2,5,9,6
Delete from one where id in(2,5,9,6);
20、删除最后一条记录
Delete from one order by id desc limit 1;
下一篇:三年级趣味数学竞赛试卷