SHOW
输入:
SHOW COLUMNS FROM customers;
DESCRIBE customers;
输出:
Field | Type | Null | Key | Default | Extra | |
---|---|---|---|---|---|---|
cust_id | int(11) | NO | PRI | NULL | auto_increment | |
cust_name | char(50) | NO | NULL | |||
cust_address | char(50) | YES | NULL | |||
cust_city | char(50) | YES | NULL | |||
cust_state | char(5) | YES | NULL | |||
cust_zip | char(10) | YES | NULL | |||
cust_country | char(50) | YES | NULL | |||
cust_contact | char(50) | YES | NULL | |||
cust_email | char(255) | YES | NULL |
SHOW COLUMNS
返回表的信息,包括字段名、数据类型等,与DESCRIBE
等价。
SHOW STATUS
:显示广泛的服务器状态信息;SHOW CREATE DATABSE
,SHOW CREATE TABLE
:显示创建特定数据库或表的MySQL语句SHOW GRANTS
:显示授予用户(所有用户或特定用户)的安全权限SHOW ERRORS
,SHOW WARNINGS
:显示服务器错误或警告消息SELECT
SELECT prod_name FROM products;
:products表中名为prod_name的列SELECT prod_id,prod_name,prod_price FROM products;
:products表中指定的3列SELECT * FROM products;
:通配符(*)返回表中所有列SELECT DISTINCT vend_id FROM products;
:DISTINCT
只返回不同的值,如果ven_id
中有重复的会被省略SELECT prod_name FROM products LIMIT 5;
:LIMIT 5
指示返回不多于5行SELECT prod_name FROM products LIMIT 5,3;
:从第5行开始再输出3行排序
SELECT prod_name FROM products ORDER BY prod_name;
:对prod_name列以字母顺序排序SELECT prod_id, prod_price, prod_name FROM products ORDER BY prod_price, prod_name;
:当多个行具有相同的prod_price值时才对产品按prod_name进行排序。SELECT prod+id, prod_price, prod_name FROM products ORDER BY prod_price DESC
:DESC
指定prod_price降序排序SELECT prod+id, prod_price, prod_name FROM products ORDER BY prod_price DESC