1. 基本数据类型
- char:prod_id char(10),括号内的内容表示字符的长度
- decimal:十进制,不带参数为整数(四舍五入)
- text:文本类型,长度不限
2. 日期和时间处理函数
# order_date 类型为datetime
# 插入行之后即为:2012-05-01 00:00:00
select order_num from orders where year(order_date) = 2012;
select order_num from orders where month(order_date) = 5;
select order_num from orders where day(order_date) = 1;
3. 变量
SHOW GLOBAL VAIABLES; 显示系统变量;
mysql> show global variables like 'autocommit'; +---------------+-------+ | Variable_name | Value | +---------------+-------+ | autocommit | ON | +---------------+-------+
4. 用户自定义变量(@)及系统变量(@@)
mysql> SET @t1=0,@t2=0,@t3=0;
Query OK, 0 rows affected (0.00 sec)
mysql> SELECT @t1:=(@t2:=1)+@t3:=4,@t1,@t2,@t3;
+----------------------+------+------+------+
| @t1:=(@t2:=1)+@t3:=4 | @t1 | @t2 | @t3 |
+----------------------+------+------+------+
| 5 | 5 | 1 | 4 |
+----------------------+------+------+------+
1 row in set (0.00 sec)