I have a big list of hexadecimal numbers I'd like to insert into a PostgresQL table. I tried something like this:
INSERT INTO foo (i)
VALUES (0x1234);
...but that didn't work. Is this possible?
I have a big list of hexadecimal numbers I'd like to insert into a PostgresQL table. I tried something like this:
INSERT INTO foo (i)
VALUES (0x1234);
...but that didn't work. Is this possible?
As you've noted, you can start with a bit-string constant written in hexadecimal, and then type-cast it to the type you want. So,
INSERT INTO foo (i) VALUES (CAST(x'1234' AS int))
or
INSERT INTO foo (i) VALUES (x'1234'::int) -- postgres-specific syntax