Structured Query Language (SQL)
The Structured Query Language (SQL) is a standardized form of data access and modification. All relational databases support SQL. The following are the most often used SQL statements:
- Create: CREATE professor (prof_id INTEGER PRIMARY KEY NOT NULL, name CHAR(20))
- Select: SELECT first_name, last_name, rank FROM professor WHERE rank = 2 ORDER BY last_name
- Insert: INSERT INTO professor (last_name, first_name, rank) VALUES ('John', 'Jones', 3)
- Delete: DELETE FROM professor WHERE first_name = 'Jones'
- Update:UPDATE professor SET rank = 1 WHERE last_name = 'Jones'
SQL allows the use of the wild card symbol * (asterisk) to indicate all fields in a select statement, and the ? charcter for pattern matching, using the like keyword. The keywords ASCENDING and DESCENDING can modify sorting:
SELECT * FROM professor WHERE last_name LIKE 'J?' ORDER BY last_name DESCENDING
SQL is NOT case sensitive. Use of run-time parameters is also allowed, with the related syntax varying slightly.
The SQL language is standardized to a large degree, but variations occur as specified by the various database product vendors. So there are e.g Oracle, SQL Server (Microsoft), Access, SYBASE, Borland etc. "flavors". A flavor of SQL may not work on a platform using an other flavor. This is a common problem with database access and can be solved by carefully designing platform-independent database interface layers.