Structured Query Language

For more information on SQL syntax, click here.

SQL Parts

  • SQL DDL: defining, deleting and modifying relation schemas
  • SQL DML: query information from, insert tuples into, delete tuples from and modify tuples in the database
  • integrity: SQL DDL includes commands for specifying integrity constraints
  • View definition: SQL DDL includes commands for defining views
  • Transaction control: SQL commands for specifying the beginning and ending of transactions
  • Embedded SQL and dynamic SQL: define how SQL statements can be embedded within general-purpose programming languages
  • Authorization: SQL DDL includes commands for specifying access rights to relations and views

Data Definition Language

The SQL data-definition language (DDL) allows the specification of relations and information about relations, including:

  • the schema for each relation
  • the type of values associated with each attribute
  • the integrity constraints
  • the set of indices to be maintained for each relation
  • security and authorization information for each relation
  • the physical storage structure of each relation on disk

Views

A view is defined as:

create view v as < query expression >

Once a view is defined, the view name can be used to refer to the virtual relation that the view generates. This is not the same as creating a new relation by evaluating the query expression.

You can use views in the expression defining another view.

Certain database systems allow view relations to be physically stored. A physical copy is created when the view is defined.

Transactions

A transaction consists of a sequence of query and/or update statements and is a "unit" of work. The SQL standard specifies that a transaction begins implicitly when an SQL statement is executed.

  • the transaction must end with one of the following statements:
    • Commit work: the updates performed by the transaction become permanent in the database
    • Rollback work: All the updates performed by the SQL statements in the transaction are undone.
  • Atomic transaction (indivisible)
    • either fully executed or rolled back as if never occurred
  • Isolation from concurrent transactions