X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id E6FA0DA214 for ; Wed, 5 Oct 2005 12:23:51 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 60539-09 for ; Wed, 5 Oct 2005 15:23:50 +0000 (GMT) Received: from floppy.pyrenet.fr (floppy.pyrenet.fr [194.116.145.2]) by svr1.postgresql.org (Postfix) with ESMTP id 6660BDA226 for ; Wed, 5 Oct 2005 12:23:49 -0300 (ADT) Received: by floppy.pyrenet.fr (Postfix, from userid 106) id 9244D3105B; Wed, 5 Oct 2005 17:23:48 +0200 (MET DST) From: "codeWarrior" X-Newsgroups: pgsql.sql Subject: Re: using pg_tables and tablename in queries Date: Wed, 5 Oct 2005 08:24:11 -0700 Organization: Hub.Org Networking Services Lines: 38 Message-ID: References: <9420.1128445291@sss.pgh.pa.us> X-Complaints-To: usenet@news.hub.org X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.2670 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670 To: pgsql-sql@postgresql.org X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=2.24 required=5 tests=[AWL=-0.024, FORGED_HOTMAIL_RCVD2=1.079, PRIORITY_NO_NAME=1.185] X-Spam-Level: ** X-Archive-Number: 200510/37 X-Sequence-Number: 22890 "Tom Lane" wrote in message news:9420.1128445291@sss.pgh.pa.us... > solarsail 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 Sounds like a classic opportunity to use the postgreSQL inheritance model to me.... > > ---------------------------(end of broadcast)--------------------------- > TIP 4: Have you searched our list archives? > > http://archives.postgresql.org >