DECLARE @UCode int;
DECLARE @LCode int
DECLARE @i int
DECLARE @char varchar(255);
DECLARE @Marks varchar(255);
DECLARE @num varchar(255);
SET @Lcode = 1
SET @Ucode = 9999
SET @char = 'abcdfghjklmnpqrstvwxyz'
SET @marks='aeiou'
SET @num='123456789'
SET @i=1
WHILE @i<=200000 BEGIN
insert into test_1(code1,name1,email)
select
ROUND(((@Ucode - @Lcode -1) * RAND() + @Lcode), 0) as code,
SUBSTRING(@char,ABS(CAST(CAST(NewID() AS VARBINARY) AS int)) % LEN(@char) + 1, 2) + SUBSTRING(@marks,ABS(CAST(CAST(NewID() AS VARBINARY) AS int)) % LEN(@marks) + 1, 1) + SUBSTRING(@char,ABS(CAST(CAST(NewID() AS VARBINARY) AS int)) % LEN(@char) + 1, 2) as name1,
SUBSTRING(@char,ABS(CAST(CAST(NewID() AS VARBINARY) AS int)) % LEN(@char) + 1, 2) + SUBSTRING(@marks,ABS(CAST(CAST(NewID() AS VARBINARY) AS int)) % LEN(@marks) + 1, 1) + SUBSTRING(@char,ABS(CAST(CAST(NewID() AS VARBINARY) AS int)) % LEN(@char) + 1, 2) + SUBSTRING(@num,ABS(CAST(CAST(NewID() AS VARBINARY) AS int)) % LEN(@num) + 1, 5) + '@hotmail.com'
SET @i=@i+1
END
use databasename;
drop procedure if exists insert_data;
delimiter $$
create procedure insert_data()
begin
declare i int Default 0 ;
declare random char(20) ;
declare random2 int ;
myloop: loop
set random=conv(floor(rand() * 99999999999999), 20, 36) ;
set random2 =floor(rand() * 100);
insert into a (id,x,y) VALUES (null,random,random2) ;
set i=i+1;
# จำนวน 10000 record
if i=100000 then
leave myloop;
end if;
end loop myloop;
end $$
delimiter ;
call insert_data();
คำค้น SQL:
delimiter $$ CREATE PROCEDURE insert_data( ) BEGIN declare i int Default 0;
MySQL แสดง: เอกสารอ้างอิง
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'delimiter $$
create procedure insert_data()
begin
declare i i' at line 1