SQL2 Flashcards

0
Q

SQL built-in data type categories?

A
Exact numbers
Approximate numbers
Date and time
Character strings
Unicode character strings
Binary strings
Other data types
CLR data types:(common language runtime)
Spatial data types
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
1
Q

Data type?

A

Is an attribute that specifies the type of data an object can hold. As well as how many bytes each data type takes up.

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

Most commonly used data type?

A
Money
Datetime
Integer (int) : numeric data type
varchar or nvarchar (international)
Boolean: bit data type (T or F)
Float: numeric data type  ( 4-byte-7 digits / 8-byte-15 digits)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Exact number?

A
Bit 1b
Tinyint 1b
Smallint 2b
Int 4b
Bigint 8b
Numberic varies
Decimal varies
Smallmoney 4b
Money 8 b
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Character strings?

A

Char: fixed length
Varchar: variable length

A regular character uses one byte of storage for each character.

Syntax ‘ ‘ ( single quotes)

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

Unicode character strings?

A

Nchar: fixed length
Nvarchar: variable length

(2 x storages)

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

Character strings?

A

Char: fixed length
Varchar: variable length

A regular character uses one byte of storage for each character.

Syntax ‘ ‘ ( single quotes)

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

Binary strings?

A

Binary: fixed length
Varbinary: variable length

Ex: image

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

What determined when two expressions have different data type?

A
  1. Lower precedence converted to higher precedence
  2. SQL Server predefined collation precedence
  3. The result depend on the precision,scale,length of the input expression
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Scales(s)?

A

Reflects the maximum number of decimal digits that can be stored to the right of the decimal point.

Ex: decimal [(p[,s])]

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

Precision (p)?

A

Is the maximum total number of decimal digits that can be stored,both to the left and to the right of the decimal point. This value must be at least 1 and at most 38. The default precision number is 18.

Ex: decimal [(p[,s])]

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

Implicit conversions?

A

Data type conversion are done automatically.

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

Two common naming convention ?

A

PacalCase
camelCase

No space or use _ as word separators

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

Explicit conversion?

A

Data type conversions require you to use the functions Cast or Convert specifically.

Cast and Convert functions

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

A view?

A

Is simply a virtual table consisting of different columns from one or more tables.

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

Two major reasons why provide database view?

A
  1. Views allow you to limit the type of data users can access.
  2. Views reduce complexity for end users so they don’t have to learn how to write complex SQL queries.

-Indexing to the schema can actually increase the overhead of database

16
Q

SQL injections?

A

is an attack in which malicious code is inserted into strings that are later passed on to instances of SQL Server waiting for parsing and execution. (metadata)