How to Import CSV to Postgesql Using Dbeaver

Hello, today we are going to talk about How to Import CSV to Postgesql Using Dbeaver topic.

For this article we will use a sample csv file which contains cities. You can download CSV sample from https://github.com/datasets/world-cities/blob/master/data/world-cities.csv URL.

How to Import CSV to Postgesql Using Dbeaver

In this article i will only use Dbeaver to import data. In one of my previous articles, i covered How to Import CSV File Data Into a PostgreSQL Table topic.

If you are looking for a command line tutorial you can follow the guide on the link above.

Creating a Sample Table

If you look at the titles of the csv file you see: name, country, subcountry, geonameid. Let’s create a table as following:

CREATE TABLE WORLD_CITIES (
	id integer generated always as identity,
	name varchar(200),
	country varchar(200),
	subcountry varchar(200),
	geonameid bigint,
	primary key(id)
);

If you run the statement above it creates a table.

Importing CSV using Dbeaver

This chapter applies to all other database engines as well. So even if you are using another database engine you can use this article to import CSV data using dbeaver.

I really like Dbeaver’s CSV import wizard, it is highly customizable and doesn’t force you to you one specific file type.

How to Import CSV to Postgesql Using Dbeaver

Right click to world_cities table and click to Import Data button.

dbeaver csv import wizard

Select CSV from the list and click Next.

Open CSV file to import database

Choose file to import. In bottom section there are settings for the file you chose.

If your file contains header select header position. If file has a different encoding you can also specify it on that form.

Map columns between csv and table to import data

You can map columns from CSV to table. This form is pretty customizable, you can skip a column, you can change mapping.

Select batch size and performance settings to import csv

For very big CSV files, i would like to suggest you to limit “Do Commit after row insert:” with a lower value.

Summary page of the importing wizard

Wizard shows a summary of the operation. Click proceed to start importing data.

For our csv file, it takes around a second to complete importing.

select count from table after importing wizard

Select data from the table, and ta daaa we are done.

Summary

We believe that the best conversations happen when everyone has a chance to share their thoughts and ask questions. Your questions spark insightful discussions and provide an opportunity to learn from each other. Whether you’re curious about a topic we covered or you’d like to share your perspective, don’t hesitate to leave a comment and join the conversation. Your input is valued and can greatly enrich the community’s experience.

By asking questions and sharing your thoughts, you contribute to a dynamic and inclusive environment where diverse opinions are respected. Your input helps us understand what interests you the most and allows us to tailor our content to better meet your needs. Whether it’s a suggestion, a question, or an insight, your comments are an integral part of our community. Let’s build a space where everyone feels empowered to participate, learn, and grow together.


Hi! I’m an IT Specialist

I want to hear from you! I am Working with enterprises for 10+ years to improve their infrastructure and efficiency.

Get in touch with me.

A new post everyday, subscribe now and don’t miss it!

Subscribe to our newsletter for cool news

Hi! I’m an IT Specialist

I want to hear from you! I am Working with enterprises for 10+ years to improve their infrastructure and efficiency.

Get in touch with me.

Leave a Reply

Discover more from Empower. Innovate. Transform.

Subscribe now to keep reading and get access to the full archive.

Continue reading