Home  >  Article  >  Database  >  Boolean Education Yan Shiba mysql introductory video material sharing

Boolean Education Yan Shiba mysql introductory video material sharing

巴扎黑
巴扎黑Original
2017-08-30 16:34:361274browse

MySQL is a relational database management system developed by the Swedish MySQL AB company and is currently a product of Oracle. MySQL is one of the most popular relational database management systems. In terms of WEB applications, MySQL is the best RDBMS (Relational Database Management System) application software.

MySQL is a relational database management system. A relational database stores data in different tables instead of placing all data in one large warehouse, which increases speed and flexibility.

The SQL language used by MySQL is the most commonly used standardized language for accessing databases. MySQL software adopts a dual licensing policy and is divided into community version and commercial version. Due to its small size, fast speed, low total cost of ownership, and especially the characteristics of open source, MySQL is generally chosen as the website database for the development of small and medium-sized websites.

"Boolean Education Yan Shiba MySQL Introductory Video Tutorial" is a basic introductory course for MySQL. With the continuous development of MySQL, using MySQL+php to make websites has become a mainstream web development technology. If you want to learn dynamic web design , then it is recommended that you choose php+mysql. This course is designed to help beginners of mysql database get started quickly. If you have needs in this area, then start the journey of learning mysql with us! ! !

Boolean Education Yan Shiba mysql introductory video material sharing

Video playback address: http://www.php.cn/course/195.html

The teacher’s teaching style :

Teachers’ lectures are simple and easy to understand, clear in structure, analyzed layer by layer, interlocking, rigorous in argumentation, and rigorous in structure. They use the logical power of thinking to attract students’ attention and use reason to control the classroom teaching process. By listening to the teacher's lectures, students not only learn knowledge, but also receive thinking training, and are also influenced and infected by the teacher's rigorous academic attitude.

The more difficult point in this video is the trigger:

MySQL includes support for triggers. A trigger is a database object related to table operations. When a specified event occurs on the table where the trigger is located, the object will be called, that is, the operation event of the table triggers the execution of the trigger on the table.

Create trigger
In MySQL, the syntax for creating a trigger is as follows:

The code is as follows:

CREATE TRIGGER trigger_name
trigger_time
trigger_event ON tbl_name
FOR EACH ROW
trigger_stmt

Among them:

trigger_name: identifies the trigger The name of the trigger is specified by the user;
trigger_time: identifies the triggering time, the value is BEFORE or AFTER;
trigger_event: identifies the trigger event, the value is INSERT, UPDATE or DELETE;
tbl_name: identifies the creation trigger The table name, that is, on which table the trigger is created;
trigger_stmt: Trigger program body, which can be a SQL statement, or multiple statements contained in BEGIN and END.

It can be seen that 6 types of triggers can be created, namely: BEFORE INSERT, BEFORE UPDATE, BEFORE DELETE, AFTER INSERT, AFTER UPDATE, and AFTER DELETE.

Another limitation is that you cannot create two triggers of the same type on a table at the same time, so a maximum of 6 triggers can be created on a table.

trigger_event Detailed explanation
MySQL In addition to defining the basic operations of INSERT, UPDATE, and DELETE, it also defines the LOAD DATA and REPLACE statements. These two statements can also cause the triggering of the above 6 types of triggers. .

The LOAD DATA statement is used to load a file into a data table, which is equivalent to a series of INSERT operations.

The REPLACE statement is generally very similar to the INSERT statement, except that when there is a primary key or unique index in the table, if the inserted data is consistent with the original primary key or unique index, the original data will be deleted first. Then add a new piece of data, that is, a REPLACE statement is sometimes equivalent to one.

The INSERT statement is sometimes equivalent to a DELETE statement plus an INSERT statement.

INSERT type trigger: The trigger is activated when a certain row is inserted, which may be triggered by INSERT, LOAD DATA, and REPLACE statements;
UPDATE type trigger: The trigger is activated when a certain row is changed, which may be triggered by the UPDATE statement. Trigger;
DELETE trigger: The trigger is activated when a row is deleted, and may be triggered by DELETE and REPLACE statements.

BEGIN … END Detailed explanation
In MySQL, the syntax of the BEGIN … END statement is:

BEGIN
[statement_list]
END

Among them, statement_list represents a list of one or more statements, and each statement in the list All must end with a semicolon (;).
In MySQL, the semicolon is the identifier of the end of the statement. When encountering a semicolon, it means that the statement has ended and MySQL can start execution. Therefore, the interpreter starts execution after encountering the semicolon in statement_list, and then reports an error because no END matching BEGIN is found.

The DELIMITER command will be used at this time (DELIMITER is the delimiter, the meaning of the separator). It is a command and does not require an end-of-statement identifier. The syntax is:
DELIMITER new_delemiter
new_delemiter can be set to 1 or more length symbols, the default is semicolon (;), we can change it to other symbols, such as $:
DELIMITER $
The statement after this ends with a semicolon, explanation The processor will not respond. Only when $ is encountered, the statement is considered to have ended. Note that after using it, we should remember to modify it back.

The above is the detailed content of Boolean Education Yan Shiba mysql introductory video material sharing. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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