一个sql的存储过程的简单示例

创建一个personinfo表

create table PersonInfo 
(
   personId             varchar(10)                    not null,
   password             varchar(30)                    not null,
   version              numeric                        null,
   constraint PK_PERSONINFO primary key clustered (personId)
);
然后我想为这个表添加1000条测试数据
create PROCEDURE demo()
begin
DECLARE id INT ;
set id=0;
add_loop : LOOP
set id=id+1;
if id<=1000
then insert into personinfo values(id+"","sdadsd",0);
ELSE
LEAVE add_loop;
end if;
end loop add_loop;
end ;

call demo()

以上就是一个简单存储过程的创建并调用(mysql不区分大小写)

具体或复杂用法请参考《Mysql从零开始学习》。



猜你喜欢

转载自blog.csdn.net/fsgsggd/article/details/79821174