mysql> insert into teacher -> values (202, 'robot', 'ZhuHai', '2013-04-24'); Query OK, 1 row affected (0.00 sec) mysql> insert into teacher -> values (203, 'Jack', 'ZhuHai', '2013-04-24'); Query OK, 1 row affected (0.00 sec) mysql> insert into teacher -> values (204, 'Ann', 'ZhuHai', '2013-04-24'); Query OK, 1 row affected (0.01 sec) mysql> insert into teacher -> values (205, 'Rose', 'ZhuHai', '2013-04-24'); Query OK, 1 row affected (0.01 sec)
(1)统计有多少条记录
mysql> select count(*) from teacher; +----------+ | count(*) | +----------+ | 4 | +----------+ row in set (0.01 sec) mysql> select * from teacher; +-----+-------+---------+------------+ | Id | name | address | year | +-----+-------+---------+------------+ | 202 | robot | ZhuHai | 2013-04-24 | | 203 | Jack | ZhuHai | 2013-04-24 | | 204 | Ann | ZhuHai | 2013-04-24 | | 205 | Rose | ZhuHai | 2013-04-24 | +-----+-------+---------+------------+ rows in set (0.00 sec)
(2)投影操作,选择需要查看的信息
mysql> select Id, year from teacher; +-----+------------+ | Id | year | +-----+------------+ | 202 | 2013-04-24 | | 203 | 2013-04-24 | | 204 | 2013-04-24 | | 205 | 2013-04-24 | +-----+------------+ rows in set (0.00 sec) mysql> select Id, name from teacher; +-----+-------+ | Id | name | +-----+-------+ | 202 | robot | | 203 | Jack | | 204 | Ann | | 205 | Rose | +-----+-------+ rows in set (0.00 sec)
(3)预览功能,显示字段中一部分的信息
mysql> select Id, left(address, 3) from teacher; +-----+------------------+ | Id | left(address, 3) | +-----+------------------+ | 202 | Zhu | | 203 | Zhu | | 204 | Zhu | | 205 | Zhu | +-----+------------------+ rows in set (0.00 sec) mysql>