Home > Database > Mysql Tutorial > How to optimize the data type of a table using MySQL database commands

How to optimize the data type of a table using MySQL database commands

黄舟
Release: 2017-08-10 15:13:40
Original
1478 people have browsed it

What data type needs to be used in the MySQL database table is determined according to the application; in the MySQL database, you can use the procedure analyze function to achieve this. The following uses a specific example to illustrate the usage of this function. The operation is as follows:

How to optimize the data type of a table using MySQL database commands


##1. The first step is to create the database table t_tree and view the table structure. The command is as follows:

create table t_tree(
id int(4),
tid int(4),
tname varchar(20),
tdesc varchar(100);
);
desc t_tree;
Copy after login

As shown in the figure below:

How to optimize the data type of a table using MySQL database commands

2. In the second step, use the procedure analyze function to analyze t_tree,

select * from t_tree procedure analyse();
Copy after login

as shown in the figure below:

How to optimize the data type of a table using MySQL database commands

3. The third step is to insert five pieces of data into the database table t_tree, as shown in the figure below:

How to optimize the data type of a table using MySQL database commands


##4. The fourth step is to view the database table t_tree data

select * from t_tree
Copy after login

As shown in the figure below:

How to optimize the data type of a table using MySQL database commands

5. In the fifth step, use the procedure analyze function again to analyze the table t_tree,

select * from t_tree procedure analyse();
Copy after login
as shown below Shown:

How to optimize the data type of a table using MySQL database commands

6. In the sixth step, you can add parameters in the procedure analyze function,

select * from t_tree procedure analyse(16,256);
Copy after login

As shown in the figure below:

How to optimize the data type of a table using MySQL database commandsNotes

Pay attention to the usage of the procedure analyze function

Master the MySQL database analysis table data type method

The above is the detailed content of How to optimize the data type of a table using MySQL database commands. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template