———————————————————————–
TINYINT -128 127 1バイト
TINYINT UNSIGNED 0 255 1バイト
———————————————————————–

mysql> CREATE TABLE `TINT` (
-> `ID` tinyint(2) NULL,
-> `TimeS` timestamp NULL DEFAULT CURRENT_TIMESTAMP
-> ) ENGINE=MyISAM DEFAULT CHARSET=utf8
-> ;
Query OK, 0 rows affected (0.15 sec)

tint_table

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

mysql> insert into TINT(ID) values(2);
Query OK, 1 row affected (0.00 sec)

mysql> insert into TINT(ID) values(100);
Query OK, 1 row affected (0.00 sec)

mysql> insert into TINT(ID) values(127);
Query OK, 1 row affected (0.00 sec)

mysql> insert into TINT(ID) values(128);
Query OK, 1 row affected, 1 warning (0.00 sec)

mysql> show warnings;
+---------+------+---------------------------------------------+
| Level | Code | Message |
+---------+------+---------------------------------------------+
| Warning | 1264 | Out of range value for column 'ID' at row 1 |
+---------+------+---------------------------------------------+
1 row in set (0.00 sec)

mysql> select * from TINT;
+——+———————+
| ID | TimeS |
+——+———————+
| 1 | 2009-07-06 12:45:00 |
| 2 | 2009-07-06 12:45:03 |
| 100 | 2009-07-06 12:45:11 |
| 127 | 2009-07-06 12:45:19 |
| 127 | 2009-07-06 12:45:22 | <--- 127以上の数値はTINY INTでは受け付けない +------+---------------------+ 5 rows in set (0.00 sec) mysql>

tint

Comments are closed.

Post Navigation