12. mysqlsql_mode short _ MySQL

Source: Internet
Author: User
12. mysqlsql_mode
1. in general, SQL _mode is empty by default, that is, the SQL check is not strict. 2. if SQL _mode is null, test: create table tt3 (name char (2 )); // define a tt3 table with the name field length of 2 to insert into tt3 values ('wo'); // insert into tt3 values ('woshi '); // normal insertion, but the value has been intercepted into "wo" and changed SQL _mode to STRICT mode: set session SQL _mode = 'strict _ TRANS_TABLES '; insert into tt3 values ('woshi '); // ERROR: ERROR 1406 (22001): Data too long for column 'name' at row 1, that is, under strict conditions, is the 3.set session SQL _mode = 'strict _ TRANS_TABLES 'that strictly controls the length of the input value of the field. this connection takes effect for set global SQL _mode = 'strict _ TRANS_TABLES'. this connection does not take effect, the new connection takes effect in 4.set session SQL _mode = 'no _ BACKSLASH_ESCAPES '. When enabled, the slash will be inserted as a string, for example, insert into tt3 values ('/1 ');, insert "1" before enabling, and insert "/1" after enabling; 5.set session SQL _mode = 'Pipes _ AS_CONCAT '; after enabling, | will be used as a connector such as select "beijing" | 2008; returns 1 before enabling (or), and returns "beijin2008" 6 after enabling. common SQL _mode ANSI: closer to the standard SQL STRICT_TRANS_TABLES: strict mode. invalid dates are not allowed. TRADITIONAL: strict mode is not allowed for values that exceed the length defined by the field, if an incorrect value is inserted, an error is reported, which is generally available during the transaction.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.