字段名 ????????数据类型 ????????主键???????? 外键 ????????非空 ????????唯一 ????????自增
?id ? ?????????????????INT? ? ? ? ? ? ? ?是 ???????????????否 ? ????????是 ?????????????是 ? ????????否
?name ????????ARCHAR(50)? ? 否 ???????????????否? ? ? ? ? ? 是 ????????????否 ????????否
?glass ?????????VARCHAR(50) 否? ? ? ? ? ???????否 ???????????是? ? ? ? ? ? ?否 ????????否
sch 表内容
id name glass
1 xiaommg glass 1
2 xiaojun glass 2
DELIMITER $
CREATE FUNCTION count_sch()
RETURNS INT
DETERMINISTIC
BEGIN
DECLARE count_value INT;
SELECT COUNT(*) INTO count_value FROM sch;
RETURN count_value;
END $
DELIMITER ;
DELIMITER $
create procedure avg_sal(in p1 int,in p2 varchar(50),out avg_salary float)
begin
select avg(sal) into avg_salary from emp
where deptno =p1 and job = p2;
end $