David Rodrigues
David Rodrigues

Reputation: 12542

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.

Upvotes: 0

Views: 65

Answers (3)

Bohemian
Bohemian

Reputation: 425083

You should not care what mysql does with your query internally.

You should be managing your SQL source in some form of source control, but even if you aren't, you should work with your SQL source (text) files only, then execute them as a script to mysql.

Upvotes: 1

David Rodrigues
David Rodrigues

Reputation: 12542

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'));

Upvotes: 1

Devart
Devart

Reputation: 121952

You cannot avoid it. It is MySQL behavior.

Upvotes: 0

Related Questions