4

I have created some databases with postgres, and put some data in them.

The problem is when I delete/drop database, and then create new database, the new database always contains tables and data from the first database that was created with postgres.

How can I delete database so that, when the new database is created it dosent contain data from old database?

Thanks

1
  • @BurhanKhalid in pgAdmin I go to [name](localhost:5432) right click and the select Delete/Drop... Commented Sep 8, 2012 at 8:53

2 Answers 2

5

It sounds like you created tables in the template1 database (or you specify the TEMPLATE xyz option with your CREATE DATABASE statement).

To get rid of the tables in the template1 database, connect to it and drop all tables there. After that new database will not contain those tables any more.

1
  • 3
    Yep, or just connect as user postgres to the postgres db and DROP DATABASE template1; then CREATE DATABASE template1 TEMPLATE template0. Commented Sep 8, 2012 at 9:08
0

Delete the rows in table using truncate commnad

 truncate <tablename>

then delete database using drop command

drop database <databasename>

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.