如何“提取” mysql查看对象?
我只想以以下格式转储 mysql 数据库中的视图对象:
CREATE OR REPLACE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v_sample` AS SELECT `a`.`id` AS `id`, `a`.`code` AS `active`, `a`.`title` AS `title` FROM t_test a;
上面的脚本是我曾经遇到过的最佳实践...没有权限问题,例如无法删除临时视图表等
。 我在转储脚本数据库中发现,mysql首先将视图对象视为表,然后将被真实视图替换。
I want to dump only view object from mysql databases in the following format :
CREATE OR REPLACE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v_sample` AS SELECT `a`.`id` AS `id`, `a`.`code` AS `active`, `a`.`title` AS `title` FROM t_test a;
the script above is the best practive i have ever had... no problem with privilege issue like can not drop the temporary view table, etc
Notes :
I found inside the dump script database, that mysql treat the view object as table first then will be replaced by the real view.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要使用 SHOW CREATE VIEW 语句。
You need to use SHOW CREATE VIEW statement.