MySQL first knowledge database

⭐️Introduction⭐️

Hello everyone, I am Blue and White Porcelain. Today, I will share with you the basic operation of MySQL. The blogger Xiaobai, if there is any place where the summary is not in place, please point out!

Please add image description

⭐️ What is a database

The database is a software (a type of software) , and the function of this type of software is "管理数据"to implement the internal database software and widely use various data structures.

The database is the management data, in general, it is saved on the hard disk~("持久化存储"的方式)

⭐️ Database Classification

Databases can be roughly divided into relational databases and non- relational databases

关系型数据库(RDBMS): Refers to a database that uses a relational model to organize data. Simply put, a relational model refers to a two-dimensional table model, and a relational database is a data organization composed of two-dimensional tables and the connections between them.
1. Oracle: Oracle product, suitable for large-scale projects, suitable for Complex business logic, such as ERP, OA, etc., charges and prosthetics are expensive 2.
MySQL: belongs to Oracle, not suitable for complex business, open source free
Large projects, fee

非关系型数据库:
SQL-based implementation is not specified. Now it refers more to NoSQL database
1. Based on key-value pair (Key-Value)
2. Based on document type: such as mongodb

Generally, we use MySQL in the process of learning:
MySQL database is a '客户端-服务器'structural program

The party that initiates the request actively is called the party that 客户端
passively receives the request, it is called 服务器
the data sent by the client to the server, it is called "请求"
the data returned by the server to the client, it is called "响应"
MySQL we use about four cases~
insert image description here

insert image description here

⭐️ Operation of the database
⭐️ Show current database

Grammar: show databases;
Note: There is a space between show and databases, which can be one or more, but not without!

insert image description here

⭐️Create database

Grammar : create database 数据库名字;
insert image description here
Note : When some students are just learning MySQL, one of the most likely mistakes is 单词的拼写, so we must pay attention when using MySQL! The meaning of the horizontal line here means that操作成功了!花的时间为0.00 秒~

Here's an addition, if we enter the sql statement and encounter execution failure, there will be an error message. At this time, don't panic. In fact, the error message is the simplest and most basic English, and you only need to be patient to understand it. It's just that some students get scared when they see English~
insert image description here

⭐️ Use database

grammar: use 数据库名;
insert image description here

⭐️ delete database

Grammar: drop database; 数据库名;
insert image description here
Note: This operation is very dangerous!! Once executed successfully! At this time, the data will not be returned with a high probability, (cool, bbq!)

⭐️ Common data types

It mainly includes the following five categories:

Integer types: BIT, BOOL, TINY INT, SMALL INT, MEDIUM INT, INT, BIG INT

Floating point type: FLOAT, DOUBLE, DECIMAL

String types: CHAR, VARCHAR, TINY TEXT, TEXT, MEDIUM TEXT, LONGTEXT, TINY BLOB, BLOB, MEDIUM BLOB, LONG BLOB

Date Type: Date, DateTime, TimeStamp, Time, Year

Other data types: BINARY, VARBINARY, ENUM, SET, Geometry, Point, MultiPoint, LineString, MultiLineString, Polygon, GeometryCollection, etc.

⭐️ Numeric Type

insert image description here
insert image description here

⭐️ String type

insert image description here

⭐️ Date Type

insert image description here

⭐️ Table operations
⭐️ View table

Grammar: show tables;
The premise of this operation must also be先选中数据库~
insert image description here

⭐️ View table structure

grammar: desc 表名;

insert image description here

Notice:insert image description here

⭐️Create table

Syntax: create table 表名;
insert image description here
Note: Before the operation of creating a table,要先选中数据库(use 数据库名;)

If you create a table directly, it cannot be created
insert image description here
. The correct way is to select the database first and then create the table.
insert image description here

⭐️ delete table

grammar: drop table 表名;

insert image description here
After deleting, looking at our table again, we will see that it is gone.
insert image description here
Note:

Deleting a table is also a very dangerous operation! Everyone must be careful, once it is deleted, it may not be restored!!~

Guess you like

Origin blog.csdn.net/Biteht/article/details/123281654