- 论坛徽章:
- 7
|
用SQL可以实现;可惜你没环境;这是PostgreSQL数据库- postgres=# create table li0924(id int,ip_start inet,ip_stop inet);
- CREATE TABLE
- postgres=# insert into li0924 values (1,'192.168.1.240','192.168.2.10');
- INSERT 0 1
- postgres=# select * from li0924;
- id | ip_start | ip_stop
- ----+---------------+--------------
- 1 | 192.168.1.240 | 192.168.2.10
- (1 row)
- postgres=# select id, generate_series(0, ip_stop-ip_start)+ip_start as ip_new from li0924;
- id | ip_new
- ----+---------------
- 1 | 192.168.1.240
- 1 | 192.168.1.241
- 1 | 192.168.1.242
- 1 | 192.168.1.243
- 1 | 192.168.1.244
- 1 | 192.168.1.245
- 1 | 192.168.1.246
- 1 | 192.168.1.247
- 1 | 192.168.1.248
- 1 | 192.168.1.249
- 1 | 192.168.1.250
- 1 | 192.168.1.251
- 1 | 192.168.1.252
- 1 | 192.168.1.253
- 1 | 192.168.1.254
- 1 | 192.168.1.255
- 1 | 192.168.2.0
- 1 | 192.168.2.1
- 1 | 192.168.2.2
- 1 | 192.168.2.3
- 1 | 192.168.2.4
- 1 | 192.168.2.5
- 1 | 192.168.2.6
- 1 | 192.168.2.7
- 1 | 192.168.2.8
- 1 | 192.168.2.9
- 1 | 192.168.2.10
- (27 rows)
复制代码 |
|