Contents /
Previous /
Next
SQL Basics
The basic structure in SQL is the statement.
Semicolons separate multiple SQL statements.
Statements are composted of tokens.
A token can be a key word, an identifier, a quoted identifier,
a literal (or constant), or a special character symbol.
Tokens are normally separated by whitespace (space, tab, newline).
Whitespace may be used freely in SQL commands.
SQL is case insensitive about key words and identifiers, except
when identifiers are double-quoted to preserve the case.
There are 3 basic categories of SQL Statements:
- Data definition language (DDL) --
SQL-Schema Statements -- maintain schema (catalog)
- CREATE TABLE Statement -- create tables
- CREATE VIEW Statement -- create vie
- Interactive (or Embedded) data manipulation language (DML) --
SQL-Data Statements -- query and modify tables and columns
- SELECT Statement -- query tables and views in the database
- INSERT Statement -- add rows to tables
- UPDATE Statement -- modify columns in table rows
- DELETE Statement -- remove rows from tables
- SQL-Transaction Statements -- control transactions
- COMMIT Statement -- commit the current transaction
- ROLLBACK Statement -- roll back the current transaction
White Space and Comments
White space (i.e., spaces, tabs and newlines) may be used freely in
SQL queries.
Single-line comments are denoted by --
Multiple-line comments, and comments within a line,
are denoted by /* ... */