实验中经常会遇到需要多条数据的情况就想到了用SQL语句循环生成数据 DROP PROCEDURE if EXISTS test_insert; DELIMITER ;; CREATE PROCEDURE test_insert() BEGIN DECLARE y BIGINT DEFAULT 1; WHILE y<100000 DO INSERT INTO `sshshop`.`product` (`pname`, `market_price`, `shop_price`, `image`, `
双重循环插入 DELIMITER ;; CREATE PROCEDURE test_insert() BEGIN DECLARE a INT DEFAULT 1; DECLARE b TINYINT DEFAULT 1; WHILE (a <= 100) DO -- repeat SET a = a + 1; -- select a; WHILE (b <=20) DO insert into school_sp_mj(school_id,mojor_id,status) values(a,b
一 Oracle 循环插入测试数据 declare maxrecords constant int:=1000; i int :=1; begin for i in 1..maxrecords loop insert into UserInfo(UserID,login,password,firstName,lastName,ISADMINISTRATOR) values(SYS_GUID(),TO_CHAR('9999'+i),'password','fri
--循环插入一年的时间 DROP TABLE #temp CREATE TABLE #temp (date DATETIME); DECLARE @year INT ; WITH a1 AS ( SELECT CAST(RTRIM(@year)+'-01-01' AS DATETIME) date UNION ALL ,date) ,date))=@year ) INSERT #temp SELECT date FROM a1 EXCEPT SELECT date FROM #temp ) --