vimwiki/tech/sql.wiki

51 lines
919 B
Plaintext

= SQL =
Stuctered Query Language is a language that describes a method of fetching and
describing the relationship between different types of data
== 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
== Also see ==
[[databases]]
[[index]]