12. mysql Sql_mode ropes

Source: Internet
Author: User

1generally, by default, Sql_mode is empty, which is not a strict SQL check.2if the Sql_mode is empty, test:Create TableTT3 (nameChar(2));//define a tt3 table with a name field length of 2Insert  intoTt3Values('wo');//normal insertion, flawlessInsert  intoTt3Values('Woshi');//normal insertion, but the value has been truncated to "wo" modified Sql_mode to strict mode:SetSession Sql_mode= 'Strict_trans_tables'; Insert  intoTt3Values('Woshi');//Error: Error1406(22001): Data tooLong  for column 'name'At row1That is, strictly, the length of the field input value is strictly controlled.3.SetSession Sql_mode= 'Strict_trans_tables'; This connection takes effectSetGlobal Sql_mode= 'Strict_trans_tables'the connection does not take effect and the new connection takes effect4.SetSession Sql_mode= 'No_backslash_escapes'when turned on, the slash will be inserted as a string such asInsert  intoTt3Values('\1'); , before opening the insert "1", insert after opening" \1"; 5.SetSession Sql_mode= 'Pipes_as_concat'; When turned on,||will be treated as a connector such asSelect"Beijing"|| -; returns 1 before opening, (performed or operated), and returns "beijin2008" after opening6Common Sql_mode ANSI:: Closer to Standard SQL Strict_trans_tables:: Strict mode, do not allow illegal dates, do not allow values beyond the value defined by the field length traditional:: Strict mode, insert incorrect value will directly error, Generally available at the time of 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.