Home > database >  Mysql trigger new tables
Mysql trigger new tables

Time:09-28

To achieve a after inserting a data to a list, according to insert data, a new table
Delimiter $$

Create the trigger ceate_table
Before the insert on the test
For each row
The begin
The create table new. Tablename as select * from temptable where 1=2;
End $$

Delimiter.
The create complains, want to change the dynamic SQL, but does not support dynamic SQL, MySQL triggers so ever know how to implement this function?

CodePudding user response:

Can not achieve this function, you make a proposal to create table and insert in a stored procedure, each time to call this process,

Reason: the create table belongs to the DDL, DDL cannot be rolled back, and insert/update to DML, DML can be rolled back,

CodePudding user response:

The Execute Immediate 'create table' execution built table statements
Used in the trigger

CodePudding user response:

To perform dynamic, normal can't create table,
  • Related