snippetsqlMinor
How to retrieve the query I used to create a view?
Viewed 0 times
thecreateusedqueryviewretrievehow
Problem
for my company I created a view which is used for exporting.
Maybe there is a problem with the query that is used to create this table.
So here is my question:
Is it possible to get the query I used to create said view table ?
Maybe there is a problem with the query that is used to create this table.
So here is my question:
Is it possible to get the query I used to create said view table ?
Solution
You can use the documented feature
Reference:
13.7.5.14 SHOW CREATE VIEW Syntax (Version 5.5)
14.7.5.13 SHOW CREATE VIEW Syntax (Version 5.7)
mysql> SHOW CREATE VIEW v\G
1. row
View: v
Create View: CREATE ALGORITHM=UNDEFINED
DEFINER=
SQL SECURITY DEFINER VIEW
character_set_client: latin1
collation_connection: latin1_swedish_ci
SHOW CREATE VIEW view_name which is documented on the official dev.MySQL.com website:Reference:
13.7.5.14 SHOW CREATE VIEW Syntax (Version 5.5)
14.7.5.13 SHOW CREATE VIEW Syntax (Version 5.7)
mysql> SHOW CREATE VIEW v\G
1. row
View: v
Create View: CREATE ALGORITHM=UNDEFINED
DEFINER=
bob@localhostSQL SECURITY DEFINER VIEW
v AS select 1 AS a,2 AS bcharacter_set_client: latin1
collation_connection: latin1_swedish_ci
Context
StackExchange Database Administrators Q#170610, answer score: 5
Revisions (0)
No revisions yet.