tags:

views:

42

answers:

2

i have two mysql tables

tableA

col1   col2  SIM1 ..........col24
-----------------------------------
a       x     1             5 
b       y     1             3
c       z     0             2
d       g     2             1

tableB

colA   colB   SIM2
-------------------
x       g     1
y       f     0
x       s     0
y       e     2

i am using java to connect to mysql database using jdbc.

i need to index the two tables

   string query1 = " CREATE INDEX ON TableA (SIM1) ";
   string query2 = " CREATE INDEX ON TableB (SIM2) ";

when i use the excecuteUpdate(query1) and executeUpdate(query2) statements i get the following error

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ON TableA (SIM1)' at line 1

please suggest.

+4  A: 

Your syntax is garbled. See the MySQL reference.

You query must include the index name:

CREATE INDEX index_name ON TableA (SIM1)
Henning
+2  A: 

I think that you missed the index name: CREATE INDEX IndexName ON ...

For more details see the command reference: http://dev.mysql.com/doc/refman/5.0/en/create-index.html

Konamiman