Skip to content

Instantly share code, notes, and snippets.

@xaprb
Created December 14, 2013 19:55
Show Gist options
  • Save xaprb/f1695009025bca103087 to your computer and use it in GitHub Desktop.
Save xaprb/f1695009025bca103087 to your computer and use it in GitHub Desktop.
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