COPY
Synopsis
Use the COPY
statement to transfer data between tables and files. COPY TO
copies from tables to files. COPY FROM
copies from files to tables. COPY
outputs the number of rows that were copied.
Syntax
copy_from ::= COPY table_name [ ( column_name [ , ... ] ) ] FROM
{ 'filename' | PROGRAM 'command' | STDIN }
[ [ WITH ] ( option [ , ... ] ) ]
copy_to ::= COPY { table_name [ ( column_names ) ] | ( query ) } TO
{ 'filename' | PROGRAM 'command' | STDOUT }
[ [ WITH ] ( option [ , ... ] ) ]
copy_option ::= FORMAT format_name
| OIDS [ boolean ]
| FREEZE [ boolean ]
| DELIMITER 'delimiter_character'
| NULL 'null_string'
| HEADER [ boolean ]
| QUOTE 'quote_character'
| ESCAPE 'escape_character'
| FORCE_QUOTE { ( column_names ) | * }
| FORCE_NOT_NULL ( column_names )
| FORCE_NULL ( column_names )
| ENCODING 'encoding_name'
copy_from
copy_to
copy_option
Semantics
table_name
Specify the table, optionally schema-qualified, to be copied.
column_name
Specify the list of columns to be copied. If not specified, then all columns of the table will be copied.
query
Specify a SELECT
, VALUES
, INSERT
, UPDATE
, or DELETE
statement whose results are to be copied. For INSERT
, UPDATE
, and DELETE
statements, a RETURNING clause must be provided.
filename
Specify the path of the file to be copied. An input file name can be an absolute or relative path, but an output file name must be an absolute path.
Examples
- Errors are raised if the table does not exist.
COPY TO
can only be used with regular tables.COPY FROM
can be used with tables, foreign tables, or views.
当前内容版权归 YugabyteDB 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 YugabyteDB .