Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Demo: procedure and delimiter
## Runnable code in 5.7.25 CREATE TABLE `y` ( `id` int(11) NOT NULL DEFAULT '0', `no` varchar(32) DEFAULT NULL, `nid` int(11) DEFAULT NULL, `g1` int(11) DEFAULT NULL, `g2` int(11) DEFAULT NULL, KEY `IDX_g1` (`g1`), KEY `IDX_g2` (`g2`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; drop procedure if exists insertLoop; delimiter # create procedure insertLoop () begin declare v_int int default 0; truncate table y; start transaction; while v_int < 200000 do insert into y(id) values(v_int); set v_int = v_int + 1; end while; commit; end # delimiter ; call insertLoop(); select count(*) from y; drop procedure insertLoop; drop table y;
run
|
edit
|
history
|
help
0
sree..
CS
test
Teste
dd
barbato
How to run query to keep maximum 3 rows with the same name
vwall
test
Vidhi