Thread: cleaning up template1

cleaning up template1

From
Akbar
Date:
I remember when I first play with postgresql, I play with template1
directly not created first the database ( then play with it ). So I just
want to know is there any way to cleaning up the template1?

Regards,

Akbar


Re: cleaning up template1

From
Bruce Momjian
Date:
Akbar wrote:
> I remember when I first play with postgresql, I play with template1
> directly not created first the database ( then play with it ). So I just
> want to know is there any way to cleaning up the template1?

You can look for non-system objects stored in template1 and delete them,
or you can use pg_dump and it will show the changes made to template1 in
the dump.

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073

Re: cleaning up template1

From
Bruce Momjian
Date:
Akbar wrote:
> I remember when I first play with postgresql, I play with template1
> directly not created first the database ( then play with it ). So I just
> want to know is there any way to cleaning up the template1?
>

Sorry, correction:

> You can look for non-system objects stored in template1 and delete them,
> or you can use pg_dumpall and it will show the changes made to template1 in
                 ----------
> the dump.


--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073

Re: cleaning up template1

From
Steven Klassen
Date:
# I remember when I first play with postgresql, I play with template1
# directly not created first the database ( then play with it ). So I
# just want to know is there any way to cleaning up the template1?

This should do the trick.

xinu=# update pg_database set datistemplate = false where datname ='template1';
UPDATE 1
xinu=# drop database template1;
DROP DATABASE
xinu=# create database template1 with template = template0;
CREATE DATABASE
xinu=# update pg_database set datistemplate = true where datname ='template1';
UPDATE 1

--
Steven Klassen - Lead Programmer
Command Prompt, Inc. - http://www.commandprompt.com/
PostgreSQL Replication & Support Services, (503) 667-4564