SQL schema for the database

Source: Internet
Author: User

1. Definition: What is the strict mode of MySQL, in short, MySQL itself to strict data validation (format, length, type, etc.), such as an integer field we write a string type of data, in non-strict mode MySQL will not error, Similarly, if a field of char or varchar type is defined, the data that is written or updated exceeds the defined length without an error. I don't think this is any good for programming, although we try to do data validation in the code. MySQL turned on the strict mode from a certain program to the instructor of our code test, if our development environment does not open strict mode in the development process also did not encounter errors, then on-line or code migration will be possible when the incompatibility of the situation, So in the development process do best to turn on MySQL strict mode.

2. View the SQL schema of the database

Mysql>show variables like ' sql_mode% ';

3. Set the SQL mode to strict mode:

Mysql>setsql_mode= "Strict_trans_tables,no_auto_create_user,no_engine_substitution";

This setting is only valid when the database is connected, and is invalidated after exiting the database.

The other is to modify the configuration file for the database: by modifying the MySQL configuration file, looking for Sql-mode in the configuration file and modifying this line as:

Sql-mode= "Strict_trans_tables,no_auto_create_user,no_engine_substitution"

If you do not find sql-mode=, you can add it under [mysqld] and recommend the second method, once and for all.

During the general project development process, strict patterns are used, which facilitates backup and migration of the database.

SQL schema for the database

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.