当前位置:网站首页>MySQL - Database Foundation

MySQL - Database Foundation

2022-06-21 10:48:00 Longbow dog learning C

Catalog

One . What is a database

Two . Mainstream databases

3、 ... and . Basic use


One . What is a database

File saving data has the following disadvantages

  • File security issues
  • Files are not conducive to data query and management
  • Files are not conducive to storing large amounts of data
  • It's not convenient to control the file in the program

So in order to solve the above problems , More effective data management , Database came into being .

Two . Mainstream databases

  • SQL Sever: Microsoft products ,.Net Programmer's favorite , Medium and large scale projects .
  • Oracle: Oracle products , Suitable for large projects , Complex business logic , Concurrency is generally not as good as MySQL.
  • MySQL: The world's most popular database , It belongs to Oracle , Good concurrency , Not suitable for complex business . Mainly used in e-commerce ,SNS, Forum . For the simple SQL The treatment effect is good .
  • PostgreSQL : A relational database developed by the computer department of the University of California, Berkeley , Whether it's for private use , commercial , Or for academic research , Free to use , Modify and distribute .
  • SQLite: It's a lightweight database , Abide by ACID Database management system based on RDBMS , It's contained in a relatively small C In the library . Its design goal is embedded , And it has been used in many embedded products , It takes up very low resources , In embedded devices , It may take only a few hundred K That's enough memory .
  • H2: It's a use. Java Development of embedded database , It itself is just a class library , It can be directly embedded into the application project .

3、 ... and . Basic use

You need to install on your own server first , The blogger bought the ECS here +Xshell The use of . Please operate in the station as shown in the figure , You can find a number of installation tutorials , I won't go into details here .

Connect to server  

mysql   -h   127.0.0.1   -P   3306   -u   root   -p

mysql -uroot -p    At present, only the second type can be connected , The problem remains to be solved .

  • If not -h 127.0.0.1 The default is to connect locally
  • If not -P 3306 Connection by default 3306 Port number

The server , database , Table relations

Install the server , Is to install a database management program system program on the machine , You can manage multiple databases , Generally, an application pair uses a database . The corresponding relationship is as follows :

Code operation

// Create database 
creat database base1;

// Using a database 
use base1;

// Create database tables 
creat table person(
    id int,
    name varchar(32),
    gender varchar(2)
);

// Insert data into the table 
insert into person(id,name,gender)values(1,' One person ',' male ');
insert into person(id,name,gender)values(2,' Person two ',' male ');
insert into person(id,name,gender)values(3,' Three people ',' Woman ');

// Query data in table 
select * from person;

SQL classification

DDL【data definition language】 Data definition language , Used to maintain the structure of stored data
For instructions : create, drop, alter

DML【data manipulation language】 Data manipulation language , Used to manipulate data
For instructions : insert,delete,update

DML There is another one in the DQL, Data query language , For instructions : select

DCL【Data Control Language】 Data control language , Mainly responsible for authority management and affairs
For instructions : grant,revoke,commit


Database foundation supplement

Database features

  • Data integrity
  • Good data sharing
  • High data independence

relational database

Bloggers haven't found the answer yet , Just remember that the following three are relational databases .

  • Oracle
  • SQL Server
  • DB2

In the relational model, the logical structure of data is a two-dimensional table

原网站

版权声明
本文为[Longbow dog learning C]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202221438095181.html