Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

create table BATSMAN(

PlayerID varchar(20),
Age int,
Country varchar(15),
Average int,
Highest int,
Centuries int,
Fifties int,
StrikeRate float);

DELIMITER $$

SET @UAge = 50;


SET @LAge = 20;
SET @UCtr = 20;
SET @LCtr = 1;
SET @UAvg = 100;
SET @LAvg = 0;
SET @UHigh = 270;
SET @LHigh = 10;
SET @UCent = 70;
SET @LCent = 0;
SET @UFif = 120;
SET @LFif = 0;
SET @UStrk = 170;
SET @LStrk = 10;

CREATE PROCEDURE insert_data()


BEGIN
DECLARE cnt int DEFAULT 1;
WHILE cnt <= 1000 DO
INSERT INTO BATSMAN
VALUES
(CONCAT('Player - ',CAST(cnt as char)),round(((@UAge - @LAge) * RAND()) +
@LAge,0),CONCAT('Country - ',CAST(round(((@UCtr - @LCtr) * RAND()) + @LCtr,0) as
char)),round(((@UAvg - @LAvg) * RAND()) + @LAvg, 2),round(((@UHigh - @LHigh) *
RAND()) + @LHigh, 0),round(((@UCent - @LCent) * RAND()) + @LCent, 0),round(((@UFif
- @LFif) * RAND()) + @LFif, 0),round(((@UStrk - @LStrk) * RAND()) + @LStrk, 2));
SET cnt = cnt + 1;
END WHILE;
END$$

DELIMITER ;

CALL insert_data();

You might also like