Introduction to Structure Query Language (SQL)
- Structure Query Language (SQL) is language that provides an interface to relational database systems.
- SQL was developed by IBM in the 1970s for use in System R, and is a de facto standard, as well as an ISO and ANSI standard.
- SQL is often pronounced SEQUEL and SEQUEL means Structure EnglishQUEry Language.
Features of SQL
- SQL can be used by a range of users, including those with little or no programming experience.
- It is a non procedural language.
- It reduces the amount of time required for creating and maintaining systems.
- It is an English-like language.
Rules for SQL
1. SQL starts with a verb (i.e. a SQL action word). EXAMPLE: SELECTstatements. This verb may have additional adjectives. EXAMPLE: FROM
2. Each verb is followed by number of clauses. EXAMPLE: FROM, WHERE, HAVING
3. A space separates clause. EXAMPLE: DROP TABLE EMP;
4. A Comma (,) separates parameters without a clause.
5. A ‘;’ is used to end SQL statements.
6. Statements may be split across lines but keywords may not.
7. Lexical units such as identifiers, operator names, literals are separated by one or more spaces or other delimiters that will not be confused with the lexical unit.
8. Reserved words cannot be used as identifiers unless enclosed with double quotes. Reserved words are: AS, BY, CREATE, SELECT, VARCHAR, BETWEEN etc.
9. Identifiers can contain up to 30 characters and must start with an alphabetic character.
10. Character and date literals must be enclosed within single quotes.
11. Numeric literals can be represented by simple values such as 0.32,-34,01991, and so on, scientific notation as 2E5 meaning 2×10 to power of 5=200,000.
12. Comments may be enclosed between /* and */ symbols and may be multi line. Single line comments may be prefixed with a – symbol.
Delimiters are symbol or compound symbols, which have a special meaning within SQL and PL/SQL statements.
|/||Division||<> != ^=||Relational|
|=> <||Relational||<= >=||Relational|
|()||Expression or list||:=||Assignment|
|@||Remote access indicator||—||Comment|
|‘||Character string delimiter||/* */||Comment (Multi-line)|