Обсуждение: difference in INDEX's

Поиск
Список
Период
Сортировка

difference in INDEX's

От
Brian
Дата:
Is there a difference in doing:

foo        int PRIMARY KEY

and

CREATE INDEX idx1 on table (foo);


does both do the same thing (create an index)? is one faster or preffered
over the other?


/-------------------------- signal@shreve.net -----------------------------\
| Brian Feeny                | USR TC Hubs | ShreveNet Inc. (318)222-2638  |
| Network Administrator      | Perl, Linux | Web hosting, online stores,   |
| ShreveNet Inc.             |  USR Pilot  | Dial-Up 14.4-56k, ISDN & LANs |
| 89 CRX DX w/MPFI, lots of  |-=*:Quake:*=-| http://www.shreve.net/        |
| mods/Homepage coming soon  |LordSignal/SN| Quake server: 208.206.76.47   |
\-------------------------- 318-222-2638 x109 -----------------------------/



Re: [GENERAL] difference in INDEX's

От
Goran Thyni
Дата:
Brian wrote:
> Is there a difference in doing:
>
> foo             int PRIMARY KEY
>
> and
>
> CREATE INDEX idx1 on table (foo);

Yes,

create table bar (foo int PRIMARY KEY);

is the same as

create table bar (foo int NOT NULL); CREATE UNIQUE INDEX bar_pkey on
table bar(foo);

The first is easier to type,
the second is preferable (faster) if you will initially do a lot of
inserts, like:

create table...
loads of inserts...
create unique index...