General knowledge of the database opening introduction

Introduction

database

Database (DB) refers to a collection of data in a certain format that can be shared by multiple users and independent of the application

Database management system

Database Management System (DBMS) is software used to define and manage data. Currently the more popular database management systems are: Oracle, Mysql, SQL Server, DB2, etc.

Database application

Database Application System (DBAS) is an application developed directly facing the end user based on the database management system, using the syntax of the database management system

Database administrator

Database Administrator (DBA) refers to the person who operates the database management system and is mainly responsible for the operation and maintenance of the database

Database type

After decades of development, various types of databases have emerged. According to the different organizational structures of the data, they are mainly divided into network databases, hierarchical databases, relational databases and non-relational databases. The most common database models at present are: relational database and non-relational database

Relational Database

The relational database model uses simple binary relationships (two-dimensional tables) to represent complex data structures. In this type of database, data operations are basically based on one or more tables, and we can use structured query language (SQL) to operate the database. Relational database is the current mainstream database technology, among which representative database management systems are: Oracle, DB2, SQL Server, Mysql, etc.

Non-relational database NOSQL

NOSQL (Not Only SQL) generally refers to non-relational databases. Relational databases have become inadequate in the ultra-large-scale and high-concurrency web2.0 pure dynamic websites, exposing many insurmountable problems. The NOSQL database was created to solve the challenges brought by multiple data types in large-scale data collections, especially the problems of big data applications. Common non-relational database management systems include Memcached, MongoDB, etc.

Relational Database:

1.Oracle

Oracle database is the world's first relational database that supports SQL language developed by Oracle in the United States. After years of improvement and development, Oracle database has become the most popular database in the world, and it is also the core product of Oracle. .
Oracle database has good openness, can run on all mainstream platforms, and has high performance, high security, and low risk; but its requirements for hardware are very high, management, maintenance and operation are more complicated and expensive, so Generally used in the demand for large databases in banking, finance, insurance and other industries

2.DB2

DB2 is a well-known relational database of IBM. DB2 is impeccable in terms of stability, security, recovery, etc., and can be used from small-scale to large-scale applications, but it is very cumbersome to use and is more suitable for large-scale distributed application systems

3.SQL Server

SQL Server is a relational database developed and promoted by Micrsoft. SQL Server has comprehensive functions and high efficiency. It can be used as a database platform for medium-sized enterprises or units. SQL Server can be closely inherited with Windows operating system, whether it is application development speed or The transaction processing speed of the system can be greatly improved. However, SQL Server can only run under the Windows operating system, there is no openness at all (that is, it cannot be cross-platform, so it has nothing to do with java directly)

4.MYSQL

MySQL is an open source lightweight relational database. The MySQL database uses the most commonly used structured query language (SQL) to manage the database. Since MySQL is developed from the source code, anyone can download it under the General Public License and modify its defects according to personal needs.
Due to the small size, fast speed, low cost, and open source of the MySQL database, it has been It is widely used in small and medium-sized websites on the Internet, and large-scale websites have also begun to use MySQL databases, such as NetEase, Sina, etc.

MySQL basics

Getting started with MySQL

The MySQL database was originally developed by the Swedish company MySQL AB and was acquired by Sun on January 16, 2008. In 2009, Sun was acquired by Oracle. Mysql is currently the most popular open source database management system in the IT industry, and it is also a relational database management system that supports multi-threaded, high-concurrency, and multi-user. The main reasons why MYSQL is favored by people in the industry are as follows:

  1. Development source code
  2. Cross-platform
  3. Lightweight
  4. low cost

MYSQL is divided into community edition and enterprise edition. The community edition is completely free, and the enterprise edition is chargeable.

The main differences between the community edition and the enterprise edition are:

  1. The community version contains all the latest features of MYSQL, while the enterprise version only contains the stable functions. In other words, the community version can be understood as a beta version of the enterprise version.
  2. The official MySQL support service is only for the enterprise version. If the user has a problem with the community version, the MySQL official is not responsible

The SQL language is divided into five parts:

DQL

Data Query Language (DQL): DQL is mainly used for data query. Its basic structure is to use a combination of SELECT clause, FROM clause and WHERE clause to query one or more pieces of data

DML

Data Manipulation Language (DML): DML is mainly used to add, modify and delete data in the database. It mainly includes:

  1. INSERT: increase data
  2. UPDATE: modify data
  3. DELETE: delete data

DDL

Data Definition Language (Data Definition Language, DDL): DDL is mainly used to create, modify, and delete database objects (databases, tables, indexes, views, triggers, stored procedures, and functions). It mainly includes:

  1. CREATE: Create database objects
  2. ALTER: modify database objects
  3. DROP: delete database objects

DCL

Data Control Language (Data Control Language, DCL): DCL is used to grant or revoke access to the database, which mainly includes:

  1. GRANT: Grant users certain permissions
  2. REVOKE: Recover certain permissions granted

TCL

Transaction Control Language (Transaction Control Language, TCL): TCL is used for database transaction management. It mainly includes:

  1. START TRANSACTION: start transaction
  2. COMMIT: Commit the transaction
  3. ROLLBACK: Roll back the transaction
  4. SET TRANSACTION: Set the properties of the transaction

Note: DML and DDL are different

Data manipulation language (insert, update, delete) for the data in the table

The data definition language (create, alter, drop) is for database objects, such as database, table, index, view, storage procedure, and trigger

Introduction and installation of MYSQL

MYSQL service start and stop

method one:

Computer-right click management-service

Way two:

Run
net start service name (start service) through administrator province
net start service name (stop service)

Login and logout of MYSQL service

method one:

Through mysql's own client
only limited to root users

Way two:


Log in through the client that comes with Windows :
mysql [-h host name-P port number] -u username-p password

note:

There must be no spaces between h and host name, p between port number and u and user name, but there must be no spaces between p and password, unless the password comes with a space.

drop out:

exit or ctrl+c

MYSQL common commands

  1. Connect to the database: mysql -uroot -p
  2. View the current database: show databases;
  3. Open the specified library: use library name;
  4. View all tables in the current library: show tables;
  5. View all tables in other libraries: show tables from library name;
  6. Create table: create table indicates (column name column type, column name column type, column name column type)
  7. View table structure: desc table name
  8. Check the server version
    Method 1: Log in to the mysql server
select version();

Method 2: Not logged in to the mysql server

mysql --version

or

mysql   -V
  1. Exit: exit

Guess you like

Origin blog.csdn.net/CSNN2019/article/details/114809214