Re: Need help with upsert

Поиск
Список
Период
Сортировка
От Vincent Veyron
Тема Re: Need help with upsert
Дата
Msg-id 1386192580.2550.14.camel@asus-1001PX.home
обсуждение исходный текст
Ответ на Need help with upsert  (Eric Lamer <eric@phoenixsecure.com>)
Список pgsql-general
Le mercredi 04 décembre 2013 à 17:48 +0000, Eric Lamer a écrit :

>
>
>   Each day I want to copy the last 7 days into one table so I have one
> table with the last 7 days of logs.
>
>
>
>   So I want to copy the data from 7 tables into 1.  If the row does
> not exist I just insert and if the row already exist I just update the
> sum (existing sum + new sum).
>

Unless you have a specific reason not to, ISTM you could make your life
_much_ easier with just one table and a date column?


>
>
>   Public.test is the table I use for the last 7 days logs.
>
>   daily.daily_20131202 is table for 1 day.
>
>   I will run this command 7 times with different daily table.
>

> Also, is there an easier way to do that?
>

I would just insert all rows into one big table with a date field, and
then make a select count() with the appropriate where clause on the date
field and group by clause.


--
                                        Salutations, Vincent Veyron

Legal cases, contracts and insurance claims management
http://libremen.com




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

Предыдущее
От: Scott Marlowe
Дата:
Сообщение: Re: how much disk space does a VACUUM FULL take?
Следующее
От: Merlin Moncure
Дата:
Сообщение: Re: Postgres 9.3 read block error went into recovery mode