Re: MySQL comparable syntax for PostgreSQL

From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: Ben Clewett <B(dot)Clewett(at)roadrunner(dot)uk(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: MySQL comparable syntax for PostgreSQL
Date: 2003-02-17 17:48:38
Message-ID: 20030217174838.GA22287@wolff.to
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

On Mon, Feb 17, 2003 at 14:47:01 +0000,
Ben Clewett <B(dot)Clewett(at)roadrunner(dot)uk(dot)com> wrote:
>
> An UNSIGNED number. Is this 'field INTEGER CHECK (field >= 0)', or is
> there a direct UNSIGNED reference I have missed?

There is no unsigned type. You can use a check constraint to enforce this.

> The AUTO_INREMENT extension to a Primary Key, as used in MuSQL. What is
> the official method for auto-incrementing fields? I have found the
> 'DEFAULT NEXTVAL('...'), but I am not sure whether/how/if this can be
> used to auto-increment a primary field?

Yes, you want to use sequences as they are a lightweight way to generate
unique keys. The Serial types provide a simple way to do this. They
create a sequence, set the default to use nextval and add a not null
constraint. They don't create a unique index, but a primary key constraint
will do that.

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Dirk Hamstra 2003-02-17 18:14:15 Dynamic IP - pg_hba
Previous Message Josh Trutwin 2003-02-17 16:50:24 Re: How to remove old pg RPMs?