In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly explains "what are the disadvantages of the default sql_mode in MySQL". The explanation in the article is simple and clear and easy to learn and understand. Please follow the editor's train of thought to study and learn "what are the disadvantages of the default sql_mode in MySQL"?
The default mode is non-strict mode, and the inserted field is longer than the defined field will be automatically intercepted, and no error will be reported, resulting in data confusion.
Root@test 09:13:09 > select @ @ sql_mode
+-- +
| | @ @ sql_mode |
+-- +
| | NO_ENGINE_SUBSTITUTION |
+-- +
1 row in set (0.00 sec)
Root@test 09:41:54 > desc test
+-+ +
| | Field | Type | Null | Key | Default | Extra | |
+-+ +
| | id | int (11) | YES | | NULL |
| | name | varchar (10) | YES | | NULL |
+-+ +
2 rows in set (0.00 sec)
Root@test 09:46:28 > insert into test values (12, '11111111111111111111111111')
Query OK, 1 row affected, 1 warning (0.02 sec)
Root@test 09:47:19 > select * from test
+-+ +
| | id | name |
+-+ +
| | 1 | aa11 |
| | 2 | 1234 |
| | 3 | Ab |
| | 3 | ab |
| | 12 | 1111111111 | |
+-+ +
two。 So you need to set it to traditional mode, which means it's the traditional database mode, and it responds in the same way as oracle and sql server.
Root@test 09:46:53 > set sql_mode='traditional,NO_ENGINE_SUBSTITUTION'
Query OK, 0 rows affected (0.00 sec)
-- an error will be reported if the field is too long.
Root@test 09:47:15 > insert into test values (12, '11111111111111111111111111')
ERROR 1406 (22001): Data too long for column 'name' at row 1
Therefore, when our application changes from traditional database oracle to mysql, it is best to configure sql_mode='traditional,NO_ENGINE_SUBSTITUTION', so that there will not be some strange and strange behavior.
Thank you for your reading, the above is "what are the disadvantages of the default sql_mode in MySQL", after the study of this article, I believe you have a deeper understanding of the disadvantages of the default sql_mode in MySQL, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.