Re: [despammed] Serial data type
От | Andreas Kretschmer |
---|---|
Тема | Re: [despammed] Serial data type |
Дата | |
Msg-id | 20050413155001.GB20909@webserv.wug-glas.de обсуждение исходный текст |
Ответ на | Serial data type ("Walker, Jed S" <Jed_Walker@cable.comcast.com>) |
Список | pgsql-novice |
am 13.04.2005, um 9:30:09 -0600 mailte Walker, Jed S folgendes: > I have several tables that require auto-generated Ids. I have noticed the > serial and bigserial data types (or pseudo-types). These seem like they make > things much simpler, but if you use this, how can you find out the the value > of the serial column after you insert a row? Do you have to lookup the Please read the manual about currval(). > primary key or is it stored in a session variable or some other place? Is In a squence, a extra database object. > it better to define the sequence manually and just select it out by hand > before doing the insert? No. Why? test_db=# create table seq_test (id serial, name varchar); HINWEIS: CREATE TABLE erstellt implizit eine Sequenz >>seq_test_id_seq<< f?r die >>serial<<-Spalte >>seq_test.id<< CREATE TABLE test_db=# insert into seq_test (name) values ('Andreas'); INSERT 373930 1 test_db=# insert into seq_test (name) values ('Anja'); INSERT 373931 1 test_db=# select * from seq_test; id | name ----+--------- 1 | Andreas 2 | Anja (2 Zeilen) test_db=# Andreas -- Andreas Kretschmer (Kontakt: siehe Header) Heynitz: 035242/47212, D1: 0160/7141639 GnuPG-ID 0x3FFF606C http://wwwkeys.de.pgp.net === Schollglas Unternehmensgruppe ===
В списке pgsql-novice по дате отправления: