首页 > 代码库 > Mysql创建视图,生成存储过程

Mysql创建视图,生成存储过程

-- select * from (SELECT nid from part where nid > 2) as A 
-- create view V1 AS 

-- create view V1 AS #创建视图
-- select man_to_woman.nid,man.name as mname,woman.name as wname from man_to_woman
-- LEFT JOIN man ON man_to_woman.man_id = man.nid
-- LEFT JOIN woman on man_to_woman.woman_id = woman.nid
-- where man.name = ‘duyanqi‘

delimiter \\  #声明以\\为语句结束符(默认;分号结束)
drop PROCEDURE if EXISTS proc_p1 \CREATE PROCEDURE proc_p1(in i1 INT)#生成存储过程,获取一个变量i1
BEGIN
-- SELECT * FROM man;
DECLARE d1 int;#声明变量
DECLARE d2 int DEFAULT 3;
set d1 = i1 + d2;
SELECT * FROM man_to_woman WHERE nid > d1;
END \delimiter ;#将默认的;更改回来


call proc_p1(1);#调用存储过程

#drop procedure proc_p1;#删除存储过程

  

Mysql创建视图,生成存储过程