Create a single-column index on c, and the second creates a multiple-column index that includes both c and i : Index « Table Index « SQL / MySQL






Create a single-column index on c, and the second creates a multiple-column index that includes both c and i

    
mysql>
mysql> CREATE TABLE mytbl
    -> (
    ->     i INT,
    ->     c CHAR(1)
    -> );
Query OK, 0 rows affected (0.01 sec)

mysql>
mysql> ALTER TABLE mytbl ADD INDEX (c);
Query OK, 0 rows affected (0.02 sec)
Records: 0  Duplicates: 0  Warnings: 0

mysql> ALTER TABLE mytbl ADD INDEX (c,i);
Query OK, 0 rows affected (0.01 sec)
Records: 0  Duplicates: 0  Warnings: 0

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

   
    
    
    
  








Related examples in the same category

1.Creating a Table with an Index
2.Create table: alter table to drop index
3.Create index on a column
4.Create table: Make index
5.Create index on table column with order
6.Create index on one column
7.Create index on two columns
8.Create unique index on table columns
9.Create index using btree
10.Handling Duplicate Index Values
11.Eliminating Duplicates by Adding an Index
12.How to include a unique index in the table definition.
13.How to include a regular index in a table definition:
14.Get the descriptive data of the indexes defined on the PENALTIES table.
15.Creating Indexes (CREATE INDEX)
16.Create an index on the AMOUNT column of the PENALTIES table.
17.Get the names of the indexes defined on the PENALTIES table.
18.Defining Indexes at Table-Creation Time
19.The syntax for CREATE INDEX is as follows
20.Removing Duplicates by Adding an Index
21.Removing Indexes
22.Create index of decimal type column
23.Create view for indexes
24.Drop an index by name
25.Add index to int type column
26.To create a unique-valued index, use the UNIQUE keyword instead of INDEX.
27.PRIMARY KEY INDEX_PRIM
28.Create an index and check it
29.Adding or Dropping Indexes
30.There are four types of statements for adding indexes to a table:
31.Hash index
32.Show index for a table
33.Using index in order by clause to indecate the result from subquery
34.Create a table with a nonunique index on the date-valued column Inauguration
35.To include multiple columns in an index
36.Provide index definitions in addition to the column definitions.
37.Modifying Indexes of Existing Tables
38.A table can have multiple indexes.