Iam*_*mIC 7 csv postgresql postgresql-9.2
我有这样的数据:
Akhoond,1,Akhoond,"{""Akhund"",""Akhwan""}",0
pgAdmin的导入拒绝了.文本[]需要采用什么格式在CSV中?
我也试过这个:
Akhoond,1,Akhoond,"{Akhund,Akhwan}",0
这是表创建:
CREATE TABLE private."Titles"
(
"Abbrev" text NOT NULL,
"LangID" smallint NOT NULL REFERENCES private."Languages" ("LangID"),
"Full" text NOT NULL,
"Alt" text[],
"Affix" bit
)
WITH (
OIDS=FALSE
);
ALTER TABLE private."Titles" ADD PRIMARY KEY ("Abbrev", "LangID");
CREATE INDEX ix_titles_alt ON private."Titles" USING GIN ("Alt");
ALTER TABLE private."Titles"
OWNER TO postgres;
Run Code Online (Sandbox Code Playgroud)
找出最好的方法是创建一个包含所需值的表,并COPY ... TO STDOUT查看:
craig=> CREATE TABLE copyarray(a text, b integer, c text[], d integer);
CREATE TABLE
craig=> insert into copyarray(a,b,c,d) values ('Akhoond',1,ARRAY['Akhund','Akhwan'],0);
INSERT 0 1
craig=> insert into copyarray(a,b,c,d) values ('Akhoond',1,ARRAY['blah with spaces','blah,with,commas''and"quotes'],0);
INSERT 0 1
craig=> \copy copyarray TO stdout WITH (FORMAT CSV)
Akhoond,1,"{Akhund,Akhwan}",0
Akhoond,1,"{""blah with spaces"",""blah,with,commas'and\""quotes""}",0
Run Code Online (Sandbox Code Playgroud)
所以它看起来"{Akhund,Akhwan}"很好.请注意我添加的第二个示例,显示如何处理逗号,引用数组文本中的空格.
这适用于psql \copy命令; 如果它不能与PgAdmin-III一起使用psql,那么我建议使用和\copy.
| 归档时间: |
|
| 查看次数: |
4047 次 |
| 最近记录: |