Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Kiryuu Sakuya
Database-school
Commits
4f44f87e
Verified
Commit
4f44f87e
authored
Nov 20, 2019
by
Kiryuu Sakuya
🎵
Browse files
Finish No.7
parent
26dc270c
Changes
1
Hide whitespace changes
Inline
Side-by-side
实验七.md
View file @
4f44f87e
...
...
@@ -69,19 +69,39 @@ FROM
LEFT JOIN sales s ON s.sale_id = e.emp_no;
```
#### 6. 将上述视图中订单号为 1
0001
的记录的销售总金额改为 6
000
#### 6. 将上述视图中订单号为 1
1035462019090116054034524
的记录的销售总金额改为 6
6.5
```
mysql
SHOW FULL CLOUMNS FROM another_view;
UPDATE another_view SET 销售金额="66.5" WHERE 订单号="11035462019090116054034524";
```
#### 7. 给上述视图添加一条记录数据
```
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. 删除上述视图
```
mysql
DROP VIEW emp_view;
DROP VIEW another_view;
```
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment