//录制2条记录
insert into 表名(字段1,字段2) values(1,2);
//将某个字段小于20 的 加1
updata set 表名 字段1=字段1+1 where 字段1<20;
//检测所有小于20的字段信息
select * from 标明 where now()-字段<20;
//检查年龄是否正确
select * from 标明 where now()-生日字段=年龄字段;
//删除表里最小的字段
delete from 表名 oredr by 年龄字段 desc limit 1;
//修改表name字段长度为char(20)
alert table modify name char(20);
//修改username 字段段为username char(30);
alert table modify username char(30);
//创建表包含名字,性别,生日字段
create table stu(
sid int unsigned primary key auto_increment,
name char(20) not null default '',
sex enum('男','女') not null default '男',
birthday date);
//查找所有90后的女同学
select * from student where sex='女' and year(birthday)>=1990 and year(birthday)<=1999;
select * from student where between 19000000 and 20000000 and sex='女';
//查找班级年纪最小的同学(按照生日字段排序)
select * from stu order by birthday desc limit 1;
//查询stu表里用户总数
select count(*) from stu;
//查找stu表名字包含'任'的同学的总数
select count(*) from stu where sname like ‘%任%’;
//删除表中所有数据
truncate table_name;
//退出数据库
quit
//不同字段的表互相插入数据,把a的数据插入b的表中,对应字段
insert into b(id,ctitle,content) select aid,title,con from a;
查询并批量替换
update 表名 set 字段=replace(字段,'原字符','现字符')
update 表名 set 字段1=字段2 where 字段3<='';
update 表名 set 字段1=0 where 字段2='3';
注:以上就是相关比较常用的mysql命令汇总了 ,希望能够帮助到大家,谢谢支持,赞赏。
网友评论