List and Describe: categories of SQL syntax
SQL syntax falls into five main categories:
Identifiers: names for database objects, such as databases, tables, constraints on tables, columns in tables, views, etc.
Literals: strings or values that are not identifiers or keywords.
Operators: Symbols specifying an action to be performed on one or more expressions.
Reserved Words: Words with special meaning to the database SQL parser. Reserved words (such as words used in commands and SQL statements) are words that cannot be used as identifiers.
Keywords: Words with special meaning to the database SQL parser. The term keywords is often used to refer to non-reserved words that only have a special meaning in particular contexts and can be used as identifiers in other contexts (though this is still generally best avoided)
What is an ‘identifier’ in SQL?
In its simplest terms, an identifier is the name of an object you create on your database platform.
Each object (whether a database, table, view, column, index, key, trigger, stored procedure, or constraint) in an RDBMS must be identified. When issuing the command that creates a database object, you must therefore specify an identifier (i.e., a name) for that new object.
What are two categories of rules when choosing an Identifier in SQL?
Naming Conventions & Identifier Rules
What are ‘naming conventions’ and what are their purpose?
Naming conventions establish a standard baseline for choosing object identifiers. The SQL standard has no comment on naming conventions outside of the uniqueness of an identifier, its length, and the characters that are valid within the identifier.
There two reasons for naming conventions:
List and Describe: some naming conventions
Naming Conventions:
What are ‘Identifier Rules’ and what are their purpose?
Identifier rules are rules for identifying objects within the database that are rigidly enforced by the database platforms. Rules specified by the SQL standard generally differ somewhat from those of specific database vendors.
List and Describe: some Identifier Rules for the SQL Standard.
Identifier Rules for the SQL Standard (note: identifier rules differ per vendor)
Research: ‘scope’ in programming languages in general.
The scope of a identifier name is the part of a program where the identifier name is valid; that is, where the name can be used to refer to the entity.
Scope helps prevent name collisions by allowing the same name to refer to different objects – as long as the names have separate scopes.
What naming rules for identifiers in regards to scope?
Identifiers must be unique within their scope.
. database names must be unique on a particular instance of a database server
. names of tables, views, functions, triggers, and stored procedures must be unique within a particular schema.
. a table and a stored procedure can have the same name since they are different types of objects
. names of columns, keys, and indexes must be unique in a single table or view
What is a ‘literal’ in the SQL language?
SQL defines a literal value as any explicit numeric value, character string, temporal value (e.g., date or time), or Boolean value that is not an identifier or a keyword.
In other words, a literal is a raw data value.
What is an ‘operator’ in the SQL Language?
An operator is a symbol specifying an action to be performed on one or more expressions.
List and Describe: the seven categories of operators.
Research: bitwise operations
In computer programming, a bitwise operation operates at the level of its individual bits. A bitwise operation can change bit strings, a bit arrays or a binary numerals.
What are bitwise operators in the SQL Language?
What are Comparison Operators in the SQL Language?
List and Describe: the nine Comparison Operators in the SQL Language.
Comparison operator Meaning:
= Equal to
> Greater than
< Less than
>= Greater than or equal to
<= Less than or equal to
<> Not equal to
!= Not equal to (not SQL standard)
!< Not less than (not SQL standard)
!> Not greater than (not SQL standard)