copyselect.out

来自「postgresql8.3.4源码,开源数据库」· OUT 代码 · 共 127 行

OUT
127
字号
---- Test cases for COPY (select) TO--create table test1 (id serial, t text);NOTICE:  CREATE TABLE will create implicit sequence "test1_id_seq" for serial column "test1.id"insert into test1 (t) values ('a');insert into test1 (t) values ('b');insert into test1 (t) values ('c');insert into test1 (t) values ('d');insert into test1 (t) values ('e');create table test2 (id serial, t text);NOTICE:  CREATE TABLE will create implicit sequence "test2_id_seq" for serial column "test2.id"insert into test2 (t) values ('A');insert into test2 (t) values ('B');insert into test2 (t) values ('C');insert into test2 (t) values ('D');insert into test2 (t) values ('E');create view v_test1as select 'v_'||t from test1;---- Test COPY table TO--copy test1 to stdout;1	a2	b3	c4	d5	e---- This should fail--copy v_test1 to stdout;ERROR:  cannot copy from view "v_test1"HINT:  Try the COPY (SELECT ...) TO variant.---- Test COPY (select) TO--copy (select t from test1 where id=1) to stdout;a---- Test COPY (select for update) TO--copy (select t from test1 where id=3 for update) to stdout;c---- This should fail--copy (select t into temp test3 from test1 where id=3) to stdout;ERROR:  COPY (SELECT INTO) is not supported---- This should fail--copy (select * from test1) from stdin;ERROR:  syntax error at or near "from"LINE 1: copy (select * from test1) from stdin;                                   ^---- This should fail--copy (select * from test1) (t,id) to stdout;ERROR:  syntax error at or near "("LINE 1: copy (select * from test1) (t,id) to stdout;                                   ^---- Test JOIN--copy (select * from test1 join test2 using (id)) to stdout;1	a	A2	b	B3	c	C4	d	D5	e	E---- Test UNION SELECT--copy (select t from test1 where id = 1 UNION select * from v_test1) to stdout;av_av_bv_cv_dv_e---- Test subselect--copy (select * from (select t from test1 where id = 1 UNION select * from v_test1) t1) to stdout;av_av_bv_cv_dv_e---- Test headers, CSV and quotes--copy (select t from test1 where id = 1) to stdout csv header force quote t;t"a"---- Test psql builtins, plain table--\copy test1 to stdout1	a2	b3	c4	d5	e---- This should fail--\copy v_test1 to stdoutERROR:  cannot copy from view "v_test1"HINT:  Try the COPY (SELECT ...) TO variant.\copy: ERROR:  cannot copy from view "v_test1"HINT:  Try the COPY (SELECT ...) TO variant.-- -- Test \copy (select ...)--\copy (select "id",'id','id""'||t,(id + 1)*id,t,"test1"."t" from test1 where id=3) to stdout3	id	id""c	12	c	c---- Drop everything--drop table test2;drop view v_test1;drop table test1;

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?