Re: how does setval() work???

Поиск
Список
Период
Сортировка
Искать
От
Oliver Elphick
Тема
Re: how does setval() work???
Дата
Msg-id
200101101632.f0AGW7N21365@linda.lfix.co.uk
Список
Дерево обсуждения
how does setval() work??? chris Günther <guenther@uscreen.de>
chris Gnther wrote:
  >database with the default values in the table I need to set my sequence
  >by hand using setval() I think. But I just can't figure out how this works.
  >
  >Can anyone give me an example???


bray=# create table junk (id serial, name text);
NOTICE:  CREATE TABLE will create implicit sequence 'junk_id_seq' for SERIAL 
column 'junk.id'
NOTICE:  CREATE TABLE/UNIQUE will create implicit index 'junk_id_key' for 
table 'junk'


bray=# insert into junk (name) values ('Fred');
INSERT 194510 1
bray=# select * from junk;
 id | name 
----+------
  1 | Fred
(1 row)


bray=# select setval('junk_id_seq',5);
 setval 
--------
      5
(1 row)

bray=# insert into junk (name) values ('Joe');
INSERT 194511 1
bray=# select * from junk;
 id | name 
----+------
  1 | Fred
  6 | Joe
(2 rows)

-- 
Oliver Elphick                                Oliver.Elphick@lfix.co.uk
Isle of Wight                              http://www.lfix.co.uk/oliver
PGP: 1024R/32B8FAA1: 97 EA 1D 47 72 3F 28 47  6B 7E 39 CC 56 E4 C1 47
GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839  932A 614D 4C34 3E1D 0C1C
                 ========================================
     "Be patient therefore, brethren, unto the coming of the
      Lord...Be patient; strengthen your hearts, for 
      the coming of the Lord draweth nigh."           
                                   James 5:7,8 


В списке pgsql-novice по дате отправления
От: chris Günther
Дата:
Сообщение: how does setval() work???
От: Rik Bradt
Дата:
Сообщение: RE: Dumping Large Object
FAQ