开发者

How do you import sql with phpmyadmin that has views?

A developer created a MySQL database which utilizes views. After he left the project, I tri开发者_如何转开发ed to import the database on the production server (shared hosting) using phpMyAdmin and it chokes on the views.

How can I import the SQL with the views?


The views should get dumped as 'create' queries only. The data in the views should NOT be dumped/loaded, as that's just duplicates of whatever's in the underlying tables.


As far as I know, phpMyAdmin does not try to interpret whatever code you type in the SQL command form (or when importing from a file). It just passes the commands to MySQL.

Make sure that your MySQL version is 5.0 or greater, as it only supports views since this version. Post the error message(s).


I can's see an option in phpMyAdmin to export a whole database without the views data. The only workaround i can find is to exclude the 'views' from the table chooser, then export each view seperately. I can then import the main dump - which gives me my tables back, and then import each exported create view sql file. surely, it must be easier than this?


OK - i've resolved this for my situation. reading the PMA bugs pages, it turns out there was a bug in the export routine for the old version of PMA that i was using. Solution: Update PMA. (Quite simple, check your MySQL and PHP are compatibe, get the latest version and copy the files across to your existing phpMyAdmin folder. resart if you like).

For the original question: The export sql file was created incorrectly. Open it in an editor, search for:

INSERT INTO your view name (Fields...) VALUES

and delete this whole block for each incorrectly exported view. Now check you have the latest version of PMA and re-export it before you break something :-)

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜