mysql 创建视图
时间: 2023-11-08 22:05:25 浏览: 71
要创建视图,可以使用以下语法:
```
CREATE VIEW view_name AS
SELECT column1, column2, ...
FROM table_name
WHERE condition;
```
其中,`view_name` 是视图的名称,`column1, column2, ...` 是要选择的列,`table_name` 是要从中选择列的表,`condition` 是可选的筛选条件。
例如,以下语句创建一个名为 `customer_orders` 的视图,该视图显示了客户的订单信息:
```
CREATE VIEW customer_orders AS
SELECT customers.customer_name, orders.order_date, orders.order_amount
FROM customers
INNER JOIN orders ON customers.customer_id = orders.customer_id;
```
阅读全文