mysql> DESC student_extra ;
+-------+-----------+--------+-------+--------------+---------+
| Field | Type | Null | Key | Default | Extra |
+-------+-----------+--------+-------+--------------+---------+
| id | int(11) | NO | PRI | NULL | |
| extra | text | YES | | NULL | |
+-------+-----------+--------+-------+--------------+---------+
2 rows in set (0.00 sec)
如果需要查询某个学生的备注信息,可以用学号(id)来查询。如果需要将学生的学籍信息与备注信息同时显示时,可以将student表和student_extra表进行联表查询,查询语句如下:
SELECT * FROM student, student_extra WHERE
student.id=student_extra.id ;
通过这种分解,可以提高student表的查询效率。因此,遇到这种字段很多,而且有些字段使用不频繁的,可以通过这种分解的方式来优化数据库的性能。