MySQL - views : definition changes after saving?
When I create a view in a MySQL database, and save it, the entire code is modified and all code is on 1 line, where it was on multiple lines when I saved it. Also a lot of parenthesis are added to the开发者_开发问答 code. Is this normal?
How can you edit a complex view (with some joins) then afterwards, as it becomes practically unreadable?
You could store the neatly formatted SQL code in a file in your revision control system, alongside the rest of the application code. Then if you ever need to modify a view you can check out the SQL you originally used to create the view, modify it, then run it to recreate the view. The you can commit the modified SQL back to your repository.
As well as preserve the formatting, another advantage of this approach is that you can track changes to your database code, just as you can with ordinary code.
I faced the same problem. although this post is old, i guess it'll help people like us :)
i had this issue when i import my sql. then i realize the exported sql is in the one-line ugly format with so many parenthesis and stuffs. (not readable) instead of the original multilines format typed in navicat
what i did: make multi-lines format in your sql script if u want to import/dumpinq-in your DB. so the default would be the multilines format. my test shows that the definition for view will always revert back to the original format is was dumped when u click save.
You could store the original code for starters. You could also use a tool that will get the view's code from the database and format it for you. I use SQLyog and I find it works very well.
精彩评论