1. 程式人生 > >mysql 批量構造模擬資料

mysql 批量構造模擬資料

1、建立儲存過程

-- 建立儲存過程
DELIMITER $$ 
create procedure insert_tophatter_record(n int)
begin
declare i int default 0;
set autocommit = 0;
repeat
set i = i + 1;
INSERT INTO `ueb_tophatter_list` (`account`, `sku`, `sku_identifier`, `internal_id`, `category`, `title`, `description`, `condition`, 
`is_multi`, `brand`, `material`, `retail_price`, `cost_basis`, `minimum_bid_amount`, `scheduling_fee_bid`, 
`max_daily_schedules`, `shipping_price`, `shipping_origin`, `weight`, `days_to_fulfill`, 
`days_to_deliver`, `expedited_shipping_price`, `expedited_days_to_deliver`, `buy_one_get_one_price`, 
`primary_image`, `extra_images`, `available_quantity`, `all_images_json`, `ratings_count`, `ratings_average`, 
`created_at`, `updated_at`, `disabled_at`, `deleted_at`, `catalog_only_at`, `created_in`, `created_by`, `updated_in`, 
`updated_by`, `status`, `publish_in`, `publish_data_url`, `error_remark`) 
VALUES ('19951103', 'JM10697', 'JM10697_20181205152406_1217', '18204119', 'Accessories | Bags | Shoulder Bags & Hobos', '24Pcs/Box Triangle Beads Rhinestone Decoration Artificial False Fake Nail Art Tip & Glue', 'Features: \r\nMade of advanced environmental plastic material, which is durable and friendly to your nails and the environment. \r\nGreat for both professional nail specialist and nail art learner. \r\nIt\'s easy to remove for its surface does not stick to the nail gel or acrylic. \r\nThis natural nail art tip is easy to cut, file and apply owing to the perfect length and thickness. \r\nSuitable for nail art with nail polish, UV gel, etc. \r\n \r\nSpecifications: \r\nItem Type: False Nail \r\nMaterial: Plastic \r\nMain Color: As the Picture Shows  \r\nQuantity: 24Pcs/Box \r\nWeight: 28g  \r\nFunction: Nail Art Decoration \r\n \r\nPackage Includes: \r\n1 x 24Pcs/Box of False Nails  \r\n1 x 2g/bottle Glue', 'New', '0', '', '', '0.00', '2.00', '0.00', '0.00', NULL, '2.35', 'China', NULL, '5', '5', '0.00', NULL, '0.00', '/upload/image/Thumb_no_logo/JM14765-01/JM14765-01-2.jpg', '/upload/image/Thumb_no_logo/JM14765-01/JM14765-01-12.jpg|/upload/image/Thumb_no_logo/JM14765-01/JM14765-01-16.jpg', '0', '[{\"thumbnail\":\"https:\\/\\/images.tophatter.com\\/72639e96d55ab4aa79225e2bf2f93897\\/thumbnail.jpg\",\"square\":\"https:\\/\\/images.tophatter.com\\/72639e96d55ab4aa79225e2bf2f93897\\/square.jpg\",\"medium\":\"https:\\/\\/images.tophatter.com\\/72639e96d55ab4aa79225e2bf2f93897\\/medium.jpg\",\"large\":\"https:\\/\\/images.tophatter.com\\/72639e96d55ab4aa79225e2bf2f93897\\/large.jpg\",\"original\":\"https:\\/\\/images.tophatter.com\\/72639e96d55ab4aa79225e2bf2f93897\\/original.jpg\"},{\"thumbnail\":\"https:\\/\\/images.tophatter.com\\/89fd029261288d7e23aac06931238366\\/thumbnail.jpg\",\"square\":\"https:\\/\\/images.tophatter.com\\/89fd029261288d7e23aac06931238366\\/square.jpg\",\"medium\":\"https:\\/\\/images.tophatter.com\\/89fd029261288d7e23aac06931238366\\/medium.jpg\",\"large\":\"https:\\/\\/images.tophatter.com\\/89fd029261288d7e23aac06931238366\\/large.jpg\",\"original\":\"https:\\/\\/images.tophatter.com\\/89fd029261288d7e23aac06931238366\\/original.jpg\"},{\"thumbnail\":\"https:\\/\\/images.tophatter.com\\/7b7b651be4bd666b5750053314477f8e\\/thumbnail.jpg\",\"square\":\"https:\\/\\/images.tophatter.com\\/7b7b651be4bd666b5750053314477f8e\\/square.jpg\",\"medium\":\"https:\\/\\/images.tophatter.com\\/7b7b651be4bd666b5750053314477f8e\\/medium.jpg\",\"large\":\"https:\\/\\/images.tophatter.com\\/7b7b651be4bd666b5750053314477f8e\\/large.jpg\",\"original\":\"https:\\/\\/images.tophatter.com\\/7b7b651be4bd666b5750053314477f8e\\/original.jpg\"}]', '0', NULL, '2018-12-05 15:25:20', '2018-12-05 15:25:20', '0000-00-00 00:00:00', '0000-00-00 00:00:00', NULL, '2018-12-05 10:30:52', '1', '2018-12-05 10:41:49', '1', '1', '2018-12-05 15:24:09', 'log/tophatter/20181205/4.txt', '[http://image-us.bigbuy.win/upload/image/assistant/JM10697/495146dbc52feebf518e3da191443ffc.jpg is not an image]');
until i=n  
end repeat;
commit;
set autocommit = 1;
end $$

2、呼叫

-- 呼叫
call insert_tophatter_record(1000000);

3、檢視儲存過程

-- 檢視儲存過程
show procedure status;

4、刪除儲存過程

-- 刪除儲存過程
drop procedure if exists insert_tophatter_record;

5、其他
1.建立函式的時候要先開啟mysql建立函式功能,預設是關閉的
檢視方式:show variables like ‘%func%’;
開啟方式:set global log_bin_trust_function_creators=1;
2.建立函式和儲存過程的時候,必須在開始和結束位置新增 DELIMITER $$, $$