auto increment primary key

Поиск
Список
Период
Сортировка
Искать

auto increment primary key

От:
impala <bhnnc@yahoo.co.uk>
Дата:
I created a table, want the integer/varchar primary
key column to be incremented automatically when
inserted a new row. How do I define the table to do
that? I tried AUTO_INCREMENT and INCREMENT but
postgres accept none of them.

Thanks
NJ

__________________________________________________
Do You Yahoo!?
Yahoo! Tax Center - online filing with TurboTax
http://taxes.yahoo.com/

Re: auto increment primary key

От:
Frank Joerdens <frank@joerdens.de>
Дата:
On Fri, Apr 05, 2002 at 02:21:19AM -0800, impala wrote:
> I created a table, want the integer/varchar primary
> key column to be incremented automatically when
> inserted a new row. How do I define the table to do
> that? I tried AUTO_INCREMENT and INCREMENT but
> postgres accept none of them.

create table foo (
bar	serial primary key,
 . . .

This implies the creation of a special table called a sequence which
does the auto-incrementing.

Regards, Frank

Re: auto increment primary key

От:
"Marin Dimitrov" <marin.dimitrov@sirma.bg>
Дата:
----- Original Message ----- 
From: "impala" 

> I created a table, want the integer/varchar primary
> key column to be incremented automatically when
> inserted a new row. How do I define the table to do
> that? I tried AUTO_INCREMENT and INCREMENT but
> postgres accept none of them.
> 

search docs for "sequence" and "serial"

how do u increment a varchar?


    Marin

----
"...what you brought from your past, is of no use in your present. When 
you must choose a new path, do not bring old experiences with you. 
Those who strike out afresh, but who attempt to retain a little of the 
old life, end up torn apart by their own memories. "




FAQ