Subject | Using External File as Table |
---|---|
Author | Vaughan Wickham |
Post date | 2018-08-29T01:27:47Z |
Hello,
I need to add a large number of IP addresses to an existing table in a database.
After doing some research, I came to the conclusion using an external file as a table would do the job.
So I’ve created a fixed length text file – 15 chars for the IP address: xxx.xxx.xxx.xxx
Here is the query to create the table, it executes OK
Create Table ip_addresses
EXTERNAL File 'C:/ip_fixed_length.txt'
(IP_Address CHAR(15));
However when I query the results, it is not as I expect
select *
from ip_addresses
IP_ADDRESS
-----------------
64.233.160.0
\n64.233.160.1
\n64.233.160
2 \n64.233.1
0.3 \n64.233
160.4 \n64.2
3.160.5 \n64
233.160.6 \n
4.233.160.7
\n64.233.160.8
\n64.233.160.
\n64.233.16
.10 \n64.233.
60.11 \n64.23
.160.12 \n64.
33.160.13 \n6
.233.160.14 \
64.233.160.15
\n64.233.160.1
\n64.233.160
17 \n64.233.1
Two questions
1. Can anyone see what I’m doing wrong here
2. Is this the best way to go about this (i.e. is there another way to “import” the IP_addresses which might be better
Thank you
Regards,
Vaughan