♥️Author : Xiao Liu at Station C
♥️Personal homepage: Xiao Liu's homepage
♥️ Share cloud computing network operation and maintenance classroom notes every day, hard work may not necessarily pay off, but there will be gains, come on! Work hard together for a better life!
♥️The tree is thousands of feet tall, and the fallen leaves return to the roots. Life is not easy, but the true love in the world
foreword
Don't care too much about what others think of you, be yourself, do your own thing well, and walk your own path. Living in the eyes of others is the saddest thing in the world.
Table of contents
1). Query all tables in the current database
2). View the specified table structure
3). Query the table creation statement of the specified table
MySQL
ySQL is a relational database management system developed by the Swedish company MySQL AB , which is a product of Oracle . MySQL is one of the most popular relational database management systems . In terms of WEB applications, MySQL is one of the best RDBMS (Relational Database Management System, relational database management system ) application software.
MySQL is a relational database management system. Relational databases store data in different tables instead of putting all data in one big warehouse, which increases speed and improves flexibility.
The SQL language used by MySQL is the most commonly used standardized language for accessing databases. MySQL software adopts a dual authorization policy, which is divided into community edition and commercial edition . Because of its small size, fast speed, low overall cost of ownership, especially the open source feature, MySQL is generally chosen as the website for the development of small, medium and large websites. database .
table operation
1). Query all tables in the current database
1 show tables;
use sys;
show tables;
2). View the specified table structure
desc 表名 ;
3). Query the table creation statement of the specified table
show create table 表名 ; 1
4). Create a table structure
1 CREATE TABLE 表名(
2 字段1 字段1类型 [ COMMENT 字段1注释 ],
3 字段2 字段2类型 [COMMENT 字段2注释 ],
4 字段3 字段3类型 [COMMENT 字段3注释 ],
5 ......
6 字段n 字段n类型 [COMMENT 字段n注释 ]
7 ) [ COMMENT 表注释 ] ;
Note : parameters within [...] are optional, there is no comma after the last field
1 create table tb_user(
2 id int comment '编号',
3 name varchar(50) comment '姓名',
4 age int comment '年龄',
5 gender varchar(1) comment '性别'
6 ) comment '用户表';
Table Operations - Data Types
In the above table creation statement, we used int and varchar when specifying the data type of the field . So in MySQL , besides the above data types, what other common data types are there? Next , let's introduce the data types of MySQL in detail . There are many data types in MySQL , which are mainly divided into three categories: numeric type, string type, and date time type.
1). Numerical type
1 如:
2 1). 年龄字段 -- 不会出现负数, 而且人的年龄不会太大
3 age tinyint unsigned
4 2). 分数 -- 总分100分, 最多出现一位小数
5 score double(4,1)
2) .String type
1 如:
2 1). 用户名 username ------> 长度不定, 最长不会超过50
3 username varchar(50)
4 2). 性别 gender ---------> 存储值, 不是男,就是女
5 gender char(1)
6 3). 手机号 phone --------> 固定长度为11
7 phone char(11)
3) .Date time type
1 如:
2 1). 生日字段 birthday
3 birthday date
4 2). 创建时间 createtime
5 createtime datetime
Table operation - case
1 create table emp(
2 id int comment '编号',
3 workno varchar(10) comment '工号',
4 name varchar(10) comment '姓名',
5 gender char(1) comment '性别',
6 age tinyint unsigned comment '年龄',
7 idcard char(18) comment '身份证号',
8 entrydate date comment '入职时间'
9 ) comment '员工表';
♥️Following is the driving force for my creation
♥️Like, is the greatest recognition for me
♥️This is Xiaoliu, I am inspiring to do every article well, thank you everyone