Thread: Deleting data bases and tables?

Deleting data bases and tables?

From
"Cima"
Date:
hi,
 
i created a database and ran an sql script to create some tables. later i deleted the tables and later the data base itself. when i created a new database i noticed that the tables from the previous non related database appeared in this new database. i ran another sql script to create more tables and the new tables didnt appear immediately, i had to restart the postmaster and then the new tbles with the other tables appeared so im wondering if im not going about the deleting procedure the right way. what can or should i do to stop the old table from reappearing in my new databases?
 
thanx in advance.

Re: Deleting data bases and tables?

From
Michael Fuhr
Date:
On Wed, Mar 23, 2005 at 02:05:12AM -0500, Cima wrote:
>
> i created a database and ran an sql script to create some tables.
> later i deleted the tables and later the data base itself. when i
> created a new database i noticed that the tables from the previous non
> related database appeared in this new database.

Have you created tables in the default template database (template1)?
If so, then those tables will be copied to newly-created databases.
See "Template Databases" in the "Managing Databases" chapter of the
documentation:

http://www.postgresql.org/docs/8.0/static/manage-ag-templatedbs.html

> i ran another sql script to create more tables and the new tables
> didnt appear immediately, i had to restart the postmaster and then
> the new tbles with the other tables appeared

This sounds odd -- are you sure you've analyzed the situation
correctly?  Can you provide an exact sequence of steps that
demonstrates this behavior?

> so im wondering if im not going about the deleting procedure the
> right way. what can or should i do to stop the old table from
> reappearing in my new databases?

I'd guess that you've been working in the template1 database, so
when you create a new database it gets a copy of the tables in
template1.  In general you should leave template1 alone and create
other databases for doing work.

Do you see this problem if you use template0 as the database template?
See the createdb or CREATE DATABASE documentation for instructions
on how to do that.

--
Michael Fuhr
http://www.fuhr.org/~mfuhr/