By Red Hat
Structured Query Language (SQL) is a language used for creating, maintaining, and querying relational databases. This chapter describes the general syntax of SQL.
SQL input consists of a sequence of commands. A command is composed of a sequence of tokens, terminated by a semicolon (";"). The end of the input stream also terminates a command. Which tokens are valid depends on the syntax of the particular command.
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), but need not be if there is no ambiguity (which is generally only the case if a special character is adjacent to some other token type).
Additionally, SQL input may include comments. These are not tokens; they are effectively equivalent to whitespace.
For example, the following is (syntactically) valid SQL input:
SELECT * FROM MY_TABLE;
UPDATE MY_TABLE SET A = 5;
INSERT INTO MY_TABLE VALUES (3, 'hi there');
This is a sequence of three commands, one per line (although this is not required; more than one command can be on a line, and commands can be split across lines).
The SQL syntax is not very consistent regarding which tokens identify commands and which are operands or parameters. The first few tokens are generally the command name, so in the above example we would usually speak of a "SELECT", an "UPDATE", and an "INSERT" command. However, the syntax rules for SQL statements can vary. For instance, the UPDATE command always requires a SET token to appear in a certain position, and the particular variation of the INSERT shown above also requires a VALUES token in order to be complete. The precise syntax rules for each command are described in the SQL Guide and Reference.
Read More/Download
Structured Query Language (SQL) is a language used for creating, maintaining, and querying relational databases. This chapter describes the general syntax of SQL.
SQL input consists of a sequence of commands. A command is composed of a sequence of tokens, terminated by a semicolon (";"). The end of the input stream also terminates a command. Which tokens are valid depends on the syntax of the particular command.
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), but need not be if there is no ambiguity (which is generally only the case if a special character is adjacent to some other token type).
Additionally, SQL input may include comments. These are not tokens; they are effectively equivalent to whitespace.
For example, the following is (syntactically) valid SQL input:
SELECT * FROM MY_TABLE;
UPDATE MY_TABLE SET A = 5;
INSERT INTO MY_TABLE VALUES (3, 'hi there');
This is a sequence of three commands, one per line (although this is not required; more than one command can be on a line, and commands can be split across lines).
The SQL syntax is not very consistent regarding which tokens identify commands and which are operands or parameters. The first few tokens are generally the command name, so in the above example we would usually speak of a "SELECT", an "UPDATE", and an "INSERT" command. However, the syntax rules for SQL statements can vary. For instance, the UPDATE command always requires a SET token to appear in a certain position, and the particular variation of the INSERT shown above also requires a VALUES token in order to be complete. The precise syntax rules for each command are described in the SQL Guide and Reference.
Read More/Download