COPY TO
COPY TO with Delimiter
Overview
A delimiter is a character that separates text strings. Common delimiters include:
- Commas (,)
- Semicolon (;)
- Quotes ( ”, ’ )
- Dash (-)
- Pipes (|)
- Slashes ( / \ ).
Syntax
The syntax for COPY TO
with a delimiter is as follows:
Parameters in the syntax include:
table_name
: The table containing the data to be exported.file_path
: The CSV file location where the data will be saved.DELIMITER ‘delimiter'
: The Delimiter used in the exported CSV file.
Default delimiter is a comma (
,
).Example
Step #1: Create a Table
- Before creating a table, check for duplicate tables using the following statement:
- You will receive a list of existing tables in Oxla:
Ensure you are not creating duplicate tables.
- Create a “customer” table.
- The table and data were created successfully.
Step #2: Export Data to a CSV File using Delimiter
Important Notes:
- By default, the
- Please ensure that the directory where you save the file has a write permissions.
- By default, the
COPY TO
command overwrites the CSV file if it already exists. - Please ensure that the directory where you save the file has a write permissions.
In the example below, we are using a Comma ( ,
).
You will get the successful output below.
Using the comma ( ,
) as the delimiter for the customer
table, the expected output would be: