Verified Commit 4f44f87e authored by Kiryuu Sakuya's avatar Kiryuu Sakuya 🎵
Browse files

Finish No.7

parent 26dc270c
...@@ -69,19 +69,39 @@ FROM ...@@ -69,19 +69,39 @@ FROM
LEFT JOIN sales s ON s.sale_id = e.emp_no; LEFT JOIN sales s ON s.sale_id = e.emp_no;
``` ```
#### 6. 将上述视图中订单号为 10001 的记录的销售总金额改为 6000 #### 6. 将上述视图中订单号为 11035462019090116054034524 的记录的销售总金额改为 66.5
```mysql ```mysql
SHOW FULL CLOUMNS FROM another_view;
UPDATE another_view SET 销售金额="66.5" WHERE 订单号="11035462019090116054034524";
``` ```
#### 7. 给上述视图添加一条记录数据 #### 7. 给上述视图添加一条记录数据
```mysql ```mysql
INSERT INTO another_view (
编码, 姓名, 订单号, 销售金额
) VALUE (
"20002", "马云", "11035462019121200000023834", "1428.57"
);
# 但是我们不能直接向视图插入!要向原表插入!
# 注意约束
SELECT * FROM another_view;
INSERT INTO sale_item (
order_no, prod_id, qty, unit_price, order_date
) VALUE (
"11035462019121200000023834", "T0001", "1", "56.5", "2019-12-12 00:00:00"
);
INSERT INTO sales (
order_no, cust_id, sale_id, tot_amt, order_date, ship_date, invoice_no
) VALUE (
"11035462019121200000023834", "100011", "20002", "56.5", "2019-12-12 00:00:00", "2019-12-13 11:45:22", "34600380"
);
SELECT * FROM another_view;
``` ```
#### 8. 删除上述视图 #### 8. 删除上述视图
```mysql ```mysql
DROP VIEW emp_view;
DROP VIEW another_view; DROP VIEW another_view;
``` ```
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment