SQL is a programming language used to manage and maintain data stored in relational databases. A relational database consists of tables with labelled rows and columns.

One of the most frequent operations with SQL is to query a database to retrieve data. A typical relational database contains many tables that are related to each other by means of shared values in a column known as foreign key.

As the number of tables increases, writing queries starts to become complex. Besides, we usually need to filter or transform data while retrieving from the database. Thus, we end up writing complicated and lengthy queries to obtain the desired data.

It is doable to write a complex query once or twice. However, if we need to use it many times, a more practical approach is necessary. One option is to save the query in a text or sql file and copy it whenever needed. It is fine but there is a better option which is SQL views or simply views.

A view is a stored query. Views are saved in the database server so we do not have to copy them from some other file. We create a view by assigning a name to a query.

Let’s start with an example so that we have an idea about how a view looks like. After that, I will elaborate on the examples and explain the views in more detail.


#sql #database #programming

10 Examples to Understand SQL Views
1.90 GEEK