Import data from CSV
This topic describes how to import data into a Neon database table from a CSV file.
The instructions require a working installation of psql. The
psql client is the native command-line client for Postgres. It provides an interactive session for sending commands to Postgres. For more information about
psql, refer to the psql reference, in the PostgreSQL Documentation.
The following example uses the ready-to-use
neondb database that is created with your Neon project, a table named
customer, and a data file named
customer.csv. Data is loaded from the
customer.csv file into the
Connect to the
psql. For example:
For more information about connecting to Neon with
psql, see Connect with psql.
You can also create tables using the SQL Editor in the Neon Console. See Query with Neon's SQL Editor.
customer.csvfile with the following data:
psqlprompt, load the data from the
customer.csvfile using the
If the command runs successfully, it returns the number of records copied to the database:
For more information about the
\copyoption, refer to the psql reference, in the PostgreSQL Documentation.