Auto commit

This commit is contained in:
smallkun 2025-03-15 23:03:03 +08:00
parent 5f5abd6f79
commit 4e10137543

View File

@ -1,6 +1,6 @@
### 练习一
**1**
![image-20250315225248590](https://yp.smallkun.cn/markdown/image-20250315225248590.png!compress)
```sql
#(1)创建数据库
@ -30,7 +30,7 @@ ALTER TABLE customers RENAME TO customers_info;
ALTER TABLE customers_info DROP c_city;
```
**2**
![image-20250315225304324](https://yp.smallkun.cn/markdown/image-20250315225304324.png!compress)
```sql
#(1)创建表时 添加外键约束并指定外键约束名称
@ -51,6 +51,10 @@ DROP TABLE orders;
### 练习二
![image-20250315225318753](https://yp.smallkun.cn/markdown/image-20250315225318753.png!compress)
![image-20250315225328264](https://yp.smallkun.cn/markdown/image-20250315225328264.png!compress)
```sql
#(1)创建表、插入记录
CREATE TABLE pet(
@ -86,6 +90,10 @@ TRUNCATE pet;
### 练习三
![image-20250315225417117](https://yp.smallkun.cn/markdown/image-20250315225417117.png!compress)
![image-20250315225431297](https://yp.smallkun.cn/markdown/image-20250315225431297.png!compress)
```sql
#1.创建数据库
CREATE DATABASE test_compay DEFAULT CHARACTER SET utf8;
@ -115,24 +123,110 @@ CREATE TABLE salary(
ALTER TABLE salary ADD CONSTRAINT fk_sal_eid FOREIGN KEY(empid)
REFERENCES employee(empid) ON UPDATE CASCADE ON DELETE CASCADE;
#4插入记录
INSERT INTO department()
INSERT INTO department (depid, depname, deinfo)
VALUES
(111, '生产部', NULL),
(222, '销售部', NULL),
(333, '人事部', NULL);
(333, '人事部', NULL),
(444, '财务部', '负责公司财务管理'),
(555, '技术部', '负责技术研发与支持'),
(666, '市场部', '负责市场推广与品牌建设'),
(777, '客服部', '负责客户服务与支持'),
(888, '采购部', '负责公司物资采购'),
(999, '法务部', '负责公司法律事务'),
(1010, '行政部', '负责公司日常行政管理'),
(1011, '研发部', '负责新产品研发'),
(1012, '培训部', '负责员工培训与发展');
INSERT INTO employee()
INSERT INTO employee (empid, name, sex, title, birthday, depid)
VALUES
(1001, '张三', '男', '高级工程师', '1975-1-1', 111),
(1002, '李四', '女', '助工', '1985-1-1', 111),
(1003, '王五', '男', '工程师', '1978-11-11', 222),
(1004, '赵六', '男', '工程师', '1999-1-1', 222);
(1004, '赵六', '男', '工程师', '1999-1-1', 222),
(1005, '陈七', '女', '会计师', '1980-5-15', 444),
(1006, '刘八', '男', '软件工程师', '1990-8-20', 555),
(1007, '孙九', '女', '市场经理', '1985-12-25', 666),
(1008, '周十', '男', '客服专员', '1992-3-10', 777),
(1009, '吴十一', '女', '采购经理', '1988-7-22', 888),
(1010, '郑十二', '男', '法务顾问', '1983-9-30', 999),
(1011, '王十三', '女', '行政助理', '1995-4-18', 1010),
(1012, '李十四', '男', '研发工程师', '1991-11-5', 1011),
(1013, '赵十五', '女', '培训讲师', '1987-6-12', 1012),
(1014, '孙十六', '男', '技术支持', '1993-2-14', 555),
(1015, '杨十七', '女', '销售代表', '1994-8-8', 222);
INSERT INTO salary()
INSERT INTO salary (empid, basesalary, titleSalary, decuction)
VALUES
(1001, 2200, 1100, 200),
(1002, 1200, 200, NULL),
(1003, 2900, 700, 200),
(1004, 1950, 700, 150);
(1004, 1950, 700, 150),
(1005, 2500, 800, 100),
(1006, 3000, 1200, 250),
(1007, 2800, 1000, 200),
(1008, 1800, 300, 50),
(1009, 3200, 900, 300),
(1010, 3500, 1000, 400),
(1011, 2000, 400, 100),
(1012, 3100, 1100, 200),
(1013, 2700, 800, 150),
(1014, 2300, 700, 100),
(1015, 2600, 600, 200);
```
![image-20250315225441802](https://yp.smallkun.cn/markdown/image-20250315225441802.png!compress)
### 练习四
![image-20250315225803115](https://yp.smallkun.cn/markdown/image-20250315225803115.png!compress)
![image-20250315225818026](https://yp.smallkun.cn/markdown/image-20250315225818026.png!compress)
```sql
```
![image-20250315225829272](https://yp.smallkun.cn/markdown/image-20250315225829272.png!compress)
```sql
```
### 练习五
![image-20250315230015174](https://yp.smallkun.cn/markdown/image-20250315230015174.png!compress)
```sql
```
![image-20250315230025538](https://yp.smallkun.cn/markdown/image-20250315230025538.png!compress)
```sql
```
### 练习六
![image-20250315230057816](https://yp.smallkun.cn/markdown/image-20250315230057816.png!compress)
```sql
```
### 练习七
![image-20250315230113710](https://yp.smallkun.cn/markdown/image-20250315230113710.png!compress)
![image-20250315230128412](https://yp.smallkun.cn/markdown/image-20250315230128412.png!compress)
```sql
```
### 练习八
![image-20250315230214156](https://yp.smallkun.cn/markdown/image-20250315230214156.png!compress)
![image-20250315230227129](https://yp.smallkun.cn/markdown/image-20250315230227129.png!compress)
```sql
```