Skip to content

Latest commit

 

History

History
37 lines (26 loc) · 1.18 KB

copy-command.md

File metadata and controls

37 lines (26 loc) · 1.18 KB

Use copy command import array of Composite Types data

CREATE TYPE e_theme_icon_type AS ENUM ('perfect', 'common');

CREATE TYPE theme_icon AS (
  image varchar(200),
  svg varchar(200),
  background varchar(20),
  type e_theme_icon_type,
  goldenBackground varchar(200)
);

CREATE TABLE test (a theme_icon[], b text);

-- import file(t.copy) content
{"(g,#eeeeee,#FBCF00,perfect,#eeeeee)","(g,#678,#FBCF00,common,#123)"},jack

\copy test FROM '/Users/jack/t.copy'
# malformed array literal: "{"(g,#eeeeee,#FBCF00,perfect,#eeeeee)","(g,#678,#FBCF00,common,#123)"},jack"
# DETAIL:  Junk after closing right brace.

-- use '|' instead
{"(g,#eeeeee,#FBCF00,perfect,#eeeeee)","(g,#678,#FBCF00,common,#123)"}|jack

\copy test FROM '/Users/jack/t.copy' DELIMITER '|'

SELECT * FROM test;
+------------------------------------------------------------------------+------+
| a                                                                      | b    |
|------------------------------------------------------------------------+------|
| {"(g,#eeeeee,#FBCF00,perfect,#eeeeee)","(g,#678,#FBCF00,common,#123)"} | jack |
+------------------------------------------------------------------------+------+