Skip to main content
0 reactions

How to Create a Table in pgAdmin 4

Featured card for How to Create a Table in pgAdmin 4, showing a database above a small table with the columns title and written_on.
How to Create a Table in pgAdmin 4

pgAdmin 4 can create a table in PostgreSQL without any SQL: you name the table, add its columns in a dialog, and pgAdmin writes the CREATE TABLE statement for you. Here’s how to create a table in pgAdmin 4, step by step.

Every screen on this page is real, from pgAdmin 4 9.19 with PostgreSQL 19 on macOS.

The Example

A small notebook keeps notes: each note has a title and the day it was written. You create a notes table with those two columns.

Step 1: Create a Test Database

Create a database named notebook for the example, as How to Create a Database in pgAdmin 4 shows. Then open notebook › Schemas › public in the Object Explorer.

Step 2: Open the Create Table Dialog

Right-click Tables and choose Create › Table…:

pgAdmin’s Object Explorer with Tables right-clicked in the notebook database’s public schema, and the Create menu open on its Table item.
Right-click Tables, then choose Create › Table….

Step 3: Name the Table

On the General tab, type notes in Name. Owner and Schema are already filled in: the table belongs to postgres and goes into the public schema.

pgAdmin’s Create - Table dialog on the General tab, with notes in the Name field, postgres as the owner and public as the schema.
The General tab, with the table’s name.

Step 4: Add the Columns

Open the Columns tab and click + to add a row. Type title under Name, then type text in Data type and choose text from the list. Click + again and add written_on with the type date:

pgAdmin’s Create - Table dialog on the Columns tab, with two rows: title of type text and written_on of type date.
The Columns tab, with both columns.

The other boxes are optional. Length/Precision and Scale are for types such as varchar(n) and numeric(p,s), and the Not NULL? and Primary key? switches add rules to a column.

Step 5: Check the SQL

The SQL tab shows the statements pgAdmin will run:

pgAdmin’s Create - Table dialog on the SQL tab, showing CREATE TABLE public.notes with the columns title text and written_on date, followed by ALTER TABLE IF EXISTS public.notes OWNER to postgres.
The SQL that pgAdmin generates.

The first is a CREATE TABLE with your two columns, in the public schema. The second makes postgres the table’s owner, as the General tab said.

Step 6: Save the Table

Click Save. The table appears under Tables. Open notes › Columns to see its columns:

pgAdmin’s Object Explorer showing Tables (1) with the notes table, and its Columns (2): title text and written_on date.
The new table and its two columns.

Clean Up

To delete the example, right-click notebook and choose Drop:

pgAdmin’s Object Explorer with the notebook database right-clicked and Drop highlighted in its menu.
Right-click the database, then choose Drop.

pgAdmin asks first. Click Drop:

pgAdmin’s Drop Database dialog asking whether to drop the database notebook, with Cancel and Drop buttons.
Confirm with Drop.

Warning: Dropping a database deletes it and every table in it, and it can’t be undone.

Common Mistakes

MistakeWhat happensDo this instead
Leaving Name empty on the General tabpgAdmin shows 'Name' cannot be empty. and keeps Save greyed out.Type the table’s name on the General tab.
Adding a column row without a name or a typepgAdmin shows 'Name in Columns' cannot be empty. or 'Data type in Columns' cannot be empty.Fill in both, or delete the row with its bin icon.
Right-clicking Tables under the wrong databaseThe table is created in that database.Open the right database’s Schemas › public first.

FAQ

Can I see a table’s SQL later?

Yes. Select the table in the Object Explorer and open the SQL tab on the right: it shows the statement that creates the table.

How do I create a table with SQL instead?

Run CREATE TABLE in psql or in pgAdmin’s Query Tool. Part 6 of the PostgreSQL Tutorial creates three tables that way.

Conclusion

In pgAdmin 4, right-click Tables, choose Create › Table…, name the table, add its columns on the Columns tab and click Save. The SQL tab shows the CREATE TABLE statement it runs.

Additional Resources

Postgres, PostgreSQL and the Slonik Logo are trademarks or registered trademarks of the PostgreSQL Community Association of Canada, and used with their permission.

0 comments