Re: Tricky SQL problem - retrieve information_schema info and make use of it.

Поиск
Список
Период
Сортировка
От Steve Crawford
Тема Re: Tricky SQL problem - retrieve information_schema info and make use of it.
Дата
Msg-id CAEfWYywit2yAVni71yre_tbpJrtuFEOxUjw1-Pjni=p9yzGj=A@mail.gmail.com
обсуждение исходный текст
Ответ на Tricky SQL problem - retrieve information_schema info and make use of it.  (Paul Linehan <linehanp@tcd.ie>)
Ответы Re: Tricky SQL problem - retrieve information_schema info and make use of it.  (Paul Linehan <linehanp@tcd.ie>)
Список pgsql-novice
On Mon, Mar 21, 2016 at 3:48 PM, Paul Linehan <linehanp@tcd.ie> wrote:
Hi all,


I'll explain the problem and then I'll give you a schema you should
be able to cut and paste.

I  have a system which has different tables for each salesman (please
don't blame me for this snafu). **Same** table structure for each
person.

I want to be able to query results for each salesman - but new sales
personnel are being added and deleted all the time, so a static list
is not appropriate.

OK, we won't blame you. But since the tables are identical, have you considered inheritance?

Create table allsalespersons... to have a master table with the same structure as the individual salesperson.

For existing tables, convert them to child tables:
alter table fred inherit allsalespersons;
...

For new tables just create them as inherited to begin with.

Now you can select from "allsalespersons" and get everyone.

Cheers,
Steve

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

Предыдущее
От: Skylar Thompson
Дата:
Сообщение: Re: Tricky SQL problem - retrieve information_schema info and make use of it.
Следующее
От: Paul Linehan
Дата:
Сообщение: Re: Tricky SQL problem - retrieve information_schema info and make use of it.