Creating a table

Started by Reuben Olsonover 24 years ago3 messagesgeneral
Jump to latest
#1Reuben Olson
reuben.olson@clear.net.nz

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

#2Stephan Szabo
sszabo@megazone23.bigpanda.com
In reply to: Reuben Olson (#1)
Re: Creating a table

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.

#3Bruce Momjian
bruce@momjian.us
In reply to: Reuben Olson (#1)
Re: Creating a table

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