Creating an Index with the ALTER TABLE Statement : Index « Table « MySQL Tutorial






mysql>
mysql> CREATE TABLE myTable
    -> (
    ->    ID SMALLINT UNSIGNED NOT NULL PRIMARY KEY,
    ->    Name VARCHAR(40) NOT NULL
    -> );
Query OK, 0 rows affected (0.03 sec)

mysql>
mysql> alter table myTable add index(name);
Query OK, 0 rows affected (0.05 sec)
Records: 0  Duplicates: 0  Warnings: 0

mysql>
mysql> drop table myTable;
Query OK, 0 rows affected (0.00 sec)








4.19.Index
4.19.1.Using Indexes
4.19.2.Creating an Index
4.19.3.Creating an Index with the ALTER TABLE Statement
4.19.4.CREATE INDEX index_name ON table_name (column_name[,...]);
4.19.5.Using the ALTER TABLE statement to add an index
4.19.6.Deleting Indexes
4.19.7.ALTER TABLE table_name ADD (KEY|INDEX) index_name (column_name[,...]);
4.19.8.ALTER TABLE Employee ADD (KEY) myIndex (id);
4.19.9.Alter table to add an index on two columns
4.19.10.SHOW INDEX FROM Employee;
4.19.11.CREATE UNIQUE INDEX [index_name] ON table_name (column_name[,...]);
4.19.12.ALTER TABLE Employee DROP INDEX lastn_idx;