A view in MariaDB is a virtual table based on the result-set of an SQL statement. Views are very useful as they can simplify SQL commands for users – users can just query the defined view rather than having to remember complex SQL queries. Here is how to use a VIEW in MariaDB:
1. First, you’ll need to create a view. The syntax is:
```
CREATE VIEW view_name AS
SELECT column1, column2
FROM table_name
WHERE condition;
```
For example, if you have a table called `employees` and you wanted to create a view to list all employees in the ‘Sales’ department, you could use something like this:
```
CREATE VIEW SalesView AS
SELECT employee_id, employee_name, department
FROM employees
WHERE department = ‘Sales’;
```
After running this command, `SalesView` will now behave almost exactly like a table.
1. You can query it the same way you would a table:
```
SELECT * FROM SalesView;
```
1. If you want to delete a view, you can drop it just like a table:
```
DROP VIEW view_name;
```
Remember that this removes the view, not the data in the underlying tables.
1. To update a view, you need to drop it and create it again with the updated select statement. The syntax is:
```
DROP VIEW your_view;
CREATE VIEW your_view AS SELECT field FROM table WHERE condition;
```
Remember that not all views can be updated. The select statement should not contain groups, joins, unions or subqueries in order for the view to be able to be updated.