数据类型无时间相关类型
--zerofill不满足位数的用0填充
mysql> use yws
Database changed
mysql> create table t1(id1 int,id2 int(5));
Query OK, 0 rows affected (0.11 sec)
mysql> insert into t1 values(1,1);
Query OK, 1 row affected (0.06 sec)
mysql> commit;
Query OK, 0 rows affected (0.00 sec)
mysql> alter table t1 modify>
Query OK, 1 row affected (0.32 sec)
Records: 1 Duplicates: 0 Warnings: 0
mysql>>
Query OK, 1 row affected (0.23 sec)
Records: 1 Duplicates: 0 Warnings: 0
mysql> select * from t1;
+------------+------------+
|> +------------+------------+
| 0000000001 | 0000000001 |
+------------+------------+
1 row in set (0.00 sec)
increment类型
mysql> create table a1(id int auto_increment not null primary key);
Query OK, 0 rows affected (0.11 sec)
mysql>> Query OK, 0 rows affected (0.26 sec)
Records: 0 Duplicates: 0 Warnings: 0
mysql>insert into a1 (name) values ('yws');
Query OK, 1 row affected (0.07 sec)
mysql> commit;
Query OK, 0 rows affected (0.00 sec)
mysql> select * from a1;
+----+------+
|>
+----+------+
| 1 | yws |
+----+------+
1 row in set (0.00 sec)
mysql> insert into a1 (name) values ('yws');
Query OK, 1 row affected (0.05 sec)
mysql> commit;
Query OK, 0 rows affected (0.00 sec)
mysql> select * from a1;
+----+------+
|>
+----+------+
| 1 | yws |
| 2 | yws |
+----+------+
2 rows in set (0.00 sec)
float double decimal类型
mysql> create table a2(id1 float(5,2),id2 double(5,2),id3 decimal(5,2));
Query OK, 0 rows affected (0.09 sec)
mysql> insert into a2 values(1.23,1.23,1.23);
Query OK, 1 row affected (0.07 sec)
mysql> select * from a2;
+------+------+------+
|> +------+------+------+
| 1.23 | 1.23 | 1.23 |
+------+------+------+
1 row in set (0.00 sec)
mysql> commit;
Query OK, 0 rows affected (0.00 sec)
mysql> insert into a2 values(1.234,1.234,1.234);
Query OK, 1 row affected, 1 warning (0.03 sec)
mysql> select * from a2;
+------+------+------+
|> +------+------+------+
| 1.23 | 1.23 | 1.23 |
| 1.23 | 1.23 | 1.23 |
+------+------+------+
2 rows in set (0.00 sec)
mysql>>modify column>
Query OK, 0 rows affected (0.06 sec)
Records: 0 Duplicates: 0 Warnings: 0
mysql>> modify column>
Query OK, 0 rows affected (0.08 sec)
Records: 0 Duplicates: 0 Warnings: 0
mysql>>modify column>
Query OK, 2 rows affected, 2 warnings (0.24 sec)
Records: 2 Duplicates: 0 Warnings: 2
mysql> insert into a2 values(1.234,1.234,1.234);
Query OK, 1 row affected,1 warning (0.06 sec)
mysql> select * from a2;
+-------+-------+------+
|> +-------+-------+------+
| 1.23 | 1.23 | 1 |
| 1.23 | 1.23 | 1 |
| 1.234 | 1.234 | 1 |
+-------+-------+------+
3 rows in set (0.00 sec)
mysql> commit;
Query OK, 0 rows affected (0.00 sec)
bit数据类型
mysql>create table a3 (id bit);
Query OK, 0 rows affected (0.09 sec)
mysql> desc a3;
+-------+--------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+--------+------+-----+---------+-------+
|>bit(1) | YES | | NULL | |
+-------+--------+------+-----+---------+-------+
1 row in set (0.01 sec)
mysql> insert into a3 values(11);
ERROR 1406 (22001): Data too long for column 'id' at row 1
mysql> insert into a3 values(1);
Query OK, 1 row affected (0.05 sec)
mysql> select * from a3;
+------+
|> +------+
| |
+------+
1 row in set (0.00 sec)
mysql> select bin(id),hex(id) from a3;
+---------+---------+
| bin(id) | hex(id) |
+---------+---------+
| 1 | 1 |
+---------+---------+
1 row in set (0.04 sec)
mysql>
运维网声明
1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网 享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com