postgres テーブルにロードする必要がある約 6000 個の IPv6 アドレスがあります。「存在しない場合のエラー」を見つけるまでもなく、エスケープされていない「:」で中断します。postgres についてはよくわかりません。行を読み取り、「:」を無視する LOAD DATA INFILE 関数はありますか? ' 既存のレコードを探すだけでなく、
INSERT INTO ip_list (ip_addr)
SELECT 'ip_addr',
2600:3c01:e000:44:0:0:0:1,
2600:3c01:e000:44:0:0:0:2,
2600:3c01:e000:44:0:0:0:3,
2600:3c01:e000:44:0:0:0:4,
2600:3c01:e000:44:0:0:0:5,
2600:3c01:e000:44:0:0:0:7,
....
WHERE NOT EXIST(
SELECT 1 FROM ip_list WHERE name = 'ip_addr')
RETURNING id
);
ERROR: syntax error at or near ":"
LINE 3: 2600:3c01:e000:44:0:0:0:1,
アップデート:
このメソッドはレコードをアップロードしません:
You are now connected to database "postfix" as user "postgres".
postfix=# create temporary table t(ip_addr inet);
CREATE TABLE
postfix=# \copy t from '/var/www/localhost/htdocs/ipListScript'
postfix=# INSERT INTO ip_list(ip_addr)
select ip_addr from ip_list where
not exists (select 1 from ip_list where ip_list.ip_addr=ip_list.ip_addr);