关闭

mysql 数据类型

132人阅读 评论(0) 收藏 举报
分类:
double(16,4) 

小数点后4位,

总共16位小数

mysql> select * from test100;
+--------------------+
| value              |
+--------------------+
|            -1.0000 |
|            -1.0000 |
|            -1.0000 |
|     -99999999.0000 |
| -123456789012.0000 |
|  123456789012.0000 |
+--------------------+
6 rows in set (0.00 sec)

bigint(20) unsigned 
unsigned 表示无符号:

mysql> create table test200(value bigint(20) unsigned );
Query OK, 0 rows affected (0.01 sec)

mysql> desc test200;
+-------+---------------------+------+-----+---------+-------+
| Field | Type                | Null | Key | Default | Extra |
+-------+---------------------+------+-----+---------+-------+
| value | bigint(20) unsigned | YES  |     | NULL    |       |
+-------+---------------------+------+-----+---------+-------+
1 row in set (0.01 sec)

mysql> insert into test200 values(-1);
ERROR 1264 (22003): Out of range value for column 'value' at row 1


mysql> desc test300;
+-------+------------+------+-----+---------+-------+
| Field | Type       | Null | Key | Default | Extra |
+-------+------------+------+-----+---------+-------+
| value | bigint(20) | YES  |     | NULL    |       |
+-------+------------+------+-----+---------+-------+
1 row in set (0.00 sec)

mysql> insert into test300 values(-1);
Query OK, 1 row affected (0.00 sec)

mysql> select * from test300;
+-------+
| value |
+-------+
|    -1 |
+-------+
1 row in set (0.00 sec)


mysql> desc history_uint;
+--------+---------------------+------+-----+---------+-------+
| Field  | Type                | Null | Key | Default | Extra |
+--------+---------------------+------+-----+---------+-------+
| itemid | bigint(20) unsigned | NO   | MUL | NULL    |       |
| clock  | int(11)             | NO   |     | 0       |       |
| value  | bigint(20) unsigned | NO   |     | 0       |       |
| ns     | int(11)             | NO   |     | 0       |       |
+--------+---------------------+------+-----+---------+-------+
4 rows in set (0.00 sec)

mysql> desc history_uint;
+--------+---------------------+------+-----+---------+-------+
| Field  | Type                | Null | Key | Default | Extra |
+--------+---------------------+------+-----+---------+-------+
| itemid | bigint(20) unsigned | NO   | MUL | NULL    |       |
| clock  | int(11)             | NO   |     | 0       |       |
| value  | bigint(20) unsigned | NO   |     | 0       |       |
| ns     | int(11)             | NO   |     | 0       |       |
+--------+---------------------+------+-----+---------+-------+
4 rows in set (0.00 sec)

mysql>  alter table history_uint  modify column value  bigint(20);
Query OK, 2952022 rows affected (52.83 sec)
Records: 2952022  Duplicates: 0  Warnings: 0

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:1179174次
    • 积分:38639
    • 等级:
    • 排名:第102名
    • 原创:2818篇
    • 转载:14篇
    • 译文:0篇
    • 评论:46条
    文章分类
    最新评论