Categories: TutorialsData

Creating a View with MySQL Query Browser

2 min read

Please refer to an earlier article by the author to learn how to build queries visually.

Creating a View from an Existing Query

To create a view from a query, you must have executed the query successfully. To be more precise, the view is created from the latest successfully executed query, not necessarily from the query currently in the Query Area. To further clarify, the following three examples are cases where the view is not created from the current query:

  • Your current query fails, and immediately after you create a view from the query. The view created is not from the failed query. If the failed query is the first query in your MySQL Query Browser session, you can’t create any view.
  • You have just moved forward or backward the query in the Query Area without executing it, and then your current query is not the latest successfully executed.
  • You open a saved query that you have never executed successfully in your active Resultset.

Additionally, if you’re changing your Resultset, the view created is from the latest successfully executed query that uses the currently active Resultset to display its output.

To make sure your view is from the query you want, select the query, confirm it as written in the Query Area, execute the query, and then, immediately create its view.

You create a view from an existing query by selecting Query | Create View from Select from the Menu bar.

Type in the name you want to give to the view, and then click Create View. MySQL Query Browser creates the view.

When successfully created, you can see the view in the Schemata.

You can modify a view by editing it: Right-click the view and select Edit View.

You can edit the CREATE view statement by right-clicking it and select Edit View.

The CREATE view statement opens in its Script tab. When you finish editing, you can execute the modified view. If successful, the existing view is replaced with the modified one.

To replace the view you’re editing with the modified view, change the name of the view before you execute it. If you want to keep the view you’re editing, remove the DROP VIEW statement.


Packt

Share
Published by
Packt

Recent Posts

Top life hacks for prepping for your IT certification exam

I remember deciding to pursue my first IT certification, the CompTIA A+. I had signed…

3 years ago

Learn Transformers for Natural Language Processing with Denis Rothman

Key takeaways The transformer architecture has proved to be revolutionary in outperforming the classical RNN…

3 years ago

Learning Essential Linux Commands for Navigating the Shell Effectively

Once we learn how to deploy an Ubuntu server, how to manage users, and how…

3 years ago

Clean Coding in Python with Mariano Anaya

Key-takeaways:   Clean code isn’t just a nice thing to have or a luxury in software projects; it's a necessity. If we…

3 years ago

Exploring Forms in Angular – types, benefits and differences   

While developing a web application, or setting dynamic pages and meta tags we need to deal with…

3 years ago

Gain Practical Expertise with the Latest Edition of Software Architecture with C# 9 and .NET 5

Software architecture is one of the most discussed topics in the software industry today, and…

3 years ago