Inside of your database management system, there are databases and tables within them.
Databases store tables while tables store rows and columns of data inside of them.
Some database management systems like MySQL, SQL Server, and PostgreSQL also have concepts called views.
This MySQL views tutorial will tell you that views in database management systems act as virtual tables in that SQL views don’t store data themselves but “save” the results of a certain query in a virtual table that is called an SQL view.
Let’s say you have an employees table and you only want to see employees from a specific department.
To do that, you can create a database view that holds only the required data, then query the database view as necessary.
An SQL query that creates database views would look like this:
CREATE VIEW sales_department AS
SELECT id, name, position
FROM employees
WHERE department = ‘Sales’;
After you create such an SQL view, you can query the SQL view like so:
SELECT * FROM sales_department;
And whenever you do query the SQL view, you get the list of employees in the sales department, just like the database views were a separate table.
SQL views do not occupy storage space because SQL views don’t store actual data: database views store proceeds from SQL queries.
In other words, when you query an SQL view, MySQL or another database management system runs the underlying SELECT statement on the current data in the table specified by the SQL view.
Also, when you interact with the SQL view by deleting, inserting, or updating data inside of the SQL view, you also update data in the underlying table.
So these are MySQL views. If you enjoyed this MySQL views tutorial, make sure to subscribe to see more content around database management systems including sql interview questions and answers and other content, and until next time.
Music:
Santiago by Filo Starquez: https://soundcloud.com/filo-starquez
License: Creative Commons — Attribution – NoDerivs 3.0 Unported — CC BY-ND 3.0
Free Download / Stream: https://www.audiolibrary.com.co/filo-starquez/santiago
Music promoted by Audio Library: https://www.youtube.com/watch?v=gmsT7ffwgg8
#database #sql #coding #mysql #programming #webdevelopment


コメント