Auto commit
This commit is contained in:
parent
5f5abd6f79
commit
4e10137543
@ -1,6 +1,6 @@
|
||||
### 练习一
|
||||
|
||||
**1**
|
||||

|
||||
|
||||
```sql
|
||||
#(1)创建数据库
|
||||
@ -30,7 +30,7 @@ ALTER TABLE customers RENAME TO customers_info;
|
||||
ALTER TABLE customers_info DROP c_city;
|
||||
```
|
||||
|
||||
**2**
|
||||

|
||||
|
||||
```sql
|
||||
#(1)创建表时 添加外键约束并指定外键约束名称
|
||||
@ -51,6 +51,10 @@ DROP TABLE orders;
|
||||
|
||||
### 练习二
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
```sql
|
||||
#(1)创建表、插入记录
|
||||
CREATE TABLE pet(
|
||||
@ -86,6 +90,10 @@ TRUNCATE pet;
|
||||
|
||||
### 练习三
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
```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);
|
||||
```
|
||||
|
||||

|
||||
|
||||
### 练习四
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
```sql
|
||||
```
|
||||
|
||||

|
||||
|
||||
```sql
|
||||
```
|
||||
|
||||
|
||||
|
||||
### 练习五
|
||||
|
||||

|
||||
|
||||
```sql
|
||||
```
|
||||
|
||||

|
||||
|
||||
```sql
|
||||
```
|
||||
|
||||
### 练习六
|
||||
|
||||

|
||||
|
||||
```sql
|
||||
```
|
||||
|
||||
### 练习七
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
```sql
|
||||
```
|
||||
|
||||
### 练习八
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
```sql
|
||||
```
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user