-- Create table.
CREATE TABLE uint_copy_test (
col1 uint4 NOT NULL,
col2 uint2 NOT NULL,
col3 uint1 NOT NULL
) WITHOUT OIDS;
-- Load copy (text) data.
COPY uint_copy_test FROM '@abs_builddir@/data/copy_text.data';
-- Verify copy (text) data.
SELECT col3, col2, col1
FROM uint_copy_test
ORDER BY col1;
col3 | col2 | col1
------+-------+------------
0 | 0 | 0
0 | 0 | 1
0 | 0 | 2
0 | 0 | 3
0 | 0 | 4
0 | 1 | 7
0 | 2 | 8
0 | 3 | 15
0 | 4 | 16
1 | 7 | 31
2 | 8 | 32
3 | 15 | 63
4 | 16 | 64
7 | 31 | 127
8 | 32 | 128
15 | 63 | 255
16 | 64 | 256
31 | 127 | 32767
32 | 128 | 32768
63 | 255 | 65535
64 | 256 | 65536
127 | 32767 | 2147483647
128 | 32768 | 2147483648
255 | 65535 | 4294967295
(24 rows)
-- Save the copy data to binary.
COPY uint_copy_test TO '@abs_builddir@/data/copy_binary.data' WITH BINARY;
-- Remove rows.
TRUNCATE uint_copy_test;
-- Load copy (binary) data.
COPY uint_copy_test FROM '@abs_builddir@/data/copy_binary.data' WITH BINARY;
-- Verify copy (binary) data.
SELECT col3, col2, col1
FROM uint_copy_test
ORDER BY col1;
col3 | col2 | col1
------+-------+------------
0 | 0 | 0
0 | 0 | 1
0 | 0 | 2
0 | 0 | 3
0 | 0 | 4
0 | 1 | 7
0 | 2 | 8
0 | 3 | 15
0 | 4 | 16
1 | 7 | 31
2 | 8 | 32
3 | 15 | 63
4 | 16 | 64
7 | 31 | 127
8 | 32 | 128
15 | 63 | 255
16 | 64 | 256
31 | 127 | 32767
32 | 128 | 32768
63 | 255 | 65535
64 | 256 | 65536
127 | 32767 | 2147483647
128 | 32768 | 2147483648
255 | 65535 | 4294967295
(24 rows)