Triggers, functions, views, stored procedures

Trigger : is a special storage process, it is a code block mysql performed automatically insert, update, delete time.

 the Create  the Trigger trigger_name 

   the After / the before INSERT  / Update / the Delete  ON table name 

   for the each Row 

   the begin 

   SQL statement :( statement triggered a multi-sentence) 

   End

Function : mysql provides many built-in functions, can also customize function (implemented logic programmer need sql)

Create a custom function syntax

   Creation: the CREATE  FUNCTION function name (parameter list)  

        RETURNS return value type of the function body 

   modification: the ALTER  FUNCTION function name [ Characteristic ... ] 

   deleted: DROP  FUNCTION  [ IF EXISTS ] name of the function 

   call: the SELECT function name (parameter list)

View : A view is a virtual table is formed by the query result, the projection is a calculation table obtained by some

create view view_name as select 语句

Stored procedures : a piece of code to encapsulate, when you want to execute this piece of code, can be achieved (after the first compilation called again need to compile again, a high efficiency ratio sql statement execution) by calling the stored procedure

 the Create  Procedure stored procedure name (parameter, parameter, ...) 

   the begin 

   // Code 

   end

This article reprinted from: https: //blog.csdn.net/miaoqinian/article/details/80787592

Guess you like

Origin www.cnblogs.com/ghl666/p/11371909.html