mysql总结
//查询日期之前的差距 select user_name , from_unixtime(user_lastlogin_time),now() , year(now())-year( from_unixtime(user_lastlogin_time)) - (RIGHT(CURDATE(),5)<RIGHT(from_unixtime(user_lastlogin_time),5)) AS age from sds_admin_info;// NULL操作的常见错误是不能在定义为NOT NULL的列内插入0或空字符串,但事实并非如此。在NULL表示"没有数值"的地方有数值 select 0 is null, 0 is not null, ''is null , ''is not null;下面的SELECT语句显示了引用和转义如何工作: select 'hello', '"hello"', '""hello""', 'hel''lo', '\'hello'; select "hello", "'hello'", "''hello''", "hel""lo", "\"hello"; //控制流程函数 select case 1 when 1 then 'one' when 2 then 'twe' else 'more' end; //one select case when 1>0 then 'trun' else 'false' end; //trun select case 'B' when 'a' then 1 when 'b' then 2 end; //NUll select if(1>2,2,3); //3 select if(1<2,'yes','no'); //yse select if(strcmp('test1','test2;),'no','yes') // strcmp是比较两个字符串的大小 sql语句有几类 ddl (数据定义语言) [create alter drop] dml(数据操作语言)[insert delete upate ] select dtl(数据事务语句) [commit rollback savepoint] dcl(数据控制语句) [grant revoke] show status命令 该命令可以显示你的mysql数据库的当前状态.我们主要关心的是 “com”开头的指令 show status like ‘Com%’ <=> show session status like ‘Com%’ //显示当前控制台的情况 show global status like ‘Com%’ ; //显示数据库从启动到 查询的次数 显示连接数据库次数 show status like 'Connections'; 查看标的auto_increment
select auto_increment from information_schema.tables where table_name="ysn_slide"
修改auto_increment
alter table tablename auto_increment=number
修改表的注释
alter table test1 comment '修改后的表的注释'; 修改字段的注释 alter table test1 modify column field_name int comment '修改后的字段注释'; --注意:字段名和字段类型照写就行
当delete的时候myd没有多少 optimize table tableName 清除缓存
|
浙公网安备 33010602011771号