MySQL strict mode SQL _mode

Source: Internet
Author: User

Although we try to writeProgramControl the data inserted into the database, instead of using the database to judge whether the data is right or wrong, but sometimes for convenience, we still need the database's own fault tolerance capabilities to help us achieve our goal. Example:

 

Create the following data table

Create Table 'book' ('id' int (11) default null, 'num' int (11) unsigned default null) engine = InnoDB default charset = GBK insert into bookvalues (1, 0), (2, 0)

If you execute update book set num = 'abc', no error is reported because the strict mode is not enabled. So

Run set SQL _mode = "strict_trans_tables, no_auto_create_user, no_engine_substitution ",

Then execute update book set num = 'abc' and the database reports an error.

 

If you want to do this all, set the relevant parameters in the database configuration file my. ini

# Set the SQL mode to strict
SQL-mode = "strict_trans_tables, no_auto_create_user, no_engine_substitution"

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.