In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article will explain in detail how to use modified sql_mode=NO_TABLE_OPTIONS to collect table sentences and remove engine and charset keywords in mysql. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.
I. description
Usually we have the need to generate the establishment table statement according to the existing table, directly check that there will be two keywords ENGINE and CHARSET in the generation process, in fact, most of the time we do not need this parameter, if we manually modify the script after export, it is really troublesome. Here we can use the sql_mode parameter and change it to NO_TABLE_OPTIONS for collection. Of course, we should pay attention to modify the variables of the current session, not the global variables. Here is a small experiment to demonstrate this process.
2. Experiment
1. Check the sql_mode variable value of course
Mysql > show variables like 'sql_mode'
+-+
| | Variable_name | Value |
+-+
| | sql_mode | STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION |
+-+
1 row in set (0.01 sec)
two。 View the build statement of the T1 table with two parameters, ENGINE and CHARSET
Mysql > show create table T1
+-+ +
| | Table | Create Table |
+-+ +
| | T1 | CREATE TABLE `t1` (
`id`int (11) DEFAULT NULL
`name` char (20) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 |
+-+ +
1 row in set (0.00 sec)
3. Change sql_mode to NO_TABLE_OPTIONS
Mysql > set session sql_mode='NO_TABLE_OPTIONS'
Query OK, 0 rows affected (0.00 sec)
Mysql > show variables like'% sql_mode%'
+-+ +
| | Variable_name | Value |
+-+ +
| | sql_mode | NO_TABLE_OPTIONS |
+-+ +
1 row in set (0.00 sec)
4. Look at the SQL statement of the building T1 table again. There are no ENGINE and CHARSET parameters.
Mysql > show create table T1
+-+
| | Table | Create Table |
+-+
| | T1 | CREATE TABLE `t1` (
`id`int (11) DEFAULT NULL
`name` char (20) DEFAULT NULL
) |
+-+
1 row in set (0.00 sec)
5. Exit the session to restore the sql_mode parameter to its default value
This is the end of this article on "how to use modified sql_mode=NO_TABLE_OPTIONS to collect table sentences and remove engine and charset keywords in mysql". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.