COPY
COPY is a command in SQL utilized for copying data between a file and a table. It can be used to import data from a file into a table (COPY TO), or export data from a table into a file (COPY FROM).
Example
Output
Explanation
In the above sample, the COPY
command is used to export data from the customers
table to a file located at /usr1/proj/bray/sql/customers
. If the command was successful, it returns the number of rows that are copied. In this case, 22 rows were copied to the file.
Example
Output
Explanation
The COPY
command above is used in SQL*Plus to copy data from one database to another. Here, the example provided creates MY_TABLE
in the database specified (MY_DATABASE
) with user MY_USER
and password MY_PASSWORD
. This new table is populated with data retrieved from MY_OTHER_TABLE
using the SELECT * FROM MY_OTHER_TABLE
statement.
The output shows that the COPY
command created MY_TABLE
and copied 15 rows of data from MY_OTHER_TABLE
into it.