MySQL的儲存過程例子

2021-08-23 13:42:07 字數 704 閱讀 8158

create procedure update_article_htmlurl() // 建立乙個名字為update_article_htmlurl的儲存過程

begin //開始 declare var_num int; //定義變數var_num 型別為int

declare var_articleid int;//定義變數var_articleid 型別為int

declare var_htmlurl varchar(30);//定義變數var_htmlurl 型別為varchar

set var_num = 1;//設定初始值

set var_articleid = 547;//設定初始值

while var_articleid < 603 do //while迴圈var_articleid < 603的時候一直執行

update article set htmlurl = concat('/news/20090306/',var_num,'/file45.shmtl') where articleid = var_articleid;//執行更新操作 其中concat是合併字串的函式

set var_articleid = var_articleid + 1;//設定自增長

set var_num = var_num + 1;

end while; // 結束while

end; //結束

mysql 儲存過程 例子 MySQL儲存過程例子

索引 index create index idx sname on student sname 4 alter table teacher add index idx tname tname drop index idx sname on student 檢視 view create view v...

mysql 儲存過程例子

size large b 1 迴圈遍歷值 b size drop procedure if exists doit delimiter表示以 結束編譯 delimiter create procedure doit in parameter integer begin declare v1 int ...

mysql儲存過程小例子

drop procedure if exists customview logs pro delimiter create procedure customview logs pro in counts bigint begin declare i bigint default 1 declare ...