IP地址转为int整数存放在表中
MYSQL IP地址转为int整数函数 INET_ATON('IP地址') mysql> SELECT INET_ATON('209.207.224.40'); +-----------------------------+ | INET_ATON('209.207.224.40') | +-----------------------------+ | 3520061480 | +-----------------------------+ 1 row in set (0.00 sec) MYSQL int整数转为IP地址 INET_NTOA(整数) mysql> SELECT INET_NTOA(3520061480); +-----------------------+ | INET_NTOA(3520061480) | +-----------------------+ | 209.207.224.40 | +-----------------------+ 1 row in set (0.00 sec)
时间戳:将时间以整数方式保存
第一个将时间存为整数
第二个将整数转为时间
mysql> select unix_timestamp(now()); +-----------------------+ | unix_timestamp() | +-----------------------+ | 1525247173 | +-----------------------+ 1 row in set (0.00 sec) mysql> select from_unixtime(1525247173,'%Y-%m-%d %H:%i:%s'); +-----------------------------------------------+ | from_unixtime(1525247173,'%Y-%m-%d %H:%i:%s') | +-----------------------------------------------+ | 2018-05-02 15:46:13 | +-----------------------------------------------+ 1 row in set (0.00 sec)