How to Import a CSV into PostgreSQL with pgAdmin 4 (No Code Required)

You have a CSV file and you want to query it with SQL. This guide shows you how to get that data into PostgreSQL using pgAdmin 4's built-in import tool - no command line, no code. Just point, click, and query.

Before You Start

You will need:

  • PostgreSQL and pgAdmin 4 installed. If you have not done this yet, follow our setup guide first.
  • Your CSV file saved somewhere easy to find (e.g. your Desktop or Downloads folder).
  • pgAdmin 4 open and connected to your PostgreSQL server.

Step 1 - Open Your CSV and Note the Column Names

Open your CSV in Excel or a text editor. Look at the first row - these are your column headers. Write them down along with the data type in each column (text, number, or date). You will need this information in the next step.

For example, a retail dataset might have columns like: record_id (integer), store_location (text), product_category (text), transaction_date (date), transaction_amount (numeric).

Step 2 - Create a Database (if you don't have one)

In pgAdmin 4, expand the server tree on the left. Right-click on Databases and select Create > Database. Give it a name (e.g. bampaa_project) and click Save. This is the database that will hold your table.

Step 3 - Create the Table

You need to create an empty table before importing. Expand your database, then expand Schemas > public > Tables. Right-click Tables and select Create > Table.

In the dialog that opens:

  • Give your table a name that matches your CSV filename (e.g. retail_data).
  • Click the Columns tab.
  • Click the + button to add each column. Set the name and data type for each one.
  • Use these type mappings: text columns → TEXT, whole numbers → INTEGER, decimal numbers → NUMERIC, dates → TEXT (easiest for imports - you can convert later).
  • Click Save when done.

Step 4 - Import the CSV

Right-click on the table you just created in the left panel and select Import/Export Data.

In the dialog:

  • Make sure Import is selected (not Export).
  • Click the folder icon next to Filename and browse to your CSV file.
  • Set Format to csv.
  • Tick Header if your CSV has a header row (it almost always does).
  • Set Delimiter to , (comma).
  • Click OK.

pgAdmin will run the import. If it succeeds you will see a success message showing how many rows were imported.

Step 5 - Verify the Import

Right-click your table and select View/Edit Data > All Rows. You should see your data displayed in a grid. Alternatively, open the Query Tool (Tools > Query Tool) and run:

SELECT * FROM retail_data LIMIT 10;

You should see the first 10 rows of your dataset. Your CSV is now queryable with SQL.

Troubleshooting Common Errors

  • ERROR: invalid input syntax for type integer - one of your columns has a value that is not a number (possibly a null or empty cell). Change that column's type to TEXT in your table definition and re-import.
  • ERROR: extra data after last expected column - your CSV has more columns than your table definition. Check that every column in the CSV has a matching column in the table.
  • Permission denied - on Windows, pgAdmin sometimes cannot access files on your Desktop. Move the CSV to C:\Temp or your Documents folder and try again.
  • Rows imported but some show NULL - empty cells in the CSV become NULL values in PostgreSQL. This is normal and expected.

Next Steps

Now that your data is in PostgreSQL you can run SELECT, GROUP BY, JOIN, and any other SQL query against it. If you are working through a Bampaa project, head back to your project page and continue from Step 2.

Try it yourself

Start with Level 1: SELECT, in your browser.

The first 5 levels are free · no sign-up needed