using pg_tables and tablename in queries

Поиск
Список
Период
Сортировка
От solarsail
Тема using pg_tables and tablename in queries
Дата
Msg-id aa44f4a30510040930m510bbe8do4babd97b1b37c90d@mail.gmail.com
обсуждение исходный текст
Ответы Re: using pg_tables and tablename in queries
Список pgsql-sql
I have a large number of tables with a common naming convention<br /><br />       mytable001, mytable002, mytable003
...mytable00n<br /><br /> I would like to do a query across all of the tables, however I do not know all of the tables
beforehand, and I do not want to ( cant ) manually generate a query like<br /><br />      select * from mytable001,
mytable002,mytable003<br /><br /><br /> I have a query that returns the names of the tables I want to query:<br /><br
/>   select tablename from pg_tables where tablename like 'mytable%'<br /><br /><br /> I have successfully done this
querybefore.  I remember it used a odd syntax; I it was something like <br /><br />     select * from ( select
tablenamefrom pg_tables where tablename like 'mytable%' )<br /><br /><br /> However the above query returns just a
listingof tables, I need to use its output in the FROM and treat the input as a table name.<br /><br /> ( I've tried
creatinga Table Function that returns the above set and tried to use that in a select clause, but I cant get it to
work.)<br /><br /> 

В списке pgsql-sql по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: combination of function to simple query makes query slow
Следующее
От: Tom Lane
Дата:
Сообщение: Re: using pg_tables and tablename in queries