Introduction to Mysql database basics

Introduction to Mysql database basics

1. Database introduction

1.1. Development history of database

1.1.1. Disadvantages of file management systems

  • Writing applications is inconvenient

  • Data redundancy is inevitable

  • application dependencies

  • Concurrent access to files is not supported

  • Weak connection between data

  • Difficulty representing data in user view

  • No safety control function

1.1.2. Database system development stage

  • In its infancy: file systems

    • Use disk files to store data
  • Primary stage: first generation database

    • Network model and hierarchical model databases appeared
  • Intermediate stage: second generation database

    • Relational databases and structured query languages
  • Advanced stage: new generation database

    • "Relational-object" database

1.3. DBMS database management system

  • Database: Database is a collection of data, which is stored on storage media in a certain organizational form.

  • DBMS: It is system software that manages databases. It implements various functions of the database system. Is the core of the database system

  • DBA: Responsible for database planning, design, coordination, maintenance and management

  • Application: refers to an application based on a database

1.4. Advantages of database management systems

  • A collection of interrelated data

  • Less data redundancy

  • Programs and data are independent of each other

  • Ensure data security and reliability

  • Maximize data accuracy

  • Data can be used concurrently while ensuring consistency

1.5. Basic functions of database management system

  • data definition

  • data processing

  • Data Security

  • data backup

1.6. Database system architecture

  • Stand-alone architecture

  • Mainframe/Terminal Architecture

  • Master-slave architecture (C/S)

  • Distributed architecture

1.7. Various database management systems

1.7.1. Hierarchical database

Insert image description here

1.7.2. Network database

Insert image description here

1.7.3, RDBMS relational database

Relational Database Management System, the relational model was originally described by Edgar F. Codd, a British computer scientist at IBM,
in 1969. In 1974, IBM began developing System R, a research project to develop an RDBMS prototype. . However, the first commercially available RDBMS was Oracle, released in 1979 by Relational Software (now Oracle Corporation).

1.7.3.1 Concepts related to system database
  • Relational: A relationship is a two-dimensional table, where the order of rows and columns in the table is not important.

  • Row: Each row in the table, also called a record

  • Column: Each column in the table is called an attribute, field, or field

  • Primary key: PK, a field used to uniquely determine a record. A table has only one primary key.

  • Domain domain: The value range of the attribute. For example, gender can only have two values: 'male' and 'female', and human age can only be 0-150.

1.7.3.2. Commonly used relational databases

MySQL: MySQL, MariaDB, Percona Server

PostgreSQL: pgsql for short, EnterpriseDB

1.7.3.3. Database ranking

https://db-engines.com/en/ranking

1.8. Relational database theory

1.8.1. Entity Contact Model ER

Entity : Objective things or abstract events that exist objectively and can be distinguished from each other are called entities. In the ER diagram, a rectangular box is used to represent the entity, and the entity name is written in the box.

Attributes : Characteristics or properties of an entity

Connection : A connection is a collection of associations between data and an objectively existing application semantic chain.

• Relationship within an entity: refers to the relationship between the attributes that make up the entity. For example, in the employee entity, there is a relationship between the employee number and the department manager number.

• Relationship between entities: refers to the relationship between different entities. Example: between the student course selection entity and the student basic information entity

• The relationship between entities is represented by a diamond box
1.8.2 Contact type
One-to-one contact (1:1)

One-to-many relationship (1:n): foreign key

Many-to-many relationship (m:n): add a third table

1.8.3. Data operations

  • Data Extraction : Extract interesting content from a data collection. SELECT

  • Data update**: Change the data in the database. INSERT, DELETE, UPDATE

1.8.4. Database planning process

1. Collect data and get fields
2. Collect necessary and complete data items
3. Convert into fields of data table

2. Relational databases and non-relational databases

1) Describe the mainstream database system relational database: Mysql (Oracle), SQL server (Microsoft), access (Microsoft office product) Oracle, DB2 (IBM), sybase (sybase), etc. 2) Relational database
and The difference between non-relational databases and relational databases: The relational database structure is a two-dimensional database table. Each field (column) in the two-dimensional table is used to describe an attribute of the object, and each record (row) is used to describe the information of an object ( Complete information), wherever the relational database is written, it is stored in the hard disk, and the reading and writing system will be subject to IO restrictions or bottlenecks.
Advantages:

1. Flexible format: The format for storing data can be in key, value form, document form, picture form, etc. It is flexible to use and has a wide range of application scenarios, while relational databases only support basic types.
2. Fast speed: NoSQL can use hard disk or random access memory as the carrier, while relational database can only use hard disk;
3. High scalability and high availability;
4. Low cost: NoSQL database is easy to deploy and is basically open source software.

Disadvantages:
1. Does not provide sql support, and the learning and use costs are high;
2. No transaction processing;
3. The data structure is relatively complex, and complex queries are slightly lacking.
3. Basic concepts of database

2.1. The necessity of using a database

Using a database can store data efficiently and clearly, allowing people to manage data more quickly and conveniently. The database has the following characteristics.

  • A large amount of data information can be stored in a structured manner to facilitate effective retrieval and access by users.

  • It can effectively maintain the consistency and integrity of data information and reduce data redundancy.

  • Can meet application sharing and security requirements.

  • Database technology is one of the core technologies of computer science and has a complete theoretical foundation. Mastering the basic concepts of database will help you understand the database.

2.2. Basic concepts of database

2.2.1, Data (Data)

  • Symbolic records that describe things

  • Including numbers, text, graphics, images, sounds, file records, etc.

  • Stored in a unified format in the form of "records"

2.2.2, table

  • Organize different records together

  • Used to store specific data

2.2.3. Database

  • A collection of tables is a warehouse that stores data

  • A collection of related data stored in an organized manner

3. Installation of MySQL

MySQL
client program

  • mysql: interactive CLI tool

  • mysqladmin: manage mysqld based on mysql protocol

  • mysqlimport: data import tool

  • Management tools for MyISAM storage engine:

  • myisamchk: Check MyISAM library

  • myisampack: Pack MyISAM tables, read-only

Server-side program

  • mysqld_safe

  • mysqld

  • mysqld_multi multiple instances, example: mysqld_multi

[root@localhost ~]#yum info mariadb
可安装的软件包
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
可安装的软件包
名称    :mariadb
架构    :x86_64
时期       :1
版本    :5.5.56
发布    :2.el7
大小    :8.7 M
源    :yum
简介    : A community developed branch of MySQL
网址    :http://mariadb.org
协议    : GPLv2 with exceptions and LGPLv2 and BSD
描述    : MariaDB is a community developed branch of
         : MySQL. MariaDB is a multi-user,
         : multi-threaded SQL database server. It is a
         : client/server implementation consisting of
         : a server daemon (mysqld) and many different
         : client programs and libraries. The base
         : package contains the standard MariaDB/MySQL
         : client programs and generic MySQL files.
 
MySQL被Sun收购后,搞了个过渡的6.0版本,没多久就下线了,后来被Oracle收购后,终于迎来了像样的5.6
版本,之后就是5.7、8.0版本。由于6.0版本号已被用过,7.x系列版本专用于NDB Cluster,因而新版本
号从8.0开始。

3.1. Method 1: Compile and install

1. #安装依赖包并解压下载的mysql
yum install -y ncurses-devel autoconf cmake
tar zxf mysql-5.6.26.tar.gz 
 
2. #编译安装
cd mysql-5.6.26/
 
###编译###
cmake  \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DEXTRA_CHARSETS=all \
-DSYSCONFIDIR=/etc \
-DMYSQL_DATADIR=/home/mysql/ \
-DMYSQL_UNIX_ADDR=/home/mysql/mysql.sock
 
###安装###
make && make install -j4
 
3. #拷贝文件,并授权
cp support-files/my-default.cnf /etc/my.cnf
cp support-files/mysql.server /etc/init.d/mysqld
chmod 755 /etc/init.d/mysqld 
chkconfig --add /etc/init.d/mysqld
chkconfig  mysqld --level 35 on
 
4. #设置环境变量,申明/宣告mysql命令便于系统识别
echo "PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile
source /etc/profile
echo $PATH
 
5. #创建普通用户管理mysql
useradd -s /sbin/nologin mysql
chown -R mysql:mysql /usr/local/mysql/
chown mysql:mysql /etc/my.cnf
 
 
6. #初始化初始化数据库
/usr/local/mysql/scripts/mysql_install_db \
--user=mysql \
--ldata=/var/lib/mysql \
--basedir=/usr/local/mysql \
--datadir=/home/mysql
 
7. #修改配置文件
vim /etc/init.d/mysqld 
 
##修改46,47行
basedir=/usr/local/mysql
datadir=/home/mysql
 
8. #启动mysql
service mysqld start
ss -ntap|grep "3306"
 
9. #登录及登出mysql
##给root账号设置密码
mysqladmin -u root -p password "123123"
##登录mysql
mysql -u root -p
##登出mysql
mysql> exit
Bye

Install dependency packages and unzip the downloaded mysql
Insert image description here
Insert image description here
compile
Insert image description here
Insert image description here
and install. Copy the files and authorize them
Insert image description here
. Set environment variables and declare/declare mysql commands to facilitate system identification.
Insert image description here
Insert image description here
Create a common user to manage mysql
Insert image description here
initialization and initialize the database.
Insert image description here
Modify the configuration file .
Insert image description here
Insert image description here
Start mysql
Insert image description here
login and log out mysql.
Insert image description here
Insert image description here

3.2. Method 2: Install version 5.7 with yum



1. #创建mysql源
cd /etc/yum.repos.d/
vim mysql.repo
[mysql]
name=mysql5.7
baseurl=https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql-5.7-community-el7-x86_64/
gpgcheck=0
 
2. #安装服务mysql-community-server
yum -y install mysql-community-server
 
3. #启动服务
systemctl start mysqld
ss -ntap |grep 3306
 
4. #登入数据库,但是密码是默认的,需要查看
mysql -u root -p
grep password /var/log/mysqld.log
mysql -u root -p'+8saq%5+ljzG'
#特殊符号用单引号引起来
 
5. #登入数据库后必须修改密码
status
alter user root@'localhost' identified by 'Yxp15@2021';
 
#可以使用mysql> \h查看帮助

``
Install and start

Insert image description here
Insert image description here
Start the service
Insert image description here
and log in to the database, but the password is default and needs to be checked.
Insert image description here
The password must be changed after logging in to the database.
Insert image description here

4. Multiple instances

4.1. Multi-instance introduction

  • What is database multiple instances

Multi-instance is similar to WeChat dual-open, the port number is like WeChat account, the database is like chat window, and the table is like chat record. MySQL multi-instance is to open multiple different service ports (such as: 3306, 3307, etc.) on one server at the same time, and run multiple servers at the same time. A MySQL service process, these service processes listen to different service ports through different Sockets to provide services. Multiple instances may be different versions of MySQL, or they may be the same version of MySQL.

  • Benefits of multiple instances

Server resources can be efficiently utilized. When a single server has surplus resources, the remaining resources can be fully utilized to provide more services, and logical isolation of resources can be achieved to save server resources. For example, the company's server resources are tight, but the databases need to provide services as independently as possible, and they also need technologies such as master-slave replication. Multi-instance is the best choice.

  • Disadvantages of multiple instances
    : There is the problem of resource preemption. For example: when a database instance has high concurrency or slow SQL queries, the entire instance will consume a large amount of CPU, disk I/O and other resources, causing the quality of services provided by other database instances on the server to also decline, so specific The needs should be determined according to your actual situation.

4.2. Multiple instance examples

1. #安装mariadb-server并启动登入系统
yum -y install mariadb-server
systemctl start mariadb.service
 
#一路回车,并设置密码
mysql_secure_installation 
 
#登入系统
mysql -u root -p123123
 
 
 
2. #创建目录和文件夹
mkdir -pv /mysql/{
    
    3306,3307,3308}/{
    
    data,etc,socket,log,bin,pid}
 
3. #设置属主属组
 chown -R mysql.mysql /mysql
 tree -d /mysql/
 
 4. #初始化数据库
 mysql_install_db --user=mysql --datadir=/mysql/3306/data
 mysql_install_db --user=mysql --datadir=/mysql/3307/data
 mysql_install_db --user=mysql --datadir=/mysql/3308/data
 
 5. #编辑配置文件
vim /mysql/3306/etc/my.cnf 
[mysqld]
port=3306
datadir=/mysql/3306/data
socket=/mysql/3306/socket/mysql.sock
log-error=/mysql/3306/log/mysql.log
pid-file=/mysql/3306/pid/mysql.pid
 
6. #修改3307和3308配置文件
sed 's/3306/3307/' /mysql/3306/etc/my.cnf > /mysql/3307/etc/my.cnf
 
sed 's/3306/3308/' /mysql/3306/etc/my.cnf > 
/mysql/3308/etc/my.cnf
 
 
7. #准备启动脚本
vim /mysql/3306/bin/mysqld
#!/bin/bash
 
port=3306
mysql_user="root"
mysql_pwd=""
cmd_path="/usr/bin"
mysql_basedir="/mysql"
mysql_sock="${mysql_basedir}/${port}/socket/mysql.sock"
 
function_start_mysql()
{
    
    
    if [ ! -e "$mysql_sock" ];then
      printf "Starting MySQL...\n"
      ${cmd_path}/mysqld_safe --defaults-file=${mysql_basedir}/${port}/etc/my.cnf  &> /dev/null  &
    else
      printf "MySQL is running...\n"
      exit
    fi
}
 
 
function_stop_mysql()
{
    
    
    if [ ! -e "$mysql_sock" ];then
       printf "MySQL is stopped...\n"
       exit
    else
       printf "Stoping MySQL...\n"
       ${cmd_path}/mysqladmin -u ${mysql_user} -p${mysql_pwd} -S ${mysql_sock} shutdown
   fi
}
 
 
function_restart_mysql()
{
    
    
    printf "Restarting MySQL...\n"
    function_stop_mysql
    sleep 2
    function_start_mysql
}
 
case $1 in
start)
    function_start_mysql
;;
stop)
    function_stop_mysql
;;
restart)
    function_restart_mysql
;;
*)
    printf "Usage: ${mysql_basedir}/${port}/bin/mysqld {start|stop|restart}\n"
esac
 
8. #重复上述过程,分别建立3307,3308的启动脚本
 
9. #授权并启动服务
chmod +x /mysql/3306/bin/mysqld 
chmod +x /mysql/3307/bin/mysqld 
chmod +x /mysql/3308/bin/mysqld 
 
/mysql/3306/bin/mysqld start
/mysql/3307/bin/mysqld start
/mysql/3308/bin/mysqld start
 
#查看有没有启动成功
ss -natp|grep 33
 
 
10. #怎么看mysql这个进程是不是超线程
1)#找到mysql进程号
pstree -p
2)#查看,5450就是查看的进程号
cat /proc/5450/status |grep Threads
 
11. #登入mysql
#示例
mysql -h127.0.0.1 -P3308
 
12. #怎么杀掉这个进程,示例
/mysql/3308/bin/mysqld stop
 
13. #修改密码示例
mysqladmin -uroot -S /mysql/3306/socket/mysql.sock password  
'123123' 
 
14. #设置开机启动
vim /etc/rc.d/rc.local
for i in {
    
    3306..3308};do /mysql/$i/bin/mysqld start;done
 
chmod +x /etc/rc.d/rc.local
 
开机后
bash /etc/rc.d/rc.local 

Install mariadb-server

Insert image description here
Insert image description here
Insert image description here
Insert image description here
Create directories and folders
Insert image description here
Insert image description here
Initialize database

Insert image description here
Insert image description here
Insert image description here
Edit the configuration file.
Insert image description here
Modify the 3307 and 3308 configuration files
Insert image description here
. Prepare the startup script
Insert image description here
. Repeat the above process to create startup scripts for 3307 and 3308.
Insert image description here
Insert image description here
Authorize and start the service.

Insert image description here
How to check whether the mysql process is hyper-threaded? How to kill this process
Insert image description here
Insert image description here
after logging into mysql ?
Insert image description here

Insert image description here

5. Install plug-ins so that SQL commands can be completed when used.

1. #安装插件
yum install -y libffi-devel
yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel
 
2. #将php包导入/opt下,解压安装php
cd /opt/
tar zxvf Python-3.7.7_.tgz
##编译
cd Python-3.7.7/
./configure --prefix=/usr/local/Python-3.7.7/
 
##安装
make && make install
 
##做软连接
ln -s  /usr/local/Python-3.7.7/bin/python3.7  /usr/bin/python37
ln -s /usr/local/Python-3.7.7/bin/pip3.7 /usr/bin/pip37
pip37 install mycli -i http://mirrors.aliyun.com/pypi/simple --trusted-host mirrors.aliyun.com
ln -s /usr/local/Python-3.7.7/bin/mycli /usr/bin/mycli
 
3. #登录
mycli -u root -p 123123
 
 
####如果不装插件
[root@localhost ~]#vim /etc/my.cnf                       
[mysql]
prompt=(\\u@\\h) [\\d]>\\_
 
auto-rehash

Install the plug-in.
Insert image description here
Insert image description here
Import the php package under /opt, unzip and install php
Insert image description here
Insert image description here
Insert image description here
to make a soft connection.
Insert image description here
Insert image description here
Log in
Insert image description here
Insert image description here

6. Basic database operations

6.1. SQL classification

  • Database: database

  • Table: table, row: row column: column

  • Index: index

  • View: view

  • Stored procedure: procedure

  • Stored function: function

  • Trigger: trigger

  • Event scheduler: event scheduler, task plan

  • User: user

  • Permissions:privilege

6.2. SQL language specification

  • In the database system, SQL statements are not case-sensitive. It is recommended to use uppercase letters.

  • SQL statements can be written in a single line or multiple lines, and end with ";" by default

  • Keywords cannot span multiple lines or abbreviations

  • Use spaces and TAB indentation to improve statement readability

  • Clauses are usually on separate lines to facilitate editing and improve readability

Database objects and naming
Database components (objects):
databases, tables, indexes, views, users, stored procedures, functions, triggers, event schedulers, etc.

Naming rules:
must start with a letter, and can include letters, numbers and three special characters (# _ $).
Do not use MySQL reserved words, such as table select show databases
SQL statement classification

  • DDL: Data Definition Language data definition language

CREATE,DROP,ALTER

  • DML: Data Manipulation Language

INSERT, DELETE, UPDATE
software development: CRUD

  • DQL: Data Query Language data query language

SELECT

  • DCL: Data Control Language data control language

GRANT,REVOKE

  • TCL: Transaction Control Language Transaction Control Language

COMMIT,ROLLBACK,SAVEPOINT

#DDL: Data Defination Language 数据定义语言
CREATE,DROP,ALTER
 
#DML: Data Manipulation Language 数据操纵语言
INSERT,DELETE,UPDATE
 
#DQL:Data Query Language 数据查询语言
SELECT 
 
 
#DCL:Data Control Language 数据控制语言
GRANT,REVOKE,COMMIT,ROLLBACK
 
 
SELECT *                 #SELECT子句
FROM products             #FROM子句
WHERE price>666         #WHERE子句

6.3. View help information

mysql> help create
#help 后面跟上具体命令可以查看帮助
Many help items for your request exist.
To make a more specific request, please type 'help <item>',
where <item> is one of the following
topics:
   CREATE DATABASE
   CREATE EVENT
   CREATE FUNCTION
   CREATE FUNCTION UDF
   CREATE INDEX
   CREATE LOGFILE GROUP
   CREATE PROCEDURE
   CREATE SERVER
   CREATE TABLE
   CREATE TABLESPACE
   CREATE TRIGGER
   CREATE USER
   CREATE VIEW
   SHOW
   SHOW CREATE DATABASE
   SHOW CREATE EVENT
   SHOW CREATE FUNCTION
   SHOW CREATE PROCEDURE
   SHOW CREATE TABLE
   SHOW CREATE USER
   SPATIAL
   
   
 ##也可以进一步
 mysql> help create DATABASE \G

6.4. View supported character sets

show charset;
#查看支持字符集
默认拉丁文字
 
utf8     | UTF-8 Unicode   
#阉割版的
 
utf8mb4  | UTF-8 Unicode 
#真实的版本
 
我们编译安装已经修改过了

6.5. View table and use table

mysql> show databases;
#查看当前数据库
 
 
mysql> use mysql;
#使用 mysql表
 
 
MySQL root@localhost:school> select * form  yxp;
#查看yxp表格的

6.6. Management database

6.6.1. Create database

CREATE DATABASE|SCHEMA [IF NOT EXISTS] 'DB_NAME'
CHARACTER SET 'character set name'
COLLATE 'collate name';
 
#创建数据库
create database dbb1;
 
#创建的时候指定语言
create database db3 charset=utf8;
 
 
#查看创建的数据库
show create  database dbb1;
 
#加的数据位置
cd /usr/local/mysql/data/test/

Insert image description here
Insert image description here
Insert image description here
Insert image description here

6.6.2. Modify database

ALTER DATABASE DB_NAME character set utf8;

Insert image description here

6.6.3. Delete database

DROP DATABASE|SCHEMA [IF EXISTS] 'DB_NAME';
 
例如
drop database dbb1;

Insert image description here

6.6.4. View database list

SHOW DATABASES;
 
例如:
show databases;

Insert image description here

6.6.5. Check the current directory status

 system ls

Insert image description here

6.6.6. View host name

 system hostname

Insert image description here

6.6.7. View current database version information

mysql -V

Insert image description here

7. Data type

type of data:

What does the data look like?

How much space does the data need to store?

type of data

System built-in data types

user-defined data type

MySQL supports multiple built-in data types**

Numeric type

date/time type

String (character) type

Data type reference link

https://dev.mysql.com/doc/refman/8.0/en/data-types.html

Choosing the right data type is critical to achieving high performance. Three principles:

1. Smaller is usually better. Try to use the smallest data type that can store data correctly.
2. Simple is good. Operations on simple data types usually require fewer CPU cycles.
3. Try to avoid NULL and columns containing NULL. MySQL is harder to optimize

7.1. Integer type

tinyint(m) 1 byte range (-128~127)

smallint(m) 2 byte range (-32768~32767)

mediumint(m) 3 byte range (-8388608~8388607)

int(m) 4 byte range (-2147483648~2147483647)

bigint(m) 8-byte range (±9.22*10 to the 18th power)

If the above data type is added with the modifier unsigned, the maximum value will be doubled.

For example: the value range of tinyint unsigned is (0~255)

7.2. Floating point type (float and double), approximate value

float(m,d) single-precision floating-point type with 8-bit precision (4 bytes) m total number, d decimal places, note: the decimal point does not occupy the total number double(m,d) double-precision floating-point type with 16-bit precision (8 bytes) m total number, d decimal places, note: the decimal point does not occupy the total number.
Suppose a field is defined as float (6, 3). If a number 123.45678 is inserted, the actual database stores 123.457, but the total number Count in return

The actual situation shall prevail, i.e. 6 digits

7.3, Number of fixed points

The exact value is stored in the database and is stored as decimal.

The format decimal(m,d) represents up to m digits, including d decimals, and the decimal point is not included in the length.

For example: DECIMAL(6,2) can store a total of 6 digits, the last 2 digits are decimals, and the maximum field value is 9999.99 (the decimal point is not included in the length)

Parameter m<65 is the total number, d<30 and d<m is the decimal place

MySQL 5.0 and later pack numbers into a binary string (9 numbers per 4 bytes).

For example: decimal(18,9) will store 9 numbers on both sides of the decimal point, using a total of 9 bytes: among them, 4 are used for the 9 numbers before the decimal point.

Bytes, the 9 digits after the decimal point use 4 bytes, and the decimal point itself occupies 1 byte

Floating point types generally use less space than decimal when storing the same range of values. float uses 4 bytes for storage. double occupied

8 bytes

Because of the extra space and computational overhead, you should try to only perform exact calculations on decimals.

7.4, string (char, varchar, text)

char(n) fixed length, up to 255 characters, note not bytes

varchar(n) variable length, up to 65535 characters

tinytext variable length, up to 255 characters

text variable length, up to 65535 characters

mediumtext variable length, up to 2 to the 24th power - 1 character

longtext variable length, up to 2 to the 32nd power - 1 character

BINARY(M) fixed length, can store binary or characters, length is 0-M bytes

VARBINARY(M) variable length, can store binary or characters, allowed length is 0-M bytes

Built-in types: ENUM enumeration, SET collection

Comparison of char and varchar:

Guess you like

Origin blog.csdn.net/fyb012811/article/details/132949925