mysql儲存過程簡單示例

2021-08-03 22:00:13 字數 978 閱讀 3624

create

procedure

testp4

(in a int,in b int,out c int,out d int

)begin

setc = a+b;

select count(attribution) into d from credit_card;

endcall testp4(1,2,@s,@m);

select @s,@m;

mysql大資料量分頁效能優化

select * from product a join (select id from product limit 866613, 20) b on a.id = b.id
給表新增更新時間字段

alter

table

`tablename`

add`updateat`

timestamp

null

onupdate

current_timestamp;

修改秒殺開始結束時間

update seckill.seckill a set a.end_time =  date_sub(now(),interval -2

day) -- 具體可搜尋mysql日期時間函式

簡單觸發器示例

create

trigger lasttime

after

update

on myaccount.credit_card

foreach

rowbegin

update seckill set a=1

where id = new/old.id ;

end;

new是新新增行資料的指代,old是修改前的行資料指代

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...