Having trouble with Create Index

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm trying to add a primary key (Unique Index) on a table via a SQL query,
but it's not working the way I expected. My SQL is:

Create Unique Index Unid
On mytable (Id);

I expected Access to add the new column "Id", but the query fails. After I
manually add the new column in the Design view the query runs, but the table
is not changed. I expected unique row numbers to be generated. Finally,
what is the function of index_name? I don't see that it adds anything, but
without it the query fails.

Thanks, Glenn
 
Adding Fields (ALTER TABLE SQL) and creating Index (CREATE INDEX SQL) are 2
different actions.

It sound to me that you want to create a COUNTER / AUTOINCREMENT Field
(which is displayed as AutoNumber Field in the Table Design view).

Check the JET SQL Reference section of Access for the capitalised words /
phrases above.
 
Thank you, that worked.

Van T. Dinh said:
Adding Fields (ALTER TABLE SQL) and creating Index (CREATE INDEX SQL) are 2
different actions.

It sound to me that you want to create a COUNTER / AUTOINCREMENT Field
(which is displayed as AutoNumber Field in the Table Design view).

Check the JET SQL Reference section of Access for the capitalised words /
phrases above.
 
Back
Top