当前位置:网站首页>MySQL Foundation
MySQL Foundation
2022-07-02 23:30:00 【pengege666】
1. Database related concepts
1.1 Database concept : Warehouse for storing and managing data , Data is organized and stored . database (DataBase, abbreviation DB) Is to store the data on the hard disk , It can achieve the effect of persistent storage .
1.2 Database management system : Large software for managing databases (DataBase Management System, abbreviation DBMS)
explain : After installing the database management system on the computer , You can create a database through the database management system to store data , You can also add, delete, modify and query the data in the database through the system . That's what we talk about MySQL The database is actually MySQL Database management system .
1.3 Common database management system
Oracle: A large database of charges ,Oracle Products of the company
MySQL: Open source free small and medium-sized databases . later Sun The company acquired MySQL, and Sun The company was again Oracle Acquisition
SQL Server:MicroSoft A database of medium-sized companies that charge .C#、.net Such language is often used
PostgreSQL: Open source free small and medium-sized databases
DB2:IBM The company's large charging database products
SQLite: Embedded micro database . Such as : As Android Built in database
MariaDB: Open source free small and medium-sized databases
1.4 SQL
- english :Structured Query Language, abbreviation SQL, Structured query language
- Programming language for operating relational databases
- Define a unified standard for operating all relational databases , have access to SQL Operate all relational database management systems , in the future If other database management systems are used in the work , Use the same SQL To operate .
2.MySQL
2.1 install A little ...
2.2 MySQL Data model
Relational database :
A relational database is a database based on a relational model , In short , Relational database is made up of several pieces that can be connected with each other Two-dimensional table Composed database
Data model :
Summary :
- MySQL You can create multiple databases in , Each database corresponds to a folder on disk
- Multiple tables can be created in each database , Each corresponds to a... On disk frm file
- Each table can store multiple pieces of data , The data will be stored on disk MYD In file
3.SQL
- english :Structured Query Language, abbreviation SQL
- Structured query language , A programming language for operating relational databases
- Define a unified standard for operating all relational databases
- For the same need , There may be some differences in each way of database operation , We call it “ dialect ”
DDL(Data Definition Language) : Data definition language , Used to define database objects : database , surface , Column, etc.
DDL Simple understanding is used to operate the database , Table, etc
DML(Data Manipulation Language) Data operation language , It is used to add, delete and modify the data in the database
DML Simply understand and add, delete and modify the data in the table .
DQL(Data Query Language) Data query language , Used to query the records of tables in the database ( data )
DQL The simple understanding is to query the data . Query the data we want from the database table .
DCL(Data Control Language) Data control language , It is used to define the access rights and security level of the database , And create users
DML The simple understanding is to control the permissions of the database . For example, I let a database table be operated by only one user .
Be careful : The most common thing we will do in the future is DML and DQL , Because the most common operation in our development is data .
DDL
1. Operating the database
1. Query all databases
SHOW DATABASES;
2. Create database
CREATE DATABASE Database name ;
3. Delete database
DROP DATABASE Database name ;
4. Using a database
USE Database name ;
5. View currently used databases
SELECT DATABASE();
2. Operation data sheet
1. Query the names of all tables in the current database
SHOW TABLES;
2. Query table structure
DESC The name of the table ;
3. Create table
CREATE TABLE Table name (
Field name 1 data type 1,
Field name 2 data type 2,
…
Field name n data type n
);
4. Delete table
DROP TABLE Table name ;
5. Modify the name of the table
ALTER TABLE Table name RENAME TO New table name ;
6. Add a column
ALTER TABLE Table name ADD Name data type ;
7. Change data type
ALTER TABLE Table name MODIFY Name New data types ;
8. Change column name and data type
ALTER TABLE Table name CHANGE Name New column names New data types ;
9. Delete column
ALTER TABLE Table name DROP Name ;
DML
DML It mainly increases the data (insert) Delete (delete) Change (update) operation .
1. Add data
1.1 Add data to the specified column
INSERT INTO Table name ( Name 1, Name 2,…) VALUES( value 1, value 2,…);
1.2 Add data to all columns
INSERT INTO Table name VALUES( value 1, value 2,…);
1.3 Batch add data
INSERT INTO Table name ( Name 1, Name 2,…) VALUES( value 1, value 2,…),( value 1, value 2,…),( value 1, value 2,…)…;
2. Modifying data
2.1 Modify table data
UPDATE Table name SET Name 1= value 1, Name 2= value 2,… [WHERE Conditions ] ;
3. Delete data
3.1 Delete data
DELETE FROM Table name [WHERE Conditions ] ;
DQL
SELECT
Field list
FROM
List of table names
WHERE
List of conditions
GROUP BY
Grouping field
HAVING
Conditions after grouping
ORDER BY
Sort field
LIMIT
Paging limit
边栏推荐
- Use the scroll bar of souI when using the real window in souI
- Deep analysis of data storage in memory - C language
- 简述中台的常识
- Use redis to realize self increment serial number
- Cryptographic technology -- key and ssl/tls
- 第三方支付功能测试点【杭州多测师_王sir】【杭州多测师】
- Redis expiration policy +conf record
- What if win11 can't turn off the sticky key? The sticky key is cancelled but it doesn't work. How to solve it
- 密码技术---密钥和SSL/TLS
- Call vs2015 with MATLAB to compile vs Project
猜你喜欢
C MVC creates a view to get rid of the influence of layout
Cryptography -- the mode of block cipher
YOLOX加强特征提取网络Panet分析
理想汽车×OceanBase:当造车新势力遇上数据库新势力
[analysis of STL source code] imitation function (to be supplemented)
Where is the win11 microphone test? Win11 method of testing microphone
Win11自动关机设置在哪?Win11设置自动关机的两种方法
RuntimeError: no valid convolution algorithms available in CuDNN
How difficult is it to be high? AI rolls into the mathematics circle, and the accuracy rate of advanced mathematics examination is 81%!
Interface switching based on pyqt5 toolbar button -2
随机推荐
SQL advanced syntax
What experience is there only one test in the company? Listen to what they say
Why does RTOS system use MPU?
公司里只有一个测试是什么体验?听听他们怎么说吧
ping域名报错unknown host,nslookup/systemd-resolve可以正常解析,ping公网地址通怎么解决?
What can I do after buying a domain name?
PHP get real IP
Deep analysis of data storage in memory - C language
What if win11 can't turn off the sticky key? The sticky key is cancelled but it doesn't work. How to solve it
Cryptographic technology -- key and ssl/tls
Simple square wave generating circuit [51 single chip microcomputer and 8253a]
Go basic data type
How does win11 turn on visual control? Win11 method of turning on visual control
"A good programmer is worth five ordinary programmers!"
php 获取真实ip
Mapper代理开发
密码技术---密钥和SSL/TLS
Temperature measurement and display of 51 single chip microcomputer [simulation]
golang中new与make的区别
@BindsInstance在Dagger2中怎么使用