X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (neptune.hub.org [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 15BF6D1B453 for ; Wed, 7 Jan 2004 18:39:18 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 66621-10 for ; Wed, 7 Jan 2004 14:38:35 -0400 (AST) Received: from anchor-post-34.mail.demon.net (anchor-post-34.mail.demon.net [194.217.242.92]) by svr1.postgresql.org (Postfix) with ESMTP id 42933D1D579 for ; Wed, 7 Jan 2004 14:25:45 -0400 (AST) Received: from mwynhau.demon.co.uk ([193.237.186.96] helo=mainbox.archonet.com) by anchor-post-34.mail.demon.net with esmtp (Exim 3.35 #1) id 1AeINK-000GWk-0Y; Wed, 07 Jan 2004 18:25:50 +0000 Received: by mainbox.archonet.com (Postfix, from userid 529) id A060817F4B; Wed, 7 Jan 2004 18:25:48 +0000 (GMT) Received: from client17.archonet.com (client17.archonet.com [192.168.1.17]) by mainbox.archonet.com (Postfix) with ESMTP id C4871165B4; Wed, 7 Jan 2004 18:25:46 +0000 (GMT) From: Richard Huxton To: Andreas , pgsql-sql@postgresql.org Subject: Re: Notation of index Date: Wed, 7 Jan 2004 18:25:46 +0000 User-Agent: KMail/1.5 References: <3FFC3D30.2080508@gmx.net> In-Reply-To: <3FFC3D30.2080508@gmx.net> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200401071825.46187.dev@archonet.com> X-Bogosity: No, tests=bogofilter, spamicity=0.000000, version=0.15.3 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200401/41 X-Sequence-Number: 16434 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