Home > Database > Mysql Tutorial > Detailed explanation of MySQL basics: data model and SQL language

Detailed explanation of MySQL basics: data model and SQL language

WBOY
Release: 2022-05-30 20:50:39
forward
2274 people have browsed it

This article brings you relevant knowledge about mysql, which mainly introduces issues related to the data model and SQL language, that is, how data is stored in MySQL, and the SQL Let’s take a look at some preliminary understanding of statements. I hope it will be helpful to everyone.

Detailed explanation of MySQL basics: data model and SQL language

Recommended learning: mysql video tutorial

1. Relational database

We know that MySQL is a relationship Relational database management system (RDBMS), and relational database (RDB) is the most widely used database today.

Relational databases, like Excel worksheets, use two-dimensional tables composed of rows and columns to store data. And relational databases use specialized SQL language to manipulate data.

Example: The following is the data of a "Student Table"

Detailed explanation of MySQL basics: data model and SQL language

2. MySQL data model

MySQL is a client/server (C/S) system, which can realize database read and write operations by sending SQL statements from the client to the server.

A MySQL server can have multiple databases, and each database can also have multiple tables. After the client connects to one of the databases, it can operate the tables in the database.

Detailed explanation of MySQL basics: data model and SQL language

3. SQL language

SQL is a language developed to operate relational databases. Although SQL also has standards, in fact SQL is different depending on the RDBMS.

1. Standard SQL

The International Organization for Standardization (ISO) has developed corresponding standards for SQL, and the SQL based on this is called standard SQL.

However, each RDBMS does not fully comply with this standard, which will result in SQL that can be used on Oracle but cannot be used on MySQL, and vice versa. Of course, each RDBMS's support for standard SQL is getting better and better. As long as you learn standard SQL, you can basically write SQL statements in various RDBMS.

2. SQL statement and its types

SQL statement is a statement composed of keywords, table names, column names, etc. Keywords are words whose meaning or usage has been defined. For example: the query keyword is create; which table it comes from, use from, etc.

According to the different types of instructions given to RDBMS, SQL statements can be divided into three categories:

  • DDL (data definition language) is used to create and delete databases, Table and other objects.
  • DML (Data Manipulation Language) is used to query or change records in a table.
  • DCL (Data Control Language) is used to confirm or cancel changes to data in the database, as well as operations on user permissions.

There will be an article later that will introduce these three SQL statements in detail, so I won’t go into details here.

3. Basic grammar rules of SQL

You must abide by some grammar rules when writing SQL statements.

  • SQL statements should end with a semicolon (;): In MySQL, SQL statements are executed one by one, and a semicolon (;) is used to indicate the end of a SQL statement.
  • SQL statements are not case-sensitive for keywords: SQL is not case-sensitive for keywords, including table names and column names.
  • Words need to be separated by spaces or newlines: Words need to be separated by spaces or newlines, otherwise an error will occur.
  • The writing method of constants is fixed: string or date type constants are enclosed in single quotes; numeric types can be written directly.

Recommended learning: mysql video tutorial

The above is the detailed content of Detailed explanation of MySQL basics: data model and SQL language. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:csdn.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template