Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- insert into temptable (name) values('abc'),('def');
- select * from temptable;
- id|name
- 1|abc
- 2|def
- auto_increment by 10,
- id|name
- 10|abc
- 20|def
- CREATE TABLE next (next_id int not null);
- INSERT INTO next VALUES(0);
- delimiter |
- CREATE TRIGGER update_id BEFORE INSERT ON temptable
- FOR EACH ROW BEGIN
- SET NEW.id = (SELECT next_id FROM next);
- UPDATE next SET next_id = next_id + 10;
- END;
- |
- delimiter ;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement