一些实用 sql 语句 复制数据新表 sql语句插入10w条数据

SQL语句
452
0
0
2022-10-07
标签   SQL语句
#数据迁移(复制数据新表 overunder_crown_half,被复制数据老表 overunder_crown_half1)

insert into overunder_crown_half select  * from overunder_crown_half1

#新表复制旧表数据(新表 overunder_crown_half,被复制数据旧表 overunder)

CREATE TABLE overunder_crown_half LIKE overunder 

#sql语句插入10w条数据

delimiter $$

DROP PROCEDURE IF EXISTS insert_current_data_uuid $$

CREATE PROCEDURE insert_current_data_uuid(IN item INTEGER)
BEGIN 
    DECLARE counter INT;
    SET counter = item;
    start transaction; 
    WHILE counter >= 1 DO
        insert into `overunder` (match_id, company_id,chu_odds,chu_big_odds,chu_small_odds,ji_odds,ji_big_odds,ji_small_odds,change_time,is_close_odds,odds_type,created_at,updated_at,time_type)
        values(2025393, '17', '2.50','0.91','0.95','2.50','1.11','0.80','2022-04-25 16:34:38','1','2','2022-04-25 16:34:38','2022-04-25 16:34:38','1');
        SET counter = counter - 1;
    END WHILE;
    commit;
END
$$
call insert_current_data_uuid(100000); #插入的条数