Learning Mysql



Download 4.24 Mb.
View original pdf
Page173/366
Date04.08.2023
Size4.24 Mb.
#61806
1   ...   169   170   171   172   173   174   175   176   ...   366
Learning MySQL
Creating Tables | 191

Query OK, 1 row affected (0.00 sec)
mysql INSERT INTO test_time VALUES, "35 13:25:59");
Query OK, 1 row affected, 1 warning (0.00 sec)
mysql SHOW WARNINGS;
+---------+------+----------------------------------------------------------+
| Level | Code | Message |
+---------+------+----------------------------------------------------------+
| Warning | 1264 | Out of range value adjusted for column 'mytime' at row 1 |
+---------+------+----------------------------------------------------------+
1 row inset sec)
mysql INSERT INTO test_time VALUES, "-35 13:25:59");
Query OK, 1 row affected, 1 warning (0.00 sec)
mysql INSERT INTO test_time VALUES, "35 13:25:69");
Query OK, 1 row affected, 1 warning (0.00 sec)
mysql SHOW WARNINGS;
+---------+------+---------------------------------------------+
| Level | Code | Message |
+---------+------+---------------------------------------------+
| Warning | 1265 | Data truncated for column 'mytime' at row 1 |
+---------+------+---------------------------------------------+
1 row inset sec)
mysql SELECT * FROM test_time;
+----+------------+
| id | mytime |
+----+------------+
| 1 | 61:25:59 |
| 2 | 838:59:59 |
| 3 | -838:59:59 |
| 4 | 00:00:00 |
+----+------------+
4 rows inset sec)
Note how the out-of-range and invalid times are stored.
H:M:S
, and single, double, and triple-digit combinations
You can use different combinations of digits when inserting or updating data;
MySQL converts them into the internal time format and displays them consistently. For example, is equivalent to
01:01:03
. Different numbers of digits can be mixed for example, is equivalent to
01:12:03
. Consider these examples:
mysql> CREATE TABLE mytime (testtime TIME);
Query OK, 0 rows affected (0.12 sec)
mysql> INSERT INTO mytime VALUES

Download 4.24 Mb.

Share with your friends:
1   ...   169   170   171   172   173   174   175   176   ...   366




The database is protected by copyright ©ininet.org 2024
send message

    Main page