关于postgresql:postgresql-copy-消息

30次阅读

共计 1295 个字符,预计需要花费 4 分钟才能阅读完成。

简略查问两个非凡的 copy 的返回值
https://www.postgresql.org/do…

CopyInResponse
The backend is ready to copy data from the frontend to a table; see Section 52.2.5.

CopyOutResponse
The backend is ready to copy data from a table to the frontend; see Section 52.2.5.

copy 相干音讯

CommandComplete (B)
Byte1('C')
Identifies the message as a command-completed response.

其中:String
For a COPY command, the tag is COPY rows where rows is the number of rows copied. (Note: the row count appears only in PostgreSQL 8.2 and later.)


CopyData (F & B)
Byte1('d')
Identifies the message as COPY data.

CopyDone (F & B)
Byte1('c')
Identifies the message as a COPY-complete indicator.

CopyFail (F)
Byte1('f')
Identifies the message as a COPY-failure indicator.

CopyInResponse (B)
Byte1('G')
Identifies the message as a Start Copy In response. The frontend must now send copy-in data (if not prepared to do so, send a CopyFail message).

CopyOutResponse (B)
Byte1('H')
Identifies the message as a Start Copy Out response. This message will be followed by copy-out data.

CopyBothResponse (B)
Byte1('W')
Identifies the message as a Start Copy Both response. This message is used only for Streaming Replication.

copy to file

postgres=# copy (select * from t1) to '/tmp/t1.csv';
COPY 5

copy from stdin

postgres=# copy t1 from stdin  (DELIMITER '|');
Enter data to be copied followed by a newline.
End with a backslash and a period on a line by itself, or an EOF signal.
>> 23|gg
>> 24|qq
>> 25|tt
>> COPY 3

copy to stdout

postgres=# copy t1 to STDOUT (DELIMITER '|');;
23|gg
24|qq
25|tt

正文完
 0