Identifiers and Keywords
Identifiers are names given to SQL entities, such as tables, columns, databases, and variables. Identifiers must be unique so that entities can be correctly identified during the execution of a program. Identifiers can also be used to change a column name in the result (column alias) in a
SELECT statement. Identifiers can be either quoted or unquoted and a maximum 128 characters long.
Identifiers are sometimes referred to as “names”.
Regular identifiers must follow these rules:
Must not contain a whitespace character or any special characters except for underscores (
Must be case-insensitive. SQream converts all identifiers to lowercase unless quoted
Does not equal any keywords, such as
To bypass the rules above you can surround an identifier with double quotes (
Quoted identifiers must follow these rules:
Must be surrounded with double quotes (
May contain any ASCII character except
Must be case-sensitive and referenced with double quotes (
Creating quoted and unquoted identifiers:
CREATE ROLE "developer"; --quoted identifiers preserves case - will create "developer" CREATE ROLE "Developer"; --quoted identifiers preserves case - will create "Developer" CREATE ROLE Developer; --unquoted identifiers ignores case - will create "developer"
Valid and invalid use of identifiers:
-- these are all valid examples when quoted: CREATE SCHEMA "my schema"; CREATE SCHEMA "123schema"; -- but are invalid when unquoted: CREATE SCHEMA my schema; --invalid CREATE SCHEMA 123schema; --invalid -- Use of invalid characters: CREATE SCHEMA "my schema@master"; Status: Ended with errorError preparing statement: Unsupported character '@' in identifier: "my schema@master" Quoted identifiers cannot contain the character '@'. Quoted identifiers may contain any ASCII character with code between 32 and 126 except for: - @ - $ - "
Identifiers are different than keywords, which are predefined words reserved with specific meanings in a statement. Some examples of keywords are
WHERE. Note that keywords cannot be used as identifiers.
SQreamDB reserved keywords: