创建修改视图
作者:互联网
创建视图
跨数据库创建视图
CREATE VIEW <视图名> AS <SELECT语句>
CREATE VIEW `student_view` AS (
SELECT
a.`id` AS `id`,
a.create_time AS create_time,
a.modify_time AS modify_time,
a.NAME AS NAME,
a.`graduate_at` AS `graduate_at`,
b.`class_name` AS `className`,
b.`teacher` AS `teacher`
FROM
`db1`.`student` a left join `db2`.`class` b
ON a.id = b.student_id
);
修改视图
ALTER VIEW <视图名> AS <SELECT语句>
ALTER VIEW `student_view` AS (
SELECT
a.`id` AS `id`,
a.create_time AS create_time,
a.modify_time AS modify_time,
a.NAME AS NAME,
a.sex AS sex,
a.email AS email,
a.mobile AS mobile,
a.`graduate_at` AS `graduate_at`,
b.`class_name` AS `className`,
b.`teacher` AS `teacher`
FROM
`db1`.`student` a left join `db2`.`class` b
ON a.id = b.student_id
);
标签:创建,create,视图,graduate,修改,student,time,id 来源: https://www.cnblogs.com/colfish/p/15620554.html