Re: check table existence...

From: "Moritz Bayer" <moritz(dot)bayer(at)googlemail(dot)com>
To: "A(dot) Kretschmer" <andreas(dot)kretschmer(at)schollglas(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: check table existence...
Date: 2007-01-15 12:45:13
Message-ID: c244500b0701150445x23394fa7q55ba457a83ec23ea@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Thanks, that's exactly what I was looking for :-)

kind regards,
Morirt

2007/1/15, A. Kretschmer <andreas(dot)kretschmer(at)schollglas(dot)com>:
>
> am Mon, dem 15.01.2007, um 13:18:11 +0100 mailte Moritz Bayer folgendes:
> > Dear list,
> >
> > I would like to create a function which gets a tablename and checks if
> the
> > specific table exists.The return value should be a bool.
> > Now I'm wondering how to do this the best way.
> >
> > Any suggestions?
>
> You can ask pg_tables:
>
> select count(1) from pg_tables where tablename = 'foo' and schemaname =
> 'public';
>
>
> This ask for a table called 'foo' in the schema 'public'.
>
>
> Andreas
> --
> Andreas Kretschmer
> Kontakt: Heynitz: 035242/47150, D1: 0160/7141639 (mehr: -> Header)
> GnuPG-ID: 0x3FFF606C, privat 0x7F4584DA http://wwwkeys.de.pgp.net
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Have you searched our list archives?
>
> http://archives.postgresql.org/
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Shoaib Mir 2007-01-15 12:45:51 Re: check table existence...
Previous Message Jan van der Weijde 2007-01-15 12:44:06 Re: Performance with very large tables