#查询日期
select * from mmcgi_rawpack_tb where date(time)>2011-07-06;
select * from mmcgi_rawpack_tb where date(time)>'%Y-%m-%d';
#时间-秒
select time_to_sec(time) from mmcgi_rawpack_tb;
#日期-天
select to_days(time) from mmcgi_rawpack_tb;
#unix标准时间-1970年算起 utc
select unix_timestamp(time) from mmcgi_rawpack_tb;
#查询一天以内的数据
select * from mmcgi_rawpack_tb where unix_timestamp(time)>unix_timestamp(now())-86400;
#清空数据表,这样自增的id都可以从1开始
truncate table table_name;
#查看表的结构
describe tablename;
#查看非空非零数据
select * from mmcgi_nodedata_tb where node_data <> "" and node_data <> "0";
自動初始化 及 自動更新
ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
只做自動初始化 (建立時初始化, 更新時不修改時間)
ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP
只做自動更新 (建立時不做初始化動作)
ts TIMESTAMP DEFAULT 0 ON UPDATE CURRENT_TIMESTAMP
全都不做(使用這個的話, 或許直接用 DATETIME 的型態 似乎比較方便?)
ts TIMESTAMP DEFAULT 0
mysql> SELECT * FROM table LIMIT 5,10; // 检索记录行 6-15
//为了检索从某一个偏移量到记录集的结束所有的记录行,可以指定第二个参数为 -1:
mysql> SELECT * FROM table LIMIT 95,-1; // 检索记录行 96-last.
//如果只给定一个参数,它表示返回最大的记录行数目:
mysql> SELECT * FROM table LIMIT 5; //检索前 5 个记录行
//换句话说,LIMIT n 等价于 LIMIT 0,n。
编码
mysql> \s
等于status;
查看mysql支持的编码:
show character set;
单独设置某个数据库:
ALTER TABLE mmcgi_hardcodetag_tb CONVERT TO CHARACTER SET utf8;
用show full columns from tenant;命令查看tenant表各个字段的字符编码。
If you have any questions or ideas ,please feel free to contact me : )
thx.^^
QQ: 1623213673