Search Postgresql Archives

Re: serial

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Dec 4, 2008 at 2:42 PM, Gustavo Rosso <grosso@xxxxxxxxxxxxx> wrote:
> I created this table:
>
> create table se (n  serial);
>
in case you did just insert into se(n) values(0); twice, it won't work
if you want to add series of numbers, don't define it as serial.
Serial is for a different purpose.
if you want a series of generated numbers, please use generate_series();

so :

create table se(n int not null);
insert into se(n) select generate_series(1,100);

serial is used for different purposes. Say, you need an auto
incremented id on a row:
create table foo(
  id serial,
  name varchar(128)
);

and than:

insert into foo(name) values('Gustavo'), ('Grzegorz') returning id;

;]



hth

-- 
GJ

-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux