Search Postgresql Archives

Re: how to show serial number of record

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

 



am  Thu, dem 18.01.2007, um 15:34:33 +0530 mailte deepak pal folgendes:
> hi i want to add a coloum called serial numer in my record set how could i do
> it..that column is not in table.

Do you mean something like this:?

test=# create table foo (t text);
CREATE TABLE
test=*# insert into foo values ('foo');
INSERT 0 1
test=*# insert into foo values ('bar');
INSERT 0 1
test=*# insert into foo values ('batz');
INSERT 0 1
test=*# select * from foo;
  t
------
 foo
 bar
 batz
(3 rows)

test=*# create sequence foo_seq;
CREATE SEQUENCE
test=*# select nextval('foo_seq'), * from foo;
 nextval |  t
---------+------
       1 | foo
       2 | bar
       3 | batz
(3 rows)


Of course, you can rename the first column using the 'as' - syntax.



Andreas
-- 
Andreas Kretschmer
Kontakt:  Heynitz: 035242/47150,   D1: 0160/7141639 (mehr: -> Header)
GnuPG-ID:   0x3FFF606C, privat 0x7F4584DA   http://wwwkeys.de.pgp.net


[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