HiveBrain v1.2.0
Get Started
← Back to all entries
snippetsqlMinor

How to retrieve the query I used to create a view?

Submitted by: @import:stackexchange-dba··
0
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 ?

Solution

You can use the documented feature 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@localhost
SQL SECURITY DEFINER VIEW
v AS select 1 AS a,2 AS b
character_set_client: latin1
collation_connection: latin1_swedish_ci

Context

StackExchange Database Administrators Q#170610, answer score: 5

Revisions (0)

No revisions yet.