Unix Technical Forum

insert a sequence

This is a discussion on insert a sequence within the pgsql Sql forums, part of the PostgreSQL category; --> Dear postgres Users, I have a simple question I think. I have a table that contains some columns one ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Sql

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-19-2008, 03:24 PM
ivan marchesini
 
Posts: n/a
Default insert a sequence

Dear postgres Users,
I have a simple question I think.
I have a table that contains some columns
one of these columns (the columns ID) contains distinct integer
values ...
I need to insert into this table some other records but I only need that
values were inserted into the ID column and that they were
progressive... (a sequence starting from 100 and ending to 300, step=1)
the other columns must remains null....
can I do this with a sequence and then an "insert into"?

many thanks




--
Ti prego di cercare di non inviarmi files .doc, .xls, .ppt, .dwg.
Preferisco formati liberi.
Please try to avoid to send me .doc, .xls, .ppt, .dwg files.
I prefer free formats.
http://it.wikipedia.org/wiki/Formato_aperto
http://en.wikipedia.org/wiki/Open_format

Ivan Marchesini
Department of Civil and Environmental Engineering
University of Perugia
Via G. Duranti 93/a
06125
Perugia (Italy)
e-mail: marchesini@unipg.it
ivan.marchesini@gmail.com
tel: +39(0)755853760
fax (university): +39(0)755853756
fax (home): +39(0)5782830887
jabber: geoivan73@jabber.org


---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

http://archives.postgresql.org

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-19-2008, 03:24 PM
Ireneusz Pluta
 
Posts: n/a
Default Re: insert a sequence

ivan marchesini napisał(a):
> Dear postgres Users,
> I have a simple question I think.
> I have a table that contains some columns
> one of these columns (the columns ID) contains distinct integer
> values ...
> I need to insert into this table some other records but I only need that
> values were inserted into the ID column and that they were
> progressive... (a sequence starting from 100 and ending to 300, step=1)
> the other columns must remains null....
> can I do this with a sequence and then an "insert into"?
>
> many thanks
>
>
>
>
>

INSERT INTO your_table (id) SELECT generate_series(100, 300, 1);

-> http://www.postgresql.org/docs/8.2/i...tions-srf.html


---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 09:35 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com