定义,修改,视图时候别忘记as select中的as
发布日期:2021-05-07 00:53:33 浏览次数:25 分类:原创文章

本文共 1138 字,大约阅读时间需要 3 分钟。

mysql> show create view view_2\G*************************** 1. row ***************************                View: view_2         Create View: CREATE ALGORITHM=MERGE DEFINER=`skip-grants user`@`skip-grants host` SQL SECURITY DEFINER VIEW `view_2` (`a`,`b`,`c`) AS select `student`.`id` AS `id`,`student`.`name_stu` AS `name_stu`,`student`.`address` AS `address` from `student` WITH CASCADED CHECK OPTIONcharacter_set_client: utf8mb4collation_connection: utf8mb4_0900_ai_ci1 row in set (0.00 sec)

 使用alter语句修改视图,执行如下代码,结果出错

mysql> alter algorithm = undefined  view view_2(aa,bb,cc) select student.id,student.name_stu,student.address  from student  with local  check option;ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'select student.id,student.name_stu,student.address  from student  with local  ch' at line 1

自习查找错误,发现少加了一个as,正确代码如下:

mysql> alter algorithm = undefined  view view_2(aa,bb,cc) as select id,name_stu,address  from student  with local  check option;Query OK, 0 rows affected (0.01 sec)

 总结:定义,修改,视图时候别忘记as select中的as

上一篇:【论文泛读02】大数据交通流预测:一种深度学习方法(SAE模型)
下一篇:windows与linux中的路径书写,斜杠、反斜杠用法总结

发表评论

最新留言

感谢大佬
[***.8.128.20]2025年04月02日 00时14分08秒