Re: [GENERAL] all serial type was changed to 1

Поиск
Список
Период
Сортировка
От Adrian Klaver
Тема Re: [GENERAL] all serial type was changed to 1
Дата
Msg-id e0d64363-8b2e-094f-552e-cf0a5f80e52b@aklaver.com
обсуждение исходный текст
Ответ на Re: [GENERAL] all serial type was changed to 1  (Max Wang <mwang@1080agile.com>)
Ответы Re: [GENERAL] all serial type was changed to 1  (Melvin Davidson <melvin6925@gmail.com>)
Список pgsql-general
On 05/01/2017 04:36 PM, Max Wang wrote:
> Hi Amitabh,
>
> I mean the serial sequence that controls the id value has been set to 1 for all tables. That's why I got the
duplicatekey value error when I tried to insert the new record to table. 

So what does the sequence query show?

As an example in psql:

test=# create table serial_test(id serial PRIMARY KEY, fld_1 varchar);
CREATE TABLE

test=# \d serial_test
                               Table "public.serial_test"
  Column |       Type        |                        Modifiers

--------+-------------------+----------------------------------------------------------
  id     | integer           | not null default
nextval('serial_test_id_seq'::regclass)
  fld_1  | character varying |
Indexes:
     "serial_test_pkey" PRIMARY KEY, btree (id)

The above shows that the sequence associated with the serial type is:
'serial_test_id_seq'

The below shows how to select from that sequence:

test=# select * from serial_test_id_seq ;
-[ RECORD 1 ]-+--------------------
sequence_name | serial_test_id_seq
last_value    | 1
start_value   | 1
increment_by  | 1
max_value     | 9223372036854775807
min_value     | 1
cache_value   | 1
log_cnt       | 0
is_cycled     | f
is_called     | f


Can you do that on the serial column from one the affected tables and
post the results here?


>
> Thanks.
>
> Regards,
> Max
>
> -----Original Message-----
> From: Adrian Klaver [mailto:adrian.klaver@aklaver.com]
> Sent: Tuesday, 2 May 2017 9:31 AM
> To: Max Wang <mwang@1080agile.com>; Amitabh Kant <amitabhkant@gmail.com>
> Cc: pgsql-general@postgresql.org
> Subject: Re: [GENERAL] all serial type was changed to 1
>
> On 05/01/2017 04:11 PM, Max Wang wrote:
>> Hi Amitabh,
>>
>>
>>
>> Thank you for suggestion. We did not reach the limit of serial type.
>> Some tables only have hundreds of rows.
>
> It would helpful if you ran the query I showed in my previous post on one the sequences just so we can see.
>
>  From subsequent post of yours:
>
> "Sorry. I mean all tables’ id column were reset to 1."
>
> I thought I understood on this, now I am not sure. Do you mean that the actual values in the id column in all the
tableshave been set to 1 or that the serial sequence that controls the id value has been set to 1? 
>
>>
>>
>>
>> Regards,
>>
>> Max
>>
>>
>
>
>


--
Adrian Klaver
adrian.klaver@aklaver.com


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

Предыдущее
От: Melvin Davidson
Дата:
Сообщение: Re: [GENERAL] all serial type was changed to 1
Следующее
От: Melvin Davidson
Дата:
Сообщение: Re: [GENERAL] all serial type was changed to 1