Search code examples
mysqlview

Views are rewritten when I save


When I save a view on MySQL, it is "rewritten". How I can avoid this?

Example, when saving this view:

SELECT * FROM `contas_users`

It is rewritten to:

select `contas_users`.`id` AS `id`,`contas_users`.`username` AS 
`username`,`contas_users`.`password` AS `password` from `contas_users`

I want to avoid this behavior (can be locally only), because I need do some tests, and copy/past to a TXT is too slow and boring.


Solution

  • I found the solution for that, but works only in specific configurations. Here works fine. The original SOURCE is stored on a file .frm of VIEW. See code below:

    SELECT LOAD_FILE(CONCAT(@@GLOBAL.datadir, 'tablename/viewname.frm'));