当前位置:网站首页>Know MySQL database

Know MySQL database

2022-07-06 01:58:00 Crazy Stuka

Basic concepts of database

data (Data)
A symbolic record of things
Including digital , written words 、 graphics 、 Images 、 voice 、 File records, etc “ Record ” Forms are stored in a unified format

surface

Organize different records together to store specific data

database

Set of tables , It's a warehouse for storing data
The interrelated data sets stored in a certain way are organized according to the data structure 、 Warehouse for storing and managing data


Database management system (DBMS)

Is to achieve effective organization of database resources 、 System software for management and access

Database system

It's a human computer system , By hardware 、OS、 database 、DBMS、 Application software and database users
Users can chant DBMS Or the application program operates the database


Introduction to today's mainstream databases

SQL Server

Microsoft products , oriented Windows operating system , Simple , Easy to use

 Insert picture description here

Oracle

Oracle products , For all mainstream platforms , large , Security , perfect

 Insert picture description here

DB2

IBM The products of the company

For all mainstream platforms

large , Security , perfect

 Insert picture description here

MySQL

Oracle buys , free , Open source , Small volume

 Insert picture description here


relational database

A relational database system is a database system based on a relational model
The data structure of relational model uses two-dimensional data table which is easy to understand

The relational model can be simply “ Entity - Relationship ”(E-R) It is shown in the figure E-R The figure contains the entity ( Data objects )、 Three elements of relationship and attribute

 Insert picture description here

Entity

Also known as instances , Corresponding to... That can be distinguished from other objects in the real world “ event ” or “ thing ”
Such as bank customers 、 Bank accounts, etc

attribute

A property of an entity , An entity can have multiple properties

Such as “ Bank customers ” Each entity in the entity set has a name 、 address 、 Phone and other attributes

contact

The correspondence between entity sets is called connection , Also known as relationships, such as between bank customers and bank accounts “ savings ” The relationship between

The collection of all entities and their relationships constitutes a relational database

The storage structure of relational database is two-dimensional table , In every two-dimensional table , Each line is called a record , Information used to describe an object , Each column is called a field , Used to describe an attribute of an object


MySQL Database introduction

A popular open source relational database
Oracle Our products
comply with GPL agreement , It can be used and modified free of charge

characteristic
Performance is remarkable 、 Stable service
Open source 、 No copyright restrictions 、 Low cost multithreading 、 Multi user
be based on C/S( client / The server ) framework , Safe and reliable

MySQL Business and community

MySQL The commercial version is made up of MySQL AB The company is responsible for the development and maintenance of , You need to pay to use
MySQL The Community Edition is made up of MySQL developer 、 Fans work together to develop and maintain , Free to use

Difference between them
The organization, management and testing of the commercial version are more strict , It will be more stable than the community version, and the commercial version does not comply GPL, Community compliance GPL Free to use
The commercial version is available 7*24 Hours of service , The community edition does not


MySQL Product camp

The first camp :5.0-5.1 camp , It can be said to be the continuation of early products
The second camp :5.4-5.7 camp , Integrated MySQL AB company 、 Storage engines developed by communities and third-party companies , To improve performance
The third camp :6.0-7.1 camp , Namely MySQL Cluster edition , It is developed to meet the needs of database cluster in the new era

Download url
http://www.dev.mysql.com/downloads


MySQL Database management

 Insert picture description here

Common data types

int: integer 

float: Single precision floating point     4 byte 32 position 

double: Double precision floating point    8 byte 64 position 

char: Fixed length character types 

varchar: Variable length character types 

text: Text 

image: picture 

decimal(5,2):5 A valid length number , After the decimal point is 2 position 

Check the database structure

1. View the current database

[[email protected] ~]# mysql -u root -p

mysql> show databases;

 Insert picture description here

2. View... In the current database mysql database , How to check

mysql> use mysql;
mysql> show tables;

 Insert picture description here

3. see mysql In the library user surface . How to let me check

mysql> describe user;

 Insert picture description here

4. How not to switch , see mysql library

 Insert picture description here

5. How not to switch , see mysql In the library user Table structure

 Insert picture description here

How to create databases and tables

 Insert picture description here

How to delete tables in a database and delete a database

( High risk orders in the production environment ! No matter what, you can't delete the database and run away If it's light, you'll lose money , Or go to jail )

drop table  Table name ;
drop database  Library name ;

Manage data records in tables

1. Insert a new data record into the data table

 Insert picture description here

or

 Insert picture description here


select Query usage

How to query serial number 3 The information of this line

 Insert picture description here

How to query the first two lines

 Insert picture description here

Or use combination limit Order to inquire

 Insert picture description here

combination limit Only query the third and fourth lines

 Insert picture description here

How to make the table display vertically

 Insert picture description here

 Insert picture description here


change update

How to put the second line of the sequence aa Change the age to 28

 Insert picture description here

How to modify the age and description in the second line with one command ?

 Insert picture description here

How to delete The third line cc

 Insert picture description here


How to operate the table structure

Modify the name of the table

 Insert picture description here

How to delete a field

 Insert picture description here

How will it be? Age Field set back And set the default value to Age Unknown

 Insert picture description here

How to integrate ‘ name ’ Field Change it to name And No repetition Cannot be empty

 Insert picture description here

原网站

版权声明
本文为[Crazy Stuka]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202140053181727.html