MYSQL完全手册学习笔记(第五章)

数据类型


Float(5,2)规定显示的值不会超过5位数字,小数点后面的带有2位数字,如果小数点后的数字个数超过了允许的数目的值,系统自动将它四舍五入

mysql> insert into data values (876.90);
Query OK, 1 row affected (0.03 sec)

mysql> insert into data values (-5.2);
Query OK, 1 row affected (0.03 sec)

mysql> insert into data values (-12345.789);
ERROR 1264 (22003): Out of range value for column 'price' at row 1
mysql> insert into data values (-1234.789);
ERROR 1264 (22003): Out of range value for column 'price' at row 1
mysql> insert into data values (-14.789);
Query OK, 1 row affected (0.03 sec)

mysql> insert into data values (-141.789);
Query OK, 1 row affected (0.03 sec)

mysql> select * from data;
+---------+
| price   |
+---------+
|   13.60 |
|  876.90 |
|   -5.20 |
|  -14.79 |
| -141.79 |
+---------+
5 rows in set (0.00 sec)


mysql> create table data1(birthday date);
Query OK, 0 rows affected (0.08 sec)

mysql> insert into data values('2003-03-08'),(20030908);

mysql> select * from data1;
+------------+
| birthday   |
+------------+
| 2003-03-08 |
| 2003-09-08 |
+------------+
2 rows in set (0.00 sec)

mysql> insert into data2 values('12:30:56'),('12:59'),(123);
Query OK, 3 rows affected (0.02 sec)
Records: 3  Duplicates: 0  Warnings: 0

mysql> select * from data2;
+----------+
| showtime |
+----------+
| 12:30:56 |
| 12:59:00 |
| 00:01:23 |
+----------+
3 rows in set (0.00 sec)

有关timestamp 的内容希望能得到更好的补充。

你可能感兴趣的:(mysql)