dbTalk Databases Forums  

Short notation for creating indices ?

comp.databases.postgresql.novice comp.databases.postgresql.novice


Discuss Short notation for creating indices ? in the comp.databases.postgresql.novice forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Andreas
 
Posts: n/a

Default Short notation for creating indices ? - 01-07-2004 , 11:11 AM






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
....




---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.