当前位置:Gxlcms > 数据库问题 > mysql 常用sql

mysql 常用sql

时间:2021-07-01 10:21:17 帮助过:12人阅读

 

(2)ipv6

  16字节,需要两个bigint

 

2. unix时间戳

UNIX_TIMESTAMP()   以unix时间戳返回当前时间
FROM_UNIXTIME(xx) 将unix时间戳转换为普通格式时间

 

1、2:

  一个表,存储ip和时间:

CREATE TABLE table_fun (
    id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
    ip INT(10) UNSIGNED NOT NULL DEFAULT 0,
    addtime INT(10) UNSIGNED NOT NULL DEFAULT 0
    );

  插入数据:

insert into table_fun(ip,addtime) values(inet_aton(192.168.1.1),unix_timestamp());

  查询数据:

select inet_ntoa(ip),from_unixtime(addtime) from table_fun;

  技术图片

 

  技术图片

 

  删除数据:

delete from table_fun where inet_ntoa(ip)=192.168.1.0;

 

mysql 常用sql

标签:数字   转换   png   class   font   nbsp   alt   因此   create   

人气教程排行