I have created a simple table that has arrays of INET
fields:
CREATE TABLE nettable (id integer, source inet[], destination inet[]);
I can create the table, but when I try to insert data I always get a syntax error.
I have tried this syntax:
INSERT INTO nettable (id, source, destination)
VALUES (1, [ ’10.10.10.0/24’ ], [ ‘1.2.3.4/32’ ]);
And this syntax:
INSERT INTO nettable (id, source, destination)
VALUES (1,’{"10.10.10.0/24"}',’{"1.2.3.4/32"}');
Both times it complains about a syntax near the brackets.
What's the right syntax?
CodePudding user response:
The second attempt is close. But use plain single quotes '
- a.k.a. "Apostrophe":
INSERT INTO nettable (id, source, destination)
VALUES (1, '{"10.10.10.0/24"}', '{"1.2.3.4/32"}');
Double-quotes would only be only needed to eliminate ambiguity. So not in this case:
INSERT INTO nettable (id, source, destination)
VALUES (1, '{10.10.10.0/24}', '{1.2.3.4/32}');
This ’
is a "Right Single Quotation Mark".