Auto commit
This commit is contained in:
parent
53224e1642
commit
525c0edd1d
@ -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和新的工资作为参数,更新该员工的工资。
|
||||
|
Loading…
x
Reference in New Issue
Block a user