pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedhow to set the value to the column
3+ messages / 2 participants
[nested] [flat]
* how to set the value to the column
@ 2009-04-16 19:00 DM <dm.aeqa@gmail.com>
2009-04-16 19:11 ` Re: how to set the value to the column DM <dm.aeqa@gmail.com>
2009-04-16 19:11 ` Re: how to set the value to the column Andreas Kretschmer <akretschmer@spamfence.net>
0 siblings, 2 replies; 3+ messages in thread
From: DM @ 2009-04-16 19:00 UTC (permalink / raw)
To: pgsql-sql
Hi All,
I have a table test with columns name and value
test table
name
value
It has around 500 rows.
I added a new column id to the table,
Table test
id,
name,
value
I am not sure how to insert numbers to my column id (1-500).
Thanks
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: how to set the value to the column
2009-04-16 19:00 how to set the value to the column DM <dm.aeqa@gmail.com>
@ 2009-04-16 19:11 ` DM <dm.aeqa@gmail.com>
1 sibling, 0 replies; 3+ messages in thread
From: DM @ 2009-04-16 19:11 UTC (permalink / raw)
To: pgsql-sql
never mind i got the answer.
Thanks for looking into it.
- deepak
On Thu, Apr 16, 2009 at 12:00 PM, DM <dm.aeqa@gmail.com> wrote:
> Hi All,
>
> I have a table test with columns name and value
>
> test table
> name
> value
>
> It has around 500 rows.
>
> I added a new column id to the table,
>
> Table test
> id,
> name,
> value
>
> I am not sure how to insert numbers to my column id (1-500).
>
> Thanks
>
>
>
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: how to set the value to the column
2009-04-16 19:00 how to set the value to the column DM <dm.aeqa@gmail.com>
@ 2009-04-16 19:11 ` Andreas Kretschmer <akretschmer@spamfence.net>
1 sibling, 0 replies; 3+ messages in thread
From: Andreas Kretschmer @ 2009-04-16 19:11 UTC (permalink / raw)
To: pgsql-sql
DM <dm.aeqa@gmail.com> wrote:
> Hi All,
>
> I have a table test with columns name and value
>
> test table
> name
> value
>
> It has around 500 rows.
>
> I added a new column id to the table,
>
> Table test
> id,
> name,
> value
>
> I am not sure how to insert numbers to my column id (1-500).
You can create a SEQUENCE and use this Sequence for that, an example:
test=# create table foo (name text);
CREATE TABLE
Zeit: 2,824 ms
test=*# copy foo from stdin;
Geben Sie die zu kopierenden Daten ein, gefolgt von einem Zeilenende.
Beenden Sie mit einem Backslash und einem Punkt alleine auf einer Zeile.
>> a
>> b
>> c
>> d
>> e
>> \.
Zeit: 5592,132 ms
test=*# create sequence foo_seq;
CREATE SEQUENCE
Zeit: 10,030 ms
test=*# alter table foo add column id int;
ALTER TABLE
Zeit: 0,347 ms
test=*# update foo set id = nextval('foo_seq');
UPDATE 5
Zeit: 0,379 ms
test=*# select * from foo;
name | id
------+----
a | 1
b | 2
c | 3
d | 4
e | 5
(5 Zeilen)
Zeit: 0,241 ms
test=*#
Andreas
--
Really, I'm not out to destroy Microsoft. That will just be a completely
unintentional side effect. (Linus Torvalds)
"If I was god, I would recompile penguin with --enable-fly." (unknown)
Kaufbach, Saxony, Germany, Europe. N 51.05082°, E 13.56889°
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2009-04-16 19:11 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2009-04-16 19:00 how to set the value to the column DM <dm.aeqa@gmail.com>
2009-04-16 19:11 ` DM <dm.aeqa@gmail.com>
2009-04-16 19:11 ` Andreas Kretschmer <akretschmer@spamfence.net>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox