Thread: Creating a table

Creating a table

From
"Reuben Olson"
Date:
Hi there
 
I am converting a mySQL database to postgresql database and I was wondering if there was any auto increment function like there is in mysql or di I need to use a sequence or something...
 
thanks
 
Reubs

Re: Creating a table

From
Stephan Szabo
Date:
On Mon, 12 Nov 2001, Reuben Olson wrote:

> Hi there
>
> I am converting a mySQL database to postgresql database and I was
> wondering if there was any auto increment function like there is in
> mysql or di I need to use a sequence or something...

The easiest way is to use the serial type which is an int4 with an
associated sequence it takes its default value from.


Re: Creating a table

From
Bruce Momjian
Date:
> Hi there
>
> I am converting a mySQL database to postgresql database and I
> was wondering if there was any auto increment function like
> there is in mysql or di I need to use a sequence or something...

Sure, sequences.  If you define a column as type SERIAL you get a
sequence default on the column.

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026