Re: put text list into table form

Поиск
Список
Период
Сортировка
От Bruno Wolff III
Тема Re: put text list into table form
Дата
Msg-id 20060204220007.GA15063@wolff.to
обсуждение исходный текст
Ответ на Re: put text list into table form  ("Web2cad" <alex@web2cad.co.jp>)
Список pgsql-novice
On Tue, Jan 31, 2006 at 09:24:30 +0900,
  Web2cad <alex@web2cad.co.jp> wrote:
>
> Since the user table may/may not have all the cities in the file. I can't
> just do a group by on the user table.
> This is the query that I am generating to get the above effect.
>
> SELECT count(uid) FROM (SELECT 'city1' AS city UNION SELECT 'city2'  AS city
> UNOIN........) AS c
> LEFT JOIN "user" ON (c.city="user".city) GROUP BY c.city;

That looks like a nice way to do things.

> So I am asking is there a way in postgres that will let me create a
> temporary table from a delimited flat file/string??
> Something that will have the same effect as the
> (SELECT........UNION........) query above??

If you wanted you could create a temporary table and load it using \copy
in psql. Unless the list of cities is really large, it probably won't buy you
much over what you are already doing.

Is there some reason you can't load the file in to the database and then make
that the definitive city list?

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

Предыдущее
От: Andreas Kretschmer
Дата:
Сообщение: Re: Backing Up
Следующее
От: Bruno Wolff III
Дата:
Сообщение: Re: maximum for database users?