| From: | Nico <nicod(at)tiscalinet(dot)it> |
|---|---|
| To: | pgsql-general(at)postgresql(dot)org |
| Subject: | Re: getting inherited table name |
| Date: | 2001-09-06 17:11:34 |
| Message-ID: | 9n83hg$2mes$1@news.tht.net |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
Eric Kolve wrote:
> In the pgsql tutorial two tables are created capitals inherits cities.
>
> When you do SELECT * FROM cities, you get both capitals and cities. Is
> there anyway to get get the name of the table so I could possibly know
> the 'type' it was? Or should this be maintained as a separate column
> 'city_type' that has a value of 'capital'?
>
> Suppose I had another table river_cities and what I would want to be
> able to is SELECT * FROM cities and know whether the city was a
> river_city, capital, or nothing at all.
No additional fields are required:
SELECT c.*, c.tableoid, pgc.relname as city_type
FROM cities c, pg_class pgc
WHERE c.tableoid = pgc.oid
regards
Nico
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Jeff Eckermann | 2001-09-06 17:21:41 | Can a pl/perl function return NULL? |
| Previous Message | Tom Lane | 2001-09-06 15:56:42 | Re: createdb buggy? |