From 525c0edd1dc25d3e46a7c6db41b43fb7171dbc6d Mon Sep 17 00:00:00 2001 From: smallkun Date: Wed, 19 Mar 2025 19:15:27 +0800 Subject: [PATCH] Auto commit --- 2207/存储过程练习题.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/2207/存储过程练习题.md b/2207/存储过程练习题.md index 70863f0..25c10a3 100644 --- a/2207/存储过程练习题.md +++ b/2207/存储过程练习题.md @@ -148,6 +148,21 @@ INSERT INTO employee (emp_name, salary, hire_date, dept_id, job_id) VALUES 创建一个存储过程 `add_employee`,接受员工姓名、工资、入职日期、部门ID和职位ID作为参数,并将其插入到 `employee` 表中。 +```sql +DELIMITER $$ +DROP PROCEDURE IF EXISTS add_employee; +CREATE PROCEDURE add_employee(IN `name` VARCHAR(100), IN salary DECIMAL(10, 2), IN hire_date DATE, IN dept_id INT, IN job_id INT) +BEGIN + INSERT INTO employee() + VALUES(DEFAULT, `name`, salary, hire_date, dept_id, job_id); +END $$ +DELIMTIER ; + +CALL add_employee('拼好饭', 3000, NOW(), 8, 3); +``` + + + #### 练习题 2: 更新员工工资 创建一个存储过程 `update_employee_salary`,接受员工ID和新的工资作为参数,更新该员工的工资。