---
description: The command to create a new table is Syntax CREATE TABLE table_name ( field_name data_type constrain_name, field_name data_type constrain_name ); Here table_name: Is the name of the table field_name:
title: How to Create &#038; Drop Table in PostgreSQL (Examples)
image: https://www.guru99.com/images/how-to-create-and-drop-table-in-postgresql.png
---

 

[Skip to content](#main) 

**⚡ Smart Summary**

Creating and dropping tables in PostgreSQL uses the CREATE TABLE and DROP TABLE statements. You can run them in the psql SQL Shell or build tables visually in pgAdmin, and options like IF NOT EXISTS and constraints refine each table.

* 🧱 **CREATE TABLE:** Define a table with a name, columns, data types, and optional constraints using CREATE TABLE.
* 💻 **SQL Shell:** Connect to a database with \\c, run CREATE TABLE, and use \\d to list the tables you created.
* 🛡️ **IF NOT EXISTS:** Adding IF NOT EXISTS returns a notice instead of an error when the table already exists.
* 🖱️ **pgAdmin GUI:** Build a table visually by choosing the schema, naming the table, and adding columns in the Columns tab.
* ⚙️ **Table Options:** Parameters such as TEMP, UNLOGGED, and OF type\_name change how a table is stored and managed.
* 🗑️ **DROP TABLE:** DROP TABLE permanently removes a table along with its data, indexes, constraints, and rules.

[ Read More ](javascript:void%280%29;) 

![How to Create & Drop Table in PostgreSQL](https://www.guru99.com/images/how-to-create-and-drop-table-in-postgresql.png)

The command to create a new table is

**Syntax**

CREATE TABLE table_name (
	field_name data_type constrain_name,
	field_name data_type constrain_name
);

Here

table\_name: Is the name of the table

field\_name: Is the name the column

data\_type: Is the variable type of the column

constrain\_name: Is optional. It defines constraints on the column.

Tables never have the same name as any existing table in the same schema.

## PostgreSQL Create Table: SQL Shell

Here is a step by step process to create table in PostgreSQL:

**Step 1) Connect to the Database**

Connect to the database where you want to create a table. We will create a table in database guru99

\c guru99

[](https://www.guru99.com/images/1/092818%5F0651%5FHowtoCreate1.png)

**Step 2) Create a Table**

Enter code to create a table

CREATE TABLE tutorials (id int, tutorial_name text);

[](https://www.guru99.com/images/1/092818%5F0651%5FHowtoCreate2.png)

**Step 3) Check the relation of tables**

Use command \\d to check the list of relations (tables)

[](https://www.guru99.com/images/1/092818%5F0651%5FHowtoCreate3.png)

**Step 4) Try creating the same Table**

Again try to create the same table, you will get an error

[](https://www.guru99.com/images/1/092818%5F0651%5FHowtoCreate4.png)

**Step 5) Use IF NOT EXISTS parameter**

Use the parameter IF NOT EXISTS and you will get a notice instead of an error

[](https://www.guru99.com/images/1/092818%5F0651%5FHowtoCreate5.png)

### RELATED ARTICLES

* [What is PostgreSQL? Advantages & Disadvantages ](https://www.guru99.com/introduction-postgresql.html "What is PostgreSQL? Advantages & Disadvantages")
* [DISTINCT in PostgreSQL: Select, Order By & Limit (Examples) ](https://www.guru99.com/postgresql-select-distinct.html "DISTINCT in PostgreSQL: Select, Order By & Limit (Examples)")
* [PostgreSQL LIKE, Not Like, Wildcards (%, \_ ) Examples ](https://www.guru99.com/postgresql-like-query.html "PostgreSQL LIKE, Not Like, Wildcards (%, _ ) Examples")
* [PostgreSQL Constraints: Types with Example ](https://www.guru99.com/postgresql-constraints.html "PostgreSQL Constraints: Types with Example")

The list of parameters you can use while creating a table is exhaustive. Here are a few important ones

| Parameter Name    | Description                                                                                                                                   |
| ----------------- | --------------------------------------------------------------------------------------------------------------------------------------------- |
| TEMP or TEMPORARY | This parameter creats a temporary table. Temporary tables are deleted at the end of a session, or at after the current transaction.           |
| Unlogged          | Unlogged clause does not enter data into WAL(write ahead log). Due to removal of this additional IO operation, write performance is increased |
| If not exists     | If a table already exisits with a same name, a warning is shown instead of an error                                                           |
| Of\_type\_name    | A table that takes structure from the specified composite type.                                                                               |

Here is a PostgreSQL create table example of a table with constraints

CREATE TABLE order_info
( order_id integer CONSTRAINT order_details_pk PRIMARY KEY,
  Product_id integer NOT NULL,
  Delivery_date date,
  quantity integer,
  feedback TEXT
);

## PostgreSQL Create Table: pgAdmin

Below is a step by step process to create table in pgAdmin:

**Step 1)** In the Object Tree,

1. Select the [Database](https://www.guru99.com/postgresql-create-database.html)
2. Select the Schema where you want to create a table in our case public.
3. Click Create Table

[](https://www.guru99.com/images/1/092818%5F0651%5FHowtoCreate6.png)

**Step 2)** In the popup, Enter the Table Name

[](https://www.guru99.com/images/1/092818%5F0651%5FHowtoCreate7.png)

**Step 3)** 

1. Select the Columns Tab
2. Enter Column Details
3. Click Save

[](https://www.guru99.com/images/1/092818%5F0651%5FHowtoCreate8.png)

**Step 4)** In the object tree, you will see the table created

[](https://www.guru99.com/images/1/092818%5F0651%5FHowtoCreate9.png)

## PostgreSQL Delete/Drop Table

The PostgreSQL DROP TABLE statement allows you to remove a table definition and all associated data, indexes, constraints, rules, etc. for that table.

You should be cautious while using the command DROP TABLE in [PostgreSQL](https://www.guru99.com/introduction-postgresql.html) because when a table is deleted, then all the information containing in the table would also be lost permanently.

### Syntax

DROP TABLE table_name;

## Example

**Step 1)** Let’s check the existing tables using command \\d

[](https://www.guru99.com/images/1/092818%5F0651%5FHowtoCreate10.png)

**Step 2)** Delete table tutorials using the command

DROP TABLE tutorials;

[](https://www.guru99.com/images/1/092818%5F0651%5FHowtoCreate11.png)

**Step 3)** Again check for the list of relations and we see the table is deleted using Postgres delete command

[](https://www.guru99.com/images/1/092818%5F0651%5FHowtoCreate12.png)

## FAQs

⚖️ What is the difference between DROP TABLE and TRUNCATE TABLE?

DROP TABLE removes the entire table, including its structure, data, and constraints. TRUNCATE TABLE deletes all rows but keeps the empty table and its definition, so you can reuse it without recreating the structure.

🔧 How do you add or remove a column in an existing PostgreSQL table?

Use ALTER TABLE. To add a column, run ALTER TABLE name ADD COLUMN col type. To remove one, run ALTER TABLE name DROP COLUMN col. The table and its other data stay intact.

📋 What is a temporary table in PostgreSQL?

A temporary table, created with CREATE TEMP TABLE, exists only for the current session or transaction and is dropped automatically afterward. It is useful for holding intermediate results without affecting permanent tables.

🤖 How can AI help design PostgreSQL table schemas?

AI can suggest columns, data types, primary keys, and constraints from a plain description of your data. It also flags normalization issues and indexes, helping beginners build a clean, efficient table structure.

🤖 Can AI generate CREATE TABLE statements automatically?

Yes. AI can turn a description or a sample dataset into a complete CREATE TABLE statement with correct types and constraints. Always review the generated SQL before running it on your database.

#### Summarize this post with:

ChatGPT Perplexity Grok Google AI 

**Stay Updated on AI** **Get Weekly AI Skills, Trends, Actionable Advice.** 

##### Sign up for the newsletter

Subscribe for Free 

You have successfully subscribed.  
Please check your inbox. 

![AI-Newsletter]() Chosen by over **350,000+** professionals 

[Scroll to top ](#wrapper)Scroll to top 

× 

Toggle Menu Close 

Search for: 

Search

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://www.guru99.com/#organization","name":"Guru99","sameAs":["https://www.facebook.com/Guru99Official","https://twitter.com/guru99com"],"logo":{"@type":"ImageObject","@id":"https://www.guru99.com/#logo","url":"https://www.guru99.com/images/guru99-logo-v1-150x59.png","contentUrl":"https://www.guru99.com/images/guru99-logo-v1-150x59.png","caption":"Guru99","inLanguage":"en-US"}},{"@type":"WebSite","@id":"https://www.guru99.com/#website","url":"https://www.guru99.com","name":"Guru99","publisher":{"@id":"https://www.guru99.com/#organization"},"inLanguage":"en-US"},{"@type":"ImageObject","@id":"https://www.guru99.com/images/how-to-create-and-drop-table-in-postgresql.png","url":"https://www.guru99.com/images/how-to-create-and-drop-table-in-postgresql.png","width":"700","height":"250","caption":"How to Create &amp; Drop Table in PostgreSQL","inLanguage":"en-US"},{"@type":"BreadcrumbList","@id":"https://www.guru99.com/create-drop-table-postgresql.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":"1","item":{"@id":"https://www.guru99.com","name":"Home"}},{"@type":"ListItem","position":"2","item":{"@id":"https://www.guru99.com/postgresql","name":"PostgreSQL"}},{"@type":"ListItem","position":"3","item":{"@id":"https://www.guru99.com/create-drop-table-postgresql.html","name":"How to Create &#038; Drop Table in PostgreSQL (Examples)"}}]},{"@type":"WebPage","@id":"https://www.guru99.com/create-drop-table-postgresql.html#webpage","url":"https://www.guru99.com/create-drop-table-postgresql.html","name":"How to Create &#038; Drop Table in PostgreSQL (Examples)","dateModified":"2026-07-02T10:51:22+05:30","isPartOf":{"@id":"https://www.guru99.com/#website"},"primaryImageOfPage":{"@id":"https://www.guru99.com/images/how-to-create-and-drop-table-in-postgresql.png"},"inLanguage":"en-US","breadcrumb":{"@id":"https://www.guru99.com/create-drop-table-postgresql.html#breadcrumb"}},{"@type":"Person","@id":"https://www.guru99.com/author/juniper","name":"Juniper Willow","description":"I am Juniper Willow, a PostgreSQL Developer, offering expert guidance to help you optimize and master PostgreSQL database development.","url":"https://www.guru99.com/author/juniper","image":{"@type":"ImageObject","@id":"https://www.guru99.com/images/juniper-willow-author.png","url":"https://www.guru99.com/images/juniper-willow-author.png","caption":"Juniper Willow","inLanguage":"en-US"},"worksFor":{"@id":"https://www.guru99.com/#organization"}},{"articleSection":"PostgreSQL","headline":"How to Create &#038; Drop Table in PostgreSQL (Examples)","description":"The command to create a new table is Syntax CREATE TABLE table_name ( field_name data_type constrain_name, field_name data_type constrain_name ); Here table_name: Is the name of the table field_name:","keywords":"postgresql, sql","speakable":{"@type":"SpeakableSpecification","cssSelector":[".entry-title",".summary"]},"@type":"Article","author":{"@id":"https://www.guru99.com/author/juniper","name":"Juniper Willow"},"dateModified":"2026-07-02T10:51:22+05:30","image":{"@id":"https://www.guru99.com/images/how-to-create-and-drop-table-in-postgresql.png"},"copyrightYear":"2026","name":"How to Create &#038; Drop Table in PostgreSQL (Examples)","subjectOf":[{"@type":"HowTo","name":"How to Create PostgreSQL Table: SQL Shell","description":"Here is a step by step process to create table in PostgreSQL:","step":[{"@type":"HowToStep","name":"Step 1) Connect to the Database","text":"In the first step, Connect to the database where you want to create a table. We will create a table in database guru99","image":{"@type":"ImageObject","url":"https://cdn.guru99.com/images/1/092818_0651_HowtoCreate1.png"},"url":"https://www.guru99.com/create-drop-table-postgresql.html#step1"},{"@type":"HowToStep","name":"Step 2) Create a Table","text":"Now Enter code to create a table","image":{"@type":"ImageObject","url":"https://cdn.guru99.com/images/1/092818_0651_HowtoCreate2.png"},"url":"https://www.guru99.com/create-drop-table-postgresql.html#step2"},{"@type":"HowToStep","name":"Step 3) Check the relation of tables","text":"Now Use command d to check the list of relations (tables)","image":{"@type":"ImageObject","url":"https://cdn.guru99.com/images/1/092818_0651_HowtoCreate3.png"},"url":"https://www.guru99.com/create-drop-table-postgresql.html#step3"},{"@type":"HowToStep","name":"Step 4) Try creating the same Table","text":"Again try to create the same table, you will get an error","image":{"@type":"ImageObject","url":"https://cdn.guru99.com/images/1/092818_0651_HowtoCreate4.png"},"url":"https://www.guru99.com/create-drop-table-postgresql.html#step4"},{"@type":"HowToStep","name":"Step 5) Use IF NOT EXISTS parameter","text":"Now Use the parameter IF NOT EXISTS and you will get a notice instead of an error","image":{"@type":"ImageObject","url":"https://cdn.guru99.com/images/1/092818_0651_HowtoCreate5.png"},"url":"https://www.guru99.com/create-drop-table-postgresql.html#step5"}]},{"@type":"FAQPage","mainEntity":[{"@type":"Question","name":"What is the difference between DROP TABLE and TRUNCATE TABLE?","acceptedAnswer":{"@type":"Answer","text":"DROP TABLE removes the entire table, including its structure, data, and constraints. TRUNCATE TABLE deletes all rows but keeps the empty table and its definition, so you can reuse it without recreating the structure."}},{"@type":"Question","name":"How do you add or remove a column in an existing PostgreSQL table?","acceptedAnswer":{"@type":"Answer","text":"Use ALTER TABLE. To add a column, run ALTER TABLE name ADD COLUMN col type. To remove one, run ALTER TABLE name DROP COLUMN col. The table and its other data stay intact."}},{"@type":"Question","name":"What is a temporary table in PostgreSQL?","acceptedAnswer":{"@type":"Answer","text":"A temporary table, created with CREATE TEMP TABLE, exists only for the current session or transaction and is dropped automatically afterward. It is useful for holding intermediate results without affecting permanent tables."}},{"@type":"Question","name":"How can AI help design PostgreSQL table schemas?","acceptedAnswer":{"@type":"Answer","text":"AI can suggest columns, data types, primary keys, and constraints from a plain description of your data. It also flags normalization issues and indexes, helping beginners build a clean, efficient table structure."}},{"@type":"Question","name":"Can AI generate CREATE TABLE statements automatically?","acceptedAnswer":{"@type":"Answer","text":"Yes. AI can turn a description or a sample dataset into a complete CREATE TABLE statement with correct types and constraints. Always review the generated SQL before running it on your database."}}]}],"@id":"https://www.guru99.com/create-drop-table-postgresql.html#schema-26017","isPartOf":{"@id":"https://www.guru99.com/create-drop-table-postgresql.html#webpage"},"publisher":{"@id":"https://www.guru99.com/#organization"},"inLanguage":"en-US","mainEntityOfPage":{"@id":"https://www.guru99.com/create-drop-table-postgresql.html#webpage"}}]}
```
