Index
Index is used to increase the performance of the query.
- primary key
- Unique key
- non unique key
CREATE TABLE statement defines a unique index on the OrderID and ModelID columns:
CREATE TABLE Orders
(
OrderID SMALLINT UNSIGNED NOT NULL,
ModelID SMALLINT UNSIGNED NOT NULL,
ModelDescrip VARCHAR(40),
PRIMARY KEY (OrderID),
UNIQUE (OrderID, ModelID)
);
Add a full-text index to a MyISAM table. As you recall, you can add this type of index only to the CHAR, VARCHAR, or TEXT columns.
CREATE TABLE Orders(
OrderID SMALLINT UNSIGNED NOT NULL,
ModelID SMALLINT UNSIGNED NOT NULL,
ModelName VARCHAR(40),
PRIMARY KEY (OrderID),
FULLTEXT (ModelName)
);
Query to delete index
ALTER TABLE OrdersDROP INDEX unique_1;
No comments:
Post a Comment