\copy
Performs a frontend (client) copy. This is an operation that runs an SQL COPY command, but instead of the server reading or writing the specified file, psql reads or writes the file and routes the data between the server and the local file system. This means that file accessibility and privileges are those of the local user, not the server, and no SQL superuser privileges are required.
当前阅读 PG 18·选择有来源记录的版本
此版本暂无所选语言的定义,以下显示原始英文内容。
- Client
- psql 18.6
- Case-sensitive spelling
- \copy
- command
- \copy
- manual path
- app-psql.html#APP-PSQL-META-COMMANDS-COPY
- modifiers
- 未知
- spellings
- \copy
版本定义 PG 18
\copy {table[ (column_list) ] }from{'filename'| program'command'| stdin | pstdin } [ [ with ] (option[, ...] ) ] [ wherecondition]\copy {table[ (column_list) ] | (query) }to{'filename'| program'command'| stdout | pstdout } [ [ with ] (option[, ...] ) ]-
Performs a frontend (client) copy. This is an operation that runs an SQL
COPYcommand, but instead of the server reading or writing the specified file, psql reads or writes the file and routes the data between the server and the local file system. This means that file accessibility and privileges are those of the local user, not the server, and no SQL superuser privileges are required.When
programis specified,commandis executed by psql and the data passed from or tocommandis routed between the server and the client. Again, the execution privileges are those of the local user, not the server, and no SQL superuser privileges are required.For
\copy ... from stdin, data rows are read from the same source that issued the command, continuing until a line containing only\.is read or the stream reaches EOF. This option is useful for populating tables in-line within an SQL script file. For\copy ... to stdout, output is sent to the same place as psql command output, and theCOPYcommand status is not printed (since it might be confused with a data row). To read/write psql's standard input or output regardless of the current command source orcount\ooption, writefrom pstdinorto pstdout.The syntax of this command is similar to that of the SQL
COPYcommand. All options other than the data source/destination are as specified forCOPY. Because of this, special parsing rules apply to the\copymeta-command. Unlike most other meta-commands, the entire remainder of the line is always taken to be the arguments of\copy, and neither variable interpolation nor backquote expansion are performed in the arguments.Tip
Another way to obtain the same result as
\copy ... tois to use the SQLCOPY ... TO STDOUTcommand and terminate it with\gorfilename\g |. Unlikeprogram\copy, this method allows the command to span multiple lines; also, variable interpolation and backquote expansion can be used.Tip
These operations are not as efficient as the SQL
COPYcommand with a file or program data source or destination, because all data must pass through the client/server connection. For large amounts of data the SQL command might be preferable.
精确保留大小写的命令写法
\copy
Spellings in this manual definition
| Command | Documented suffix modifiers |
|---|---|
| \copy | None listed in this signature |
比较版本
完整来源事实
signature
\copy { table [ ( column_list ) ] } from { 'filename' | program 'command' | stdin | pstdin } [ [ with ] ( option [, ...] ) ] [ where condition ] \copy { table [ ( column_list ) ] | ( query ) } to { 'filename' | program 'command' | stdout | pstdout } [ [ with ] ( option [, ...] ) ]来源引用
定义来源
center · PostgreSQL 18 · ee8d1a3612338fd9adf250730cb640fcc5233b5491337cc00a316a44e3a0b9f8
正文语言: en · ee8d1a3612338fd9adf250730cb640fcc5233b5491337cc00a316a44e3a0b9f8