zoukankan      html  css  js  c++  java
  • SQL语句创建表并插入指定N条数据(用于测试)

    CREATE TABLE [dbo].[TestTable](  
        [D_Id] [int] IDENTITY NOT NULL,  
        [D_Name] [varchar](50) NULL,  
        [D_Password] [varchar](32) NULL,  
        [D_Else] [varchar](4000) NULL,  
         CONSTRAINT [PK_TestTable] PRIMARY KEY CLUSTERED   
        ([D_Id] ASC)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]  
    ) ON [PRIMARY]  
    GO  
    DECLARE @d datetime   
    SET @d=getdate()  --计时开始   
    DECLARE @index INT  
    SET @index = 1  
    WHILE @index<5000 
    BEGIN   
    INSERT INTO TestTable(D_Name,D_Password,D_Else)  
    VALUES('名称'+Cast(@index as varchar),'密码测试'+Cast(@index as varchar),'其他'+Cast(@index as varchar))  
    SET @index=@index+1   
    END  
    SELECT [语句执行花费时间(毫秒)]=datediff(ms,@d,getdate()) --计时结束
    /*mysql*/
    DROP PROCEDURE if exists dowhile;
    CREATE PROCEDURE dowhile()
     begin 
      declare i int default 0;
      start transaction;
       while i<50 do
        insert into demo(name) values(concat('s00',i)); 
        set i=i+1; 
       end while; 
      commit;
     end;
    
    CALL dowhile();
    --随机产生26个英文字符 大小写
    SELECT CHAR(97+CEILING(RAND()*25))+ CHAR(65+CEILING(RAND()*25)) AS RandChar

  • 相关阅读:
    页码数求0到9共有多少个
    reduce
    map,filter
    匿名函数 lambda
    递归
    python 切片
    函数
    集合(set)
    python 中random 库的使用
    printf 输出?
  • 原文地址:https://www.cnblogs.com/smartsmile/p/6234453.html
Copyright © 2011-2022 走看看