Importing CSV Files to PostgreSQL Databases
08.27.07 (5:22 pm) [edit]
1. Create table. example.
create table countries(
id serial,
code varchar(2) unique,
name varchar(100),
primary key(id)
);
2. Loading the data.
Next, we need to load the data from the CSV file into the newly created table, we can achieve this by using PostrgreSQL's COPY command. COPY countries from '/path/to/csv/COUNTRY_LIS T.csv' DELIMITERS ',' CSV;