4. SQL Statements : COPY
 
Share this page                  
COPY
Valid in: SQL, ESQL, OpenAPI
The COPY statement copies the contents of a table to a data file (COPY INTO) or copies the contents of a file to a table (COPY FROM).
This statement has the following format:
COPY [TABLE] [schema.]table_name
     ([column_name = format [WITH NULL [(value)]]
     {, column_name = format [WITH NULL [(value)]]}])
     INTO | FROM 'filename[, type]'
     [with_clause]
table_name
Specifies an existing table from which data is read or to which data is written.
column_name
Specifies the column from which data is read or to which data is written.
format
Specifies the format in which a value is stored in the file. For details, see Column Formats for COPY.
filename
Specifies the file from which data is read or to which data is written.
type
Windows: (Optional) Specifies the file translation type: T or B.
A space after the comma or at the end of the filename causes the name to be taken literally, rather than interpreting a file type. If a filename ends in a space, Windows removes the trailing spaces so that they do not appear in the actual file name.
with_clause
Consists of the word WITH followed by a comma-separated list of one or more of the items described in With Clause Options for COPY.