From: Tom Lane <tgl@sss.pgh.pa.us>
To: solarsail <solarsail@gmail.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: using pg_tables and tablename in queries
Date: Tue, 04 Oct 2005 13:01:31 -0400
Message-ID: <9420.1128445291@sss.pgh.pa.us> (raw)
In-Reply-To: <aa44f4a30510040930m510bbe8do4babd97b1b37c90d@mail.gmail.com>
References: <aa44f4a30510040930m510bbe8do4babd97b1b37c90d@mail.gmail.com>
solarsail <solarsail@gmail.com> writes:
> I have a large number of tables with a common naming convention
> mytable001, mytable002, mytable003 ... mytable00n
> I would like to do a query across all of the tables, however I do not know
> all of the tables before hand, and I do not want to ( cant ) manually
> generate a query like
> select * from mytable001, mytable002, mytable003
> I have a query that returns the names of the tables I want to query:
> select tablename from pg_tables where tablename like 'mytable%'
This looks to me like a situation in which you should rethink your
data design. Those tables should all get merged into one big table,
adding one extra column that reflects what you had been using to
segregate the data into different tables.
regards, tom lane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: tgl@sss.pgh.pa.us, solarsail@gmail.com
Subject: Re: using pg_tables and tablename in queries
In-Reply-To: <9420.1128445291@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox