Identifiers Flashcards
What is an identifier?
It is a name for a table, attribute, schema or other object.
SQL Server 70-461 02-01
What are the characteristics of a regular identifier?
- The first character is one of the following:
>a letter between a and z, lower or upper case.
>underscore (_)
>at sign (@)
>number sign (#) - Subsequent characters can include:
>letters
>decimal numbers
>underscore (_)
>at sign (@)
>number sign (#)
>dollar sign ($) - A regular identifier cannot be a reserved word
- A regular identifier cannot contain spaces
- The identifier cannot include supplementary characters
SQL Server 70-461 02-01
If an identifier doesn’t follow the rules for a regular identifier what kind of identifier is it and what must be done?
It is an irregular identifier and it must be delimited.
SQL Server 70-461 02-01
Can a regular identifier be delimited?
A regular identifier can be delimited but it isn’t required to be delimited.
SQL Server 70-461 02-01
In what ways can an irregular identifier be delimited?
- With double quotation marks. Ex, “Sales”.”Orders”. This form is standard.
- With square brackets. Ex, [Sales].[Orders]. This form is proprietary to T–SQL.
SQL Server 70-461 02-01
What is the difference between a regular identifier and a delimited identifier
- Regular identifiers follow a set of rules
- Delimited identifiers do not follow the regular identifier rules and therefore must be surrounded by [ ] or “ “
SQL Server 70-461 08-01
The [ ] or “ “ prefered as a delimiter?
- [ ]
- There is a setting that can be turned off in which case the code would not recognize “ “ as a delimiter.
SQL Server 70-461 08-01
Can a regular identifier include spaces?
No
SQL Server 70-461 08-01
What character must a regular identifier start with and what are the two exceptions?
- A letter or an underscore
- Variables must begin with @
- Temporary tables or procedures must start with #
SQL Server 70-461 08-01
What can the length of an identifier be?
1 to 128 characters
SQL Server 70-461 08-01
What are identifiers used for?
- tables names
- schema names
- column names
- variables
- temporary tables
- procedures
- etc
SQL Server 70-461 08-01
For regular identifiers, what can the characters after the first character be?
- letters
- numerals
- @
- #
- $
- _
SQL Server 70-461 08-01
What is best practice when naming identifiers?
- Use regular identifiers
- Even though you can use special characters, just use letters. numbers and underscores
SQL Server 70-461 08-01