非常基本的问题 - 如何为MySQL表的列添加索引?
CREATE TABLE housekeeper_stats
(company_site_id int,
company_id int,
event_count int,
host varchar(100),
source varchar(100),
source_type varchar(100));
mysql> alter table housekeeper_stats add index (company_id);
ERROR 1072 (42000): Key column 'company_id' doesn't exist in table
mysql> create index company_idx_n1 on housekeeper_stats(company_id, company_site_id) using btree;
ERROR 1072 (42000): Key column 'company_id' doesn't exist in table
The documentation states:
ADD {INDEX|KEY} [index_name]
[index_type] (index_col_name,...) [index_option]
不知道我哪里错了?
感谢。