mysql——批量插入數據


要測試一下新功能,需要測試環境下的數據庫有大量的數據,一個個插入顯然不現實,需要了解一下存儲過程

https://www.cnblogs.com/endtel/p/5407455.html

Navicat中左上角新建一個函數,選擇過程

BEGIN
    DECLARE i int;
    DECLARE id int;
  set i=LAST_INSERT_ID();
    SET id=1200;
  WHILE i<200 DO
    INSERT INTO app_server(id, appname, cname, serverIp, status, hostname, kernel, 
      jdk, environment, server, serverType, intranet, dc, updateTime, createTime, 
      version, appServerGroup, scope, diskInfo, jvmInfo, memorySize, ethernetInfo, cpuCores)
            VALUES(id, 'test-name', 'test-cname',CONCAT('t_5', i), 1, 'test-hostname', 'test-kernel', 
            'test-jdk', 'test-env', 'test-server', 'st-serverType', 0, 2, '2019-04-14 17:32:07', 
            '2018-07-18 18:45:25', '2.3.3', 'test-appServerGroup', 'outer', 
            '/:50G,/dev:16G,/dev/shm:16G,/run:16G,/sys/fs/cgroup:16G,/data:296G,/boot:497M,/home:48G', 
            'cp./jmxmon.jarcom.stephan.tof.jmxmon.JMXMonitor12', 
            '00:03.0 Ethernet controller: Red Hat', 'Inc Virtio network device', 8);
    SET i=i+1;
    SET id=id+1;
    END
    WHILE;
END

以上過程實現了插入200條記錄


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM