MySQL Char & Index
1. Types of char
Type | Size | Range | Extra Space | Query Speed |
---|---|---|---|---|
CHAR | Fixed | 1~255 | 0 | fast |
VARCHAR | Dynamic | 1~65535 | 1~2 bytes | slow |
TEXT | Dynamic | 1~65535 | 2 bytes | slowest |
2. Index
Create index for database can speed up query.
2.1 How to create index
create index idx_name
on employee(name);
-- or
alter table employee
add index idx_name(name);
-- unique index
create unique index idx_name
on employee(name);
2.2 How to check index
show index from employee;
2.3 How to drop index
drop index idx_name
on employee;