pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andreas <maps.on@gmx.net>
To: pgsql-sql@postgresql.org
Subject: Notation of index
Date: Wed, 07 Jan 2004 18:09:04 +0100
Message-ID: <3FFC3D30.2080508@gmx.net> (raw)

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.
And as far as I understand I do have to give an plain INDEX explicitely 
a name while Pg makes one up for the UNIQUE.

The point is, that I want to use foreign keys and I figure it helped if 
those fk-columns were indexed but PG won't create indices for columns in 
fk-constraints automatically.
Am I right ?

Why can we use INDEX the same way as UNIQUE ?
Perhaps even as in
...
  numba   INT4    NOT NULL    INDEX
...






view thread (3+ messages)  latest in thread

Message-ID: <3FFC3D30.2080508@gmx.net>
Permalink:  ../3FFC3D30.2080508@gmx.net/
Also on:    postgresql.org/message-id/3FFC3D30.2080508@gmx.net

 · 

reply

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: maps.on@gmx.net
  Subject: Re: Notation of index
  In-Reply-To: <3FFC3D30.2080508@gmx.net>

* 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