| From: | Andreas <maps(dot)on(at)gmx(dot)net> |
|---|---|
| To: | pgsql-sql(at)postgresql(dot)org |
| Subject: | Notation of index |
| Date: | 2004-01-07 17:09:04 |
| Message-ID: | 3FFC3D30.2080508@gmx.net |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-sql |
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
...
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Michael Fuhr | 2004-01-07 17:31:47 | Re: unique constraints |
| Previous Message | Loeke | 2004-01-07 14:17:55 | Re: question : the choice of the primary key. |