Import & Export
PostgreSQL Import & Export
Categories:
Import from another table
INSERT INTO target_table (column_list)
SELECT source_column_list
FROM source_table
WHERE condition;
INSERT INTO customer_backup (customer_id, customer_name, contact_name, address, city, postal_code, country)
SELECT customer_id, customer_name, contact_name, address, city, postal_code, country
FROM customers
WHERE country = 'Taiwan';
Import CSV
Via SQL
table_name
is the name of the table where you want to import the data/path/to/file.csv
is the path to the CSV file on your computerDELIMITER
specifies the delimiter used in the CSV file (in this case, a comma).
COPY table_name FROM '/path/to/file.csv' DELIMITER ',' CSV;
COPY persons(first_name, last_name, dob, email)
FROM '/Users/kj/import_person.csv'
DELIMITER ','
CSV HEADER;
COPY table_name [ ( column_name [, ...] ) ]
FROM { 'filename' | STDIN }
[ [ WITH ] ( option [, ...] ) ]
Via DBeaver GUI
Click the right mouse on the table that you want to import, and click the Import Data
Select the csv file that you want to import on your computer