Skip to main content

Overview

The COPY TO STDOUT command is used to export data directly from a table to the client. This approach allows for data transfer by sending the data directly to the client, eliminating the need for server-side file operations.

Syntax

The basic syntax for using COPY TO STDOUT is:
Parameters:
  • table_name: The table from which the data will be exported.
  • stdout: Indicates that the data will be sent to the standard output (client application).
- Format: Only .csv is supported
- Delimiter: For CSV format, the default delimiter is a comma (,)

Examples

Step 1. Create the Table

  1. Create the table and insert some data into it.
  1. Upon successful creation, you should see the output below:

Step 2. Start the Export Operation

  1. Run the COPY TO STDOUT command to export the data from the book_inventory table:
  1. You will get the output with the table values, which you can use to create or copy into a CSV file: