开发者

how to "extract" mysql view object?

开发者 https://www.devze.com 2023-03-06 11:38 出处:网络
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

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`开发者_Python百科,
  `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.


You need to use SHOW CREATE VIEW statement.

SHOW CREATE VIEW v_sample
0

精彩评论

暂无评论...
验证码 换一张
取 消