日期:2014-05-16 浏览次数:21291 次
drop INDEX index_student_s_age on student ; drop INDEX index_student_s_no on student ; drop INDEX index_score_point on score ; drop INDEX index_score_c_id on score ;
CREATE INDEX index_student_s_age on student (s_age); CREATE INDEX index_student_s_no on student (s_no); CREATE INDEX index_score_point on score (point); CREATE INDEX index_score_c_id on score (c_id);
寮曠敤explain select a.*,b.* from student a , score b where a.s_no=b.c_id and a.s_no=11 1 SIMPLE b const PRIMARY PRIMARY 4 const 1 1 SIMPLE a ref index_student_s_no index_student_s_no 5 const 1 Using where
ALTER TABLE student CONVERT TO CHARACTER SET utf8; explain select a.*,b.* from student a , score b where a.s_no=b.c_id and a.s_no=14 1 SIMPLE b const PRIMARY PRIMARY 4 const 1 1 SIMPLE a ref index_student_s_no index_student_s_no 5 const 1 Using where
CREATE TABLE `student` (
`s_no` int(11) DEFAULT NULL,
`s_name` varchar(500) DEFAULT NULL,
`s_age` int(11) DEFAULT NULL,
`s_sex` varchar(10) DEFAULT NULL,
KEY `index_student_s_no` (`s_no`),
KEY `index_student_s_age` (`s_age`)
) ENGINE=InnoDB DEFAULT CHARSET=gbk;
CREATE TABLE `score` (
`c_id` int(11) NOT NULL,
`c_name` varchar(255) DEFAULT NULL,
`point` int(11) DEFAULT NULL,
KEY `index_course_point` (`point`),
KEY `index_course_c_id` (`point`),
KEY `index_score_point` (`point`),
KEY `index_score_c_id` (`c_id`)
) ENGINE=InnoDB DEFAULT CHARSET=gbk;
INSERT INTO `student` VALUES (1, '寮犳棤蹇?, 18, '鐢?);
INSERT INTO `student` VALUES (2, '鍛ㄨ姺鑻?, 19, '濂?);
INSERT INTO `student` VALUES (3, '鏉ㄨ繃', 19, '鐢?);
INSERT INTO `student` VALUES (4, '璧垫晱', 18, '濂?);
INSERT INTO `student` VALUES (5, '灏忛緳濂?, 17, '濂?);
INSERT INTO `student` VALUES (6, '寮犱笁涓?, 18, '鐢?);
INSERT INTO `student` VALUES (7, '浠ょ嫄鍐?, 19, '鐢?);
INSERT INTO `student` VALUES (8, '浠荤泩鐩?, 20, '濂?);
INSERT INTO `student` VALUES (9, '宀崇伒鐝?, 19, '濂?);
INSERT INTO `student` VALUES (10, '闊﹀皬瀹?, 18, '鐢?);
INSERT INTO `student` VALUES (11, '搴锋晱', 17, '濂?);
INSERT INTO `student` VALUES (12, '钀у嘲', 19, '鐢?);
INSERT INTO `student` VALUES (13, '榛勮搲', 18, '濂?);
INSERT INTO `student` VALUES (14, '閮潠', 19, '鐢?);
INSERT INTO `student` VALUES (15, '鍛ㄤ集閫?, 19, '鐢?);
INSERT INTO `student` VALUES (16, '鐟涘', 20, '濂?);
INSERT INTO `student` VALUES (17, '鏉庣姘?, 21, '濂?);
INSERT INTO `student` VALUES (18, '榛勮嵂甯?, 18, '鐢?);
INSERT INTO `student` VALUES (19, '鏉庤帿鎰?, 18, '濂?);
INSERT INTO `student` VALUES (20, '鍐粯椋?, 17, '鐢?);
INSERT INTO `student` VALUES (21, '鐜嬮噸闃?, 17, '鐢?);
INSERT INTO `student` VALUES (22, '閮', 18, '濂?);
INSERT INTO `score` VALUES (1, '浼佷笟绠$悊', 2);
INSERT INTO `score` VALUES (10, '绾挎€т唬鏁?, 17);
INSERT INTO `score` VALUES (11, '璁$畻鏈哄熀纭€', 13);
INSERT INTO `score` VALUES (12, 'AUTO CAD鍒跺浘', 15);
INSERT INTO `score` VALUES (13, '骞抽潰璁捐', 11);
INSERT INTO `score` VALUES (14, 'Flash鍔ㄦ极', 1);
INSERT INTO `score` VALUES (15, 'Java寮€鍙?, 9);
INSERT INTO `score` VALUES