mysql儲存過程的示例

2021-10-22 06:49:36 字數 612 閱讀 7755

drop

procedure

ifexists test;

# 如果存在test儲存過程則刪除

create

procedure test (

)# 建立無參儲存過程,名稱為test

begin

declare i int

;# 申明變數

set i =0;

# 變數賦值

while

i <

10000

do# 結束迴圈的條件: 當i大於10000時跳出while迴圈

insert

into liushui ( fix )

values

('in98');

# 往liushui表新增資料

set i = i +1;

# 迴圈一次,i加1

endwhile

;# 結束while迴圈

-- select * from liushui; # 檢視liushui表資料

end# 結束定義語句

call test ();

# 呼叫儲存過程

mysql儲存過程示例

create procedure pro cancel order in orderid int in userid int out resultstatus int comment 取消商品訂單 begin 引數說明 orderid 訂單id extras 擴充套件記錄 異常處理 declare ...

MySQL儲存過程示例

mysql儲存過程 自定義結束符 delimiter 如果存在同名的儲存過程就刪除 drop procedure if exists praddblack 建立儲存過程 create procedure praddblack in n int begin while n 999 do insert ...

mysql 儲存過程示例

在mysql的test庫中執行如下sql table structure for user drop table if exists user create table user id int 11 unsigned not null auto increment,tinyint 1 not nul...