代碼以下小程序
-- 若是存在testtt_insert同名的存儲過程,刪除 DROP PROCEDURE IF EXISTS testtt_insert; DELIMITER ;; -- 建立一個存儲過程 CREATE PROCEDURE testtt_insert () BEGIN -- 定義一個i,默認爲1 DECLARE i INT DEFAULT 1 ; -- 若是i小於101 WHILE i < 101 DO -- 執行如下語句 INSERT INTO `member_info` ( `id`, `customer_name`, `customer_sex`, `customer_age`, `customer_phone`, `consumer_amount`, `customer_integral`, `customer_experience`, `customer_service_name`, `member_level`, `customer_type`, `application_name`, `application_id`, `province_code`, `province_name`, `city_code`, `city_name`, `region_code`, `region_name`, `detailed_address`, `status`, `created_by`, `created_time`, `updated_by`, `updated_time` ) VALUES ( 0, -- 字符串後加1 CONCAT('曹操', i), '1', 18, -- 數字加1 18826473909+i, 200.00, 10, 10, '劉君', 'A級', '復購', '慕茹姬小程序', 18, '天津市', '天津市', '天津市', '天津市', '河北區', '河北區', '上課的空間', 'A', 1, '2021-03-26 14:35:19', 1, '2021-03-26 14:35:19' ) ; -- 給已定義的變量i賦值 SET i = i + 1 ; END-- 結束while循環 WHILE ; COMMIT ;-- commit提交事務 END;;-- 結束 CALL testtt_insert () ;-- 調用存儲過程