当前位置:网站首页>[note] May 23, 2022 MySQL
[note] May 23, 2022 MySQL
2022-06-30 03:39:00 【Sprite. Nym】
1. Relational database
1.1 Data persistence
Save data to a storage medium that can store data for a long time , In case of power failure, data will not be lost .
1.2 The history of database development
Mesh database 、 Hierarchical database 、 relational database 、NoSQL database 、NewSQL database .
1.3 Relational database features
(1) Theoretical basis : Relational algebra ( Relationship between operation 、 Set theory 、 First order predicate logic ).
(2) Concrete representation : Use two-dimensional table ( There are rows and columns ) Organization data .
(3) programing language : Structured query language (SQL).
a. DDL: Data definition language
b. DML: Data operation language
c. DQL: Data query language
d. DCL: Data control language
1.4 ER Model ( Entity relationship model ) And conceptual model diagram
ER Model , Its full name is Entity relationship model (Entity-Relationship Model), Proposed by Chinese American computer scientist Mr. Chen Pinshan , It is a high-level scanning method of conceptual data model , As shown in the figure below .
1.5 Relational database products
(1)Oracle - At present, the most widely used database management system in the world , As a general database system , It has complete data management function ; As a relational database , It is a product of complete relationship ; As a distributed database , It realizes the function of distributed processing . stay Oracle Abreast of the times 12c In the version , It also introduces a multi tenant Architecture , Using this architecture, you can easily deploy and manage the database cloud .
(2)DB2 - IBM company-developed 、 Mainly operated in Unix( Include IBM Homemade AIX)、Linux、 as well as Windows Relational database products of server version and other systems .DB2 It has a long history and is considered to be the first to use SQL Database products , It has more powerful business intelligence functions .
(3)SQL Server - from Microsoft Develop and promote relational database products , It was originally applied to the data management of small and medium-sized enterprises , But in recent years, its application scope has expanded , Some large enterprises and even multinational corporations have begun to build their own data management systems based on it .
(4)MySQL - MySQL It's open source , Anyone can be in GPL(General Public License) Download and modify it according to the needs of personalization .MySQL Because of its speed 、 Reliability and adaptability .
(5)PostgreSQL - stay BSD Open source relational database products issued under license .
2. install MySQL
(1) from Official website Download installation package
(2) Follow the installation wizard to install 
![[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-WjRqM1nC-1653286730908)(C:\Users\HP\AppData\Roaming\Typora\typora-user-images\image-20220523112632425.png)]](/img/13/e15ac3106e089f3d5a8340932f768a.png)








(3) Verify that the installation was successful and if the installation of section 5 What if the step report is wrong :


3. Use MySQL
(1) Show all character sets : show character set;
(2) open MySQL And enter the password , Show Welcome The successful [ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-453Tr6Ru-1653297164446)(file:///C:\Users\HP\Documents\Tencent Files\583882690\Image\Group2{%\I9{%I9L52L6U[G35_I6AWP6Y7.jpg)]
(3) Display database :show databases;
(4) Switch database :use Database name ;
(5) Display the tables under the database :show tables;
3.1 DDL
Full name Data Definition Language. Carry out construction 、 Delete 、 Change operation . key word :create/drop/alter.
(1) Create a database and specify the default character set :create database Database name default character set utf8mb4;
explain 1:utf8 Said the use of utf-8 Encoding mode ;mb4 Indicates maximum support for 4 Byte character .
explain 2:MySQL8 The default character set is utf8mb4, but MySQL5 The default character set is latin1, So add utf8mb4 To ensure downward compatibility .
(2) Delete database :drop database if exists school;
(3) Create a 2D table :
RIGHT Example:
create table tb_student
(
stu_id int comment ' Student number ',
stu_name varchar(4) not null comment ' full name ',
stu_sex boolean default 1 comment ' Gender ',
stu_birth date comment ' Date of birth ',
primary key (stu_id)
) engine=innodb comment ' Student list ';
explain :varchar() The parentheses indicate the maximum length of the string ;stu_sex It can also be set to char(1);primary key Indicates adding a primary key constraint , Need unique keys ;engine=innodb Is setting up the engine , It's for downward compatibility
appendix : Common data types :
Integers :integer/int(4 byte )/tinyint(1 byte )/smallint(2 byte )/bigint(8 byte )
int Value range of :-231~231-1
int unsigned Value range of :0~2^32-1( Don't add... When subtracting unsigned)
decimal :decimal(10,2) Expressing common ownership 10 Significant digits , There are at most after the decimal point 2 position
date :date/time/datetime. notes :timestamp( Time stamp ,2038 The annual meeting overflowed , It is not recommended to use )
Text :varchar. notes :char comparison varchar No advantage , Not recommended for use
(4) View table structure :desc tb_student;
(5) Delete 2D table :drop table if exists tb_student;
(6) Modify the 2D table :
a. Add a column
alter table tb_student add column stu_addr varchar(100) default '';
alter table tb_student add column tel varchar(20) not null;
b. Delete a column
alter table tb_student drop column tel;
c. Modify a column
alter table tb_student change column stu_sex stu_gender boolean default 1;
alter table tb_student modify column stu_sex char(1) default 'M';
notes : Change your name to change, A new data type must be added later ; Only change the data type to use modify.
d. Adding constraints
alter table tb_student add constraint primary key (stu_id);
e. Change the name of the table ( Do not easily change the names of libraries and tables )
alter table tb_student rename to ...;
appendix : Copy a table :
边栏推荐
- December2020 - true questions and analysis of C language (Level 2) in the youth level examination of the Electronic Society
- [qt] qmap usage details
- C#【高级篇】 C# 匿名方法【待补充Lambda表达式。。。】
- 将DataBinding整合到Activity/Fragment的一种极简方式
- Global and Chinese market for sensor screwdrivers 2022-2028: Research Report on technology, participants, trends, market size and share
- MySQL performance optimization (5): principle and implementation of master-slave synchronization
- Redis中的SDS理解
- Personal PC installation software
- General paging (2)
- Hash design and memory saving data structure design in redis
猜你喜欢

Litjson parses the generated JSON file and reads the dictionary in the JSON file

华为云原生——数据开发与DataFactory

Use of custom MVC

hudi记录

Realization of BFS in C language by storing adjacency matrix of graph

1150_ Makefile learning_ Duplicate name target processing in makefile

Hisense A7 ink screen mobile phone cannot be started
![[wechat applet] how did the conditional rendering list render work?](/img/db/4e79279272b75759cdc8d6f31950f1.png)
[wechat applet] how did the conditional rendering list render work?

An article to get you started VIM

11: I came out at 11:04 after the interview. What I asked was really too
随机推荐
Chapter 2 control structure and function (programming problem)
【笔记】2022.6.7 数据分析概论
ZABBIX trigger explanation
第2章 控制结构和函数(编程题)
Neo4j---性能优化
Neo4j--- performance optimization
1148_ Makefile learning_ Targets, variables, and wildcards in makefile
Is the largest layoff and salary cut on the internet coming?
Principle of device driver
Openssl3.0 learning 22 provider decoder
Use common fileUpload to upload files
Implementation of property management system with ssm+ wechat applet
JS cross reference
How do college students make money by programming| My way to make money in College
共124篇!墨天轮“高可用架构”干货文档分享(含Oracle、MySQL、PG)
Redis中的SDS理解
How to view Tencent's 2022 school recruitment salary, the total contract of cabbage is 40W?
专升本语文资源整理
Compile a DLL without import table
Arrangement of language resources of upgraded version