From: Richard Huxton <dev@archonet.com>
To: Andreas <maps.on@gmx.net>
To: pgsql-sql@postgresql.org
Subject: Re: Notation of index
Date: Wed, 7 Jan 2004 18:25:46 +0000
Message-ID: <200401071825.46187.dev@archonet.com> (raw)
In-Reply-To: <3FFC3D30.2080508@gmx.net>
References: <3FFC3D30.2080508@gmx.net>
On Wednesday 07 January 2004 17:09, Andreas wrote:
> Hi,
>
> I'm moving from MySQL to Pg.
> MySQL lets me create indices like this:
>
> CREATE TABLE t (
> id INTEGER NOT NULL,
> numba INTEGER NOT NULL,
> txt VARCHAR(100) NOT NULL,
> anosanumba INTEGER NOT NULL ,
>
> PRIMARY KEY (id),
> INDEX (numba),
> UNIQUE (anosanumba)
> );
>
> PostgreSQL doesn't like the line :
> INDEX (numba),
>
> Instead I have to use :
> CREATE INDEX idx_t_numba ON t (numba);
> outside the CREATE TABLE statement.
AFAIK there are two strands to this:
1. The INDEX keyword inside a CREATE TABLE statement is non-standard
2. PRIMARY KEY/UNIQUE are not indexes - they just happen to create one.
In theory, you can enforce uniqueness without the use of an index. In practice
of course, with any reasonable number of rows you will want one.
--
Richard Huxton
Archonet Ltd
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: dev@archonet.com, maps.on@gmx.net
Subject: Re: Notation of index
In-Reply-To: <200401071825.46187.dev@archonet.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox