Create a gist now

Instantly share code, notes, and snippets.

@xaprb /view_source.sql Secret
Created Dec 14, 2013

Extracts a view's source SQL from its .frm file.
SELECT
REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(
REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(
SUBSTRING_INDEX(LOAD_FILE('/var/lib/mysql/world/Oceania.frm'),
'\nsource=', -1),
'\\_','\_'), '\\%','\%'), '\\\\','\\'), '\\Z','\Z'), '\\t','\t'),
'\\r','\r'), '\\n','\n'), '\\b','\b'), '\\\"','\"'), '\\\'','\''),
'\\0','\0')
AS source;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment