2021-09-22 17:23:25 +00:00
|
|
|
= SQL =
|
|
|
|
|
|
|
|
Stuctered Query Language is a language that describes a method of fetching and
|
|
|
|
describing the relationship between different types of data
|
|
|
|
|
2022-02-28 21:15:01 +00:00
|
|
|
== Views ==
|
|
|
|
|
|
|
|
A view can be created with the following command
|
|
|
|
|
|
|
|
{{{
|
|
|
|
CREATE VIEW [view_name] AS
|
|
|
|
SELECT column1, column2, ...
|
|
|
|
FROM table
|
|
|
|
WHERE condition;
|
|
|
|
}}}
|
|
|
|
|
|
|
|
For example, this view returns all products witha price higher than the average
|
|
|
|
price of the table
|
|
|
|
|
|
|
|
{{{
|
|
|
|
CREATE VIEW [Products above average price] AS
|
|
|
|
SELECT Name, Price
|
|
|
|
FROM Products
|
|
|
|
WHERE Price > (SELECT AVG(Price) FROM Products)
|
|
|
|
|
|
|
|
SELECT * FROM [Prodcuts above average price]
|
|
|
|
}}}
|
|
|
|
|
|
|
|
== Acess control commands ==
|
|
|
|
|
|
|
|
Two commands for managing access rights
|
|
|
|
|
|
|
|
* grant
|
|
|
|
* used to grant one or more access rights or can be used to assign a user to
|
|
|
|
a role
|
|
|
|
* revoke
|
|
|
|
* revokes the acess rights
|
|
|
|
|
|
|
|
Typical access rights include
|
|
|
|
|
|
|
|
* select
|
|
|
|
* insert update
|
|
|
|
* delete
|
|
|
|
* references
|
2021-09-22 17:23:25 +00:00
|
|
|
|
|
|
|
== Also see ==
|
|
|
|
|
2022-02-28 21:15:01 +00:00
|
|
|
[[databases]]
|
2021-09-22 17:23:25 +00:00
|
|
|
|
2022-02-28 21:15:01 +00:00
|
|
|
[[index]]
|