3.3.4.1 Selecting All Data选择所有数据

The simplest form of SELECT retrieves everything from a table:SELECT的最简单形式是从表中检索所有内容:

mysql> SELECT * FROM pet;
+----------+--------+---------+------+------------+------------+
| name     | owner  | species | sex  | birth      | death      |
+----------+--------+---------+------+------------+------------+
| Fluffy   | Harold | cat     | f    | 1993-02-04 | NULL       |
| Claws    | Gwen   | cat     | m    | 1994-03-17 | NULL       |
| Buffy    | Harold | dog     | f    | 1989-05-13 | NULL       |
| Fang     | Benny  | dog     | m    | 1990-08-27 | NULL       |
| Bowser   | Diane  | dog     | m    | 1979-08-31 | 1995-07-29 |
| Chirpy   | Gwen   | bird    | f    | 1998-09-11 | NULL       |
| Whistler | Gwen   | bird    | NULL | 1997-12-09 | NULL       |
| Slim     | Benny  | snake   | m    | 1996-04-29 | NULL       |
| Puffball | Diane  | hamster | f    | 1999-03-30 | NULL       |
+----------+--------+---------+------+------------+------------+

This form of SELECT uses *, which is shorthand for select all columns. 这种形式的SELECT使用*,它是“选择所有列”的简写。This is useful if you want to review your entire table, for example, after you've just loaded it with your initial data set. 如果您想查看整个表,例如,在您刚刚用初始数据集加载它之后,这非常有用。For example, you may happen to think that the birth date for Bowser doesn't seem quite right. 例如,您可能会认为Bowser的出生日期似乎不太正确。Consulting your original pedigree papers, you find that the correct birth year should be 1989, not 1979.查阅你的原始家谱,你会发现正确的出生年份应该是1989年,而不是1979年。

There are at least two ways to fix this:至少有两种方法可以解决此问题:

There is an exception to the principle that SELECT * selects all columns. SELECT *选择所有列的原则有一个例外。If a table contains invisible columns, * does not include them. 如果表包含不可见列,*不包含这些列。For more information, see Section 13.1.20.10, “Invisible Columns”.有关更多信息,请参阅第13.1.20.10节,“不可见列”