Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I see the Original MySQL used to create a view in phpMyAdmin or other program?

How can I see the original MySQL used to create a view in phpMyAdmin or other program?

I am using phpMyAdmin version 3.3.9.

This post tells how to see the SQL used to create a view but its not the original SQL used. How can I edit a view using phpMyAdmin 3.2.4?

The code returned works, it just doesn't have my original format making it harder to edit. Is there a program to make this easier or do I need to save my original SQL in a text file somewhere?

Example:

SQL Used:

CREATE VIEW `wheel`.`new_view` AS
SELECT
`t_ci_sessions`.`session_id`,
`t_ci_sessions`.`ip_address`,
`t_ci_sessions`.`user_agent`,
`t_ci_sessions`.`last_activity`,
`t_ci_sessions`.`user_data`
FROM `wheel`.`t_ci_sessions`;
SELECT * FROM `wheel`.`ci_sessions`;

SQL phpMyAdmin Returns:

CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `new_view` AS select `t_ci_sessions`.`session_id` AS `session_id`,`t_ci_sessions`.`ip_address` AS `ip_address`,`t_ci_sessions`.`user_agent` AS `user_agent`,`t_ci_sessions`.`last_activity` AS `last_activity`,`t_ci_sessions`.`user_data` AS `user_data` from `t_ci_sessions`
like image 467
zechdc Avatar asked Sep 09 '11 02:09

zechdc


1 Answers

You can't find out the exact SQL used to create a view, but you can see the parsed version of it, which will of course be very close and semantically exactly the same, using this command:

show create view my_view_name;
like image 108
Bohemian Avatar answered Oct 20 '22 00:10

Bohemian