本文介绍ip字段在mysql数据表中的优化。 创建测试表 mysql create table hosts( - `id` int(8) not null auto_increment, - `ip` int unsigned not null, - `hostname` varchar(30) not null, - `desc` varchar(100) , - PRIMARY KEY(`id`)) ENGINE=InnoDB;Q
本文介绍ip字段在mysql数据表中的优化。
创建测试表
mysql> create table hosts( -> `id` int(8) not null auto_increment, -> `ip` int unsigned not null, -> `hostname` varchar(30) not null, -> `desc` varchar(100) , -> PRIMARY KEY(`id`)) ENGINE=InnoDB; Query OK, 0 rows affected (0.03 sec)
查看表结构
mysql> desc hosts -> ; +----------+------------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +----------+------------------+------+-----+---------+----------------+ | id | int(8) | NO | PRI | NULL | auto_increment | | ip | int(10) unsigned | NO | | NULL | | | hostname | varchar(30) | NO | | NULL | | | desc | varchar(100) | YES | | NULL | | +----------+------------------+------+-----+---------+----------------+ 4 rows in set (0.00 sec)
插入测试数据
ECSHOP仿QQ官方商城整站源码,基于ECSHOP V2.7.3制作。整体采用黑色。费用漂亮。适合综合,包包,首饰类商城网站使用。 安装方法:1.访问:域名/install,按照程序提示进行安装。2.登陆网站后台,然后进行数据还原。3.模板设置中,选择QQSHOW模板4.清空缓存。。。 注:还原数据后,网站后台信息:后台地址:admin后台用户名:admin后台密码:www.shopex5.co
3
mysql> insert into hosts (`ip`,`hostname`,`desc`) values (inet_aton('192.168.1.106'),'test','this is test host.');
Query OK, 1 row affected (0.03 sec)mysql> select * from hosts -> ; +----+------------+----------+--------------------+ | id | ip | hostname | desc | +----+------------+----------+--------------------+ | 1 | 3232235882 | test | this is test host. | +----+------------+----------+--------------------+ 1 row in set (0.00 sec)
查询
mysql> select inet_ntoa(ip) from hosts; +---------------+ | inet_ntoa(ip) | +---------------+ | 192.168.1.106 | +---------------+ 1 row in set (0.00 sec)
原文地址:Mysql 中存储IP地址, 感谢原作者分享。
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号