SQL stands for Structured Query Language. This programming language is designed to manage data in relational database management system. SQL is an ANSI and ISO standard.
SQL Queries:
- FROM – indicates table where the search will be made.
- WHERE – to define the rows, in which the search will be carried.
- HAVING – to filter rows.
- ORDER BY – to sort the results in SQL. Else, they will be returned in a random order.
Functions of SQL:
- SQL can execute queries against a database
- It can update, delete, or request information from databases.
- From a database, data can be retrieved by SQL.
- SQL can set permissions on tables, procedures, and views
- SQL can insert records in a database
- SQL can create new databases as well as view in a database.
- It can create new tables in a database
- In a database, stored procedures can be created by SQL.
SQL Language elements:
- Clauses – components of the statements and the queries
- Expressions – They produce scalar values or tables, which consist of columns and rows of data
- Predicates – they are to specify conditions, to limit the effects of the statements and the queries.
- Queries – To retrieve data
- Statements – To control transactions, sessions, connections etc.
Examples:
SQL insert
INSERT INTO phonebook
(id, name, nationality, age)
VALUES(‘31167′, ‘Jess’, ‘U.K’, ‘39’);
SQL UPDATE
UPDATE phonebook
SET id = ‘31167’, name = ‘Jess’
WHERE nationality = ‘U.K’ AND ‘age’ = ’39’;
SQL DELETE
DELETE FROM phonebook
WHERE WHERE nationality = ‘U.K’ AND ‘age’ = ’39’;
SQL DROP
DROP TABLE phonebook;