mysql中的视图创建和修改

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/hai7425/article/details/52033674
1、创建视图
CREATE 
VIEW `NewView`AS 
SELECT
`user`.USER_ID,
`user`.USER_NAME,
department.DEPT_ID,
department.DEPT_NAME
FROM
`user` ,
department
WHERE
`user`.DEPT_ID = department.DEPT_ID ;


2、修改视图

ALTER 
ALGORITHM=UNDEFINED 
DEFINER=`root`@`127.0.0.1` 
SQL SECURITY DEFINER 
VIEW `dept_user` AS 
select `user`.`USER_ID` AS `USER_ID`,`user`.`USER_NAME` AS `USER_NAME`,`department`.`DEPT_ID` AS `DEPT_ID`,`department`.`DEPT_NAME` AS `DEPT_NAME`
from (`user` join `department`)
where (`user`.`DEPT_ID` = `department`.`DEPT_ID`)
ORDER BY
department.DEPT_NO ASC ;



展开阅读全文

没有更多推荐了,返回首页