DROP TRIGGER insert_trigger; delimiter | CREATE TRIGGER insert_trigger BEFORE INSERT ON airuser FOR EACH ROW BEGIN INSERT INTO airuser_record SET username = NEW.username, edittime=now(), edittype='insert'; END;
SHOW TRIGGERS;
4. 为批量插入编写存储过程:
复制代码 代码如下:
DROP procedure createUsers; delimiter | create procedure createUsers(IN count int) begin declare i int; set i=0; while i<count do insert into airuser set username=concat('user_',i); set i=i+1; end while; end;