Article Directory
what is a database
You can use files to store data. Why do you need a database? File storage has the following disadvantages:
File security issues
Files are not conducive to data query and management
Files are not conducive to storing massive data
Files are inconvenient to control in the program
Database storage medium:
disk
memory
In order to solve the above problems, experts have designed something more conducive to managing data - database, which can manage data more effectively
mainstream database
SQL Sever: Microsoft's product, the favorite of .Net programmers, medium and large projects.
Oracle: Oracle products are suitable for large-scale projects, complex business logic, and concurrency are generally not as good as MySQL.
MySQL : The most popular database in the world, belonging to Oracle, has good concurrency and is not suitable for complex business. Mainly used in e-
commerce, SNS, forums. Good for simple SQL processing.
PostgreSQL : A relational database developed by the Computer Department of the University of California, Berkeley, whether it is for private, commercial, or academic research
use, it can be used, modified, and distributed for free.
SQLite: It is a lightweight database, a relational database management system that complies with ACID, and it is contained in a relatively small C library. Its design target is embedded, and it has been used in many embedded products. It occupies very low resources. In embedded devices, only a few hundred K of memory may be enough.
H2: It is an embedded database developed in Java, which itself is just a class library, which can be directly embedded into the application project
mysql is a set of network programs that provide us with data access services
A database generally refers to data organized in a specific structure stored on disk or in memory—a set of database solutions that will be stored on disk in the future
Database service - mysqld
General files do provide data storage functions, but files do not provide very good data management capabilities (user perspective)
The essence of the database: a set of solutions for storing data content, you give me the fields or requirements, and I will just give you the results.
storage solutions.
see database
- Log in
mysql -h 127.0.0.1 -P 3306 -u root - p
-h: Specifies to log in to the host where the mysql service is deployed
-P: Specify the port number to be accessed (this can be modified)
-u: Specifies the user logged in (default is root)
-p: Specify the password to be entered, when the password is entered, it will not be echoed
1.mysql is the client of the database service
2.mysqld is the server side of the database service
3. The essence of mysql: a network service based on C (mysql) S (mysqld) mode
Port number 3306 based on tcp protocol
Use mysql to create a database, create a table structure, insert some data , and compare how mysql behaves in Linux.
Multiple helloworld files
1. Establish a database, which is essentially a directory under Linux
Create a table:
Select database: use helloworld;
Create a table: create table student
To create a table in the database, the essence is to create the corresponding file under Linux
Who did this job? Actually mysqld does it for us.
The essence of the database is actually a file! ! It's just that these files are not directly operated by the programmer, but are operated by the database service for us
Relationships among servers, databases, and tables
Server, database, table relationship
The so-called installation of a database server is just a database management system program installed on the machine. This management program can manage multiple databases. Generally, developers will create a database for each application. In order to save the data of the entities in the application, multiple tables are generally created in the database to save the data of the entities in the program. The relationship between database server, database and table is as follows:
client is the mysql client, mysql is the mysqld server, and the rest are collectively referred to as "databases"
DB is a directory under Linux, and the table structure is presented as a binary file under Linux
data logical storage
Stored by row and column, this is logical storage.
MySQL architecture
MySQL is a portable database that runs on almost all current operating systems, such as Unix/Linux, Windows, Mac, and Solaris. Various systems have different underlying implementations, but MySQL can basically guarantee the consistency of the physical architecture on each platform.
SQL classification
DDL (data definition language) data definition language is naturally used to maintain the structure of stored data, representing instructions: create, drop, alter, operation table
DML (data manipulation language) is a data manipulation language used to manipulate data, representing instructions: insert, delete, updata, operating data
- DML is divided into a separate DQL , data query language, representing the command: select
DCL (data Control Language) data control language, mainly responsible for authority management and affairs, representative instructions: grant, revoke, commit
storage engine
The storage engine is: how the database management system stores data, how to index the stored data and how to update and query data and other technical implementation methods.
The core of MySQL is the plug-in storage engine, which supports multiple storage engines
Search engines: show engines;
Storage Engine Comparison
The most commonly used storage engines are InnoDB, MyISAM
The default storage engine is InnoDB