find the template of a database in SQL

Started by Walter Cruzover 19 years ago6 messages
#1Walter Cruz
walter.php@gmail.com

Hi all..

There's some way to find the template of a database in SQL (using 7.4)?

[]'s
- Walter

#2Joshua D. Drake
jd@commandprompt.com
In reply to: Walter Cruz (#1)
Re: find the template of a database in SQL

Walter Cruz wrote:

Hi all..

There's some way to find the template of a database in SQL (using 7.4)?

Find the template? Could you clarify your question?

Show quoted text

[]'s
- Walter

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly

#3Walter Cruz
walter.php@gmail.com
In reply to: Joshua D. Drake (#2)
Re: find the template of a database in SQL

well, when I create a database, it inherits from template1

When I have a table that I don't know if it inherits from template 1,
how can I find the 'super' ?

[]'s
- Walter

Show quoted text

On 8/18/06, Joshua D. Drake <jd@commandprompt.com> wrote:

Walter Cruz wrote:

Hi all..

There's some way to find the template of a database in SQL (using 7.4)?

Find the template? Could you clarify your question?

[]'s
- Walter

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly

#4Joshua D. Drake
jd@commandprompt.com
In reply to: Walter Cruz (#3)
Re: find the template of a database in SQL

Walter Cruz wrote:

well, when I create a database, it inherits from template1

When I have a table that I don't know if it inherits from template 1,
how can I find the 'super' ?

I do not believe that tables have templates in 7.4 unless you specifically
use a query like:

create table foo as select * from bar;

Joshua D. Drake

Show quoted text

[]'s
- Walter
On 8/18/06, Joshua D. Drake <jd@commandprompt.com> wrote:

Walter Cruz wrote:

Hi all..

There's some way to find the template of a database in SQL (using

7.4)?
Find the template? Could you clarify your question?

[]'s
- Walter

---------------------------(end of

broadcast)---------------------------

TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that

your

message can get through to the mailing list cleanly

---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

#5Tom Lane
tgl@sss.pgh.pa.us
In reply to: Walter Cruz (#3)
Re: find the template of a database in SQL

"Walter Cruz" <walter.php@gmail.com> writes:

well, when I create a database, it inherits from template1
When I have a table that I don't know if it inherits from template 1,
how can I find the 'super' ?

There isn't any persistent "inheritance" relationship for databases.
CREATE DATABASE just copies the source database at the instant of
creation, and that's the end of it.

regards, tom lane

#6korryd@enterprisedb.com
korryd@enterprisedb.com
In reply to: Joshua D. Drake (#4)
Re: find the template of a database in SQL

When I have a table that I don't know if it inherits from template 1,
how can I find the 'super' ?

I do not believe that tables have templates in 7.4 unless you specifically
use a query like:

create table foo as select * from bar;

I think Walter wants to know if a given table was defined in the current
database, or if it was created from the template database (template0 or
template1) when the database was created.

I don't think you can tell. When you create a new database from a
template (typically template1), you're just making a copy of that
template. It's not really inheritance (meaning that a change to the
table definition in the template won't affect any databases "cloned"
from that template).

To find out where the table came from, you'd have to know which template
your current database was cloned from and I don't think we store that
info anywhere.

-- Korry

--
Korry Douglas korryd@enterprisedb.com
EnterpriseDB http://www.enterprisedb.com