• mysql存储过程


    文章来源:https://www.cnblogs.com/geaozhang/p/6797357.html

    50G:1500万条记录
    
    # mysql使用:https://www.cnblogs.com/-wenli/p/10352746.html
    
    # 创建数据库 myWeb
    CREATE DATABASE myWeb;
    
    # 创建数据表 person (改表中有4个字段,id,name,email,password)
    CREATE TABLE person(id int(10),name char(20),email char(40),password char(20));
    
    
    # 从person中删除数据
    delete from person where password="KTF";
    
    # 显示支持的字符集
    show variables like '%char%';
    
    # 将某个字段设置为gbk
    alter table person modify  name char(20) character set gbk;
    
    # 创建数据库
    create table person(id int PRIMARY KEY AUTO_INCREMENT,name varchar(20) NOT NULL,email varchar(50) NOT NULL,password varchar(50) NOT NULL); # 创建自增表
    # 删除数据表
    drop table person
    
    # 插入数据到person中
    INSERT INTO person(name,email,password) VALUES("张三","Tian.Zhou@dbappsecurity.com.cn","Zs");
    INSERT INTO person(name,email,password) VALUES("李四","ktf@dbappsecurity.com.cn","Ls");
    INSERT INTO person(name,email,password) VALUES("王二","ShengKai.Chen@dbappsecurity.com.cn","We");
    INSERT INTO person(name,email,password) VALUES("麻子","YongHong.Liu@dbappsecurity.com.cn","Mz");
    
    
    # mysql创建存储过程
    
    delimiter $
    create procedure test_person(in num char(20))
    begin 
      
      declare i int default 6;
      while i <= num do 
          INSERT INTO person VALUES(i,"康廷峰","ktf@dbappsecurity.com.cn","KTF");
          set i = i+1;
      end while;
      
    end $
    
    set @num=20;
    
    #调用存储过程
    call test_person(@num);
    
    # 删除存储过程
    drop procedure name;
    
    注意:
    mysql关键字必须用:`name` 否则mysql会将其判断其为一个函数,提示字段错误;
    //如下字段
    INSERT INTO alarms (action_id,rule_id,happentime,hostname,sip,sport,dip,dport,unique_id,msg_id,`match`,severity_id,tag_id,user_agent,`url`,url_hash,method,post,response_code,request_header,response_header,response_body,country,province,city) values (1,11060006, "2020-12-14 18:35:04","10.20.185.111","10.20.89.119",62394,"10.50.36.222",8002,"6906058750556110861",11060,".mdb",2,1106,"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:83.0) Gecko/20100101 Firefox/83.0","10.20.185.111/1.mdb","e70dcc69844a7ab11a3183103739d8ca","GET","",403,"GET /1.mdb HTTP/1.1Host: 10.20.185.111User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:83.0) Gecko/20100101 Firefox/83.0Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2Accept-Encoding: gzip, deflateUpgrade-Insecure-Requests: 1Cache-Control: max-age=0","HTTP/1.1 403","","LAN","","");
    
    --------------------------
    delimiter $
    create procedure test_person(in num char(20))
    begin 
    
      DECLARE rep_body text DEFAULT 'AASDFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFQWERQWEROHJKJ2435583O47582934HKSDNJF93445345abcdefghijklmnopqrstuvwxyzABCDEFJHIJKLMNOPQRSTUVWXYZ';
      declare i int default 1;
      while i <= num do 
          INSERT INTO alarms (action_id,rule_id,happentime,hostname,sip,sport,dip,dport,unique_id,msg_id,`match`,severity_id,tag_id,user_agent,`url`,url_hash,method,post,response_code,request_header,response_header,response_body,country,province,city) values (1,11060006, "2020-12-14 18:35:04","10.20.185.111","10.20.89.119",62394,"10.50.36.222",8002,"6906058750556110861",11060,".mdb",2,1106,"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:83.0) Gecko/20100101 Firefox/83.0","10.20.185.111/1.mdb","e70dcc69844a7ab11a3183103739d8ca","GET","",403,"GET /1.mdb HTTP/1.1Host: 10.20.185.111User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:83.0) Gecko/20100101 Firefox/83.0Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2Accept-Encoding: gzip, deflateUpgrade-Insecure-Requests: 1Cache-Control: max-age=0","HTTP/1.1 403",rep_body,"LAN","","");
    
          set i = i+1;
      end while;
      
    end $
    
    set @num=20;
    
    #调用存储过程
    call test_person(@num);

  • 相关阅读:
    第一阶段站立会议4
    第一阶段站立会议3
    用户场景描述
    第一阶段站立会议2
    第一阶段站立会议1
    第七周进度条
    第十二周工作总结
    寻找水王
    第十一周工作总结
    构建之法阅读笔记05
  • 原文地址:https://www.cnblogs.com/gufengchen/p/14137989.html
Copyright © 2020-2023  润新知