Identifiers Flashcards

1
Q

What is an identifier?

A

It is a name for a table, attribute, schema or other object.

SQL Server 70-461 02-01

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are the characteristics of a regular identifier?

A
  1. The first character is one of the following:
    >a letter between a and z, lower or upper case.
    >underscore (_)
    >at sign (@)
    >number sign (#)
  2. Subsequent characters can include:
    >letters
    >decimal numbers
    >underscore (_)
    >at sign (@)
    >number sign (#)
    >dollar sign ($)
  3. A regular identifier cannot be a reserved word
  4. A regular identifier cannot contain spaces
  5. The identifier cannot include supplementary characters

SQL Server 70-461 02-01

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

If an identifier doesn’t follow the rules for a regular identifier what kind of identifier is it and what must be done?

A

It is an irregular identifier and it must be delimited.

SQL Server 70-461 02-01

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Can a regular identifier be delimited?

A

A regular identifier can be delimited but it isn’t required to be delimited.

SQL Server 70-461 02-01

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

In what ways can an irregular identifier be delimited?

A
  1. With double quotation marks. Ex, “Sales”.”Orders”. This form is standard.
  2. With square brackets. Ex, [Sales].[Orders]. This form is proprietary to T–SQL.

SQL Server 70-461 02-01

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the difference between a regular identifier and a delimited identifier

A
  • 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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

The [ ] or “ “ prefered as a delimiter?

A
  • [ ]
  • 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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Can a regular identifier include spaces?

A

No

SQL Server 70-461 08-01

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What character must a regular identifier start with and what are the two exceptions?

A
  • A letter or an underscore
  • Variables must begin with @
  • Temporary tables or procedures must start with #

SQL Server 70-461 08-01

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What can the length of an identifier be?

A

1 to 128 characters

SQL Server 70-461 08-01

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What are identifiers used for?

A
  • tables names
  • schema names
  • column names
  • variables
  • temporary tables
  • procedures
  • etc

SQL Server 70-461 08-01

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

For regular identifiers, what can the characters after the first character be?

A
  • letters
  • numerals
  • @
  • #
  • $
  • _

SQL Server 70-461 08-01

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is best practice when naming identifiers?

A
  1. Use regular identifiers
  2. Even though you can use special characters, just use letters. numbers and underscores

SQL Server 70-461 08-01

How well did you know this?
1
Not at all
2
3
4
5
Perfectly