MISC#1 Integer Range, TRUNCATE, Functions, Referential Integrity, SIGNED/UNSIGNED Flashcards

1
Q

5 INT types

A
  • BIG INT
  • INT
  • MEDIUMINT
  • SMALLINT
  • TINYINT
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q
  • How bytes of storage does BIGINT have
  • Unsigned range for BIGINT
  • Signed Range for BIGINT
A
  • 8 bytes of storage
  • Unsigned : 0 to 2^62-1
  • Signed: -2^63 to
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q
  • How bytes of storage does INT have
  • Unsigned range for INT
  • Signed Range for INT
A
  • 4 bytes of storage
  • Unsigned : 0 to 4.3 Billion
  • Signed: -2.1 billion to 2.1 billion
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q
  • How bytes of storage does MEDIUMINT have
  • Unsigned range for MEDIUMINT
  • Signed Range for MEDIUMINT
A
  • 3 bytes of storage
  • Unsigned : 0 to 16.7 million
  • Signed: -8.4 million to 8.4 million
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q
  • How bytes of storage does SMALLINT have
  • Unsigned range for SMALLINT
  • Signed Range for SMALLINT
A
  • 2 bytes of storage
  • Unsigned : 0 to 65,535
  • Signed: -32,798 to 32,767
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q
  • How bytes of storage does TINYINT have
  • Unsigned range for TINYINT
  • Signed Range for TINYINT
A
  • 1 bytes of storage
  • Unsigned : 0 to 255
  • Signed: -128 to 127
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is referential integrity?

A

Ensures consistency/correctness of relationships between tables by enforcing foreign key constraints

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

What are the four types of referntial integrity?

A
  • RESTRICT
  • SET NULL
  • SET DEFAULT
  • CASCADE
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

RESTRICT

A

Rejects whatever if violating the ref integrity

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

SET NULL

A

Sets foreign key values to NULL, when records are deleted or updated

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

SET DEFAULT

A

sets foreign key values to the default value when records are deleted or updated

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

function: CONCAT()

A

used for concatenating multiple strings together into a single string.

EX: SELECT CONCAT(‘Bean’, ‘ ‘, ‘Toast’)

  • This produces a result of: Bean Toast
  • you specify the string in quotes with any spaces denoted by an empty space in quotes
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

CASCADE

A

propagates changes to related records

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

function: CONV()

A

used for converting from one number base to another number base

EX: SELECT CONV(‘10’,2,10)

  • this produces a result of 2
  • You first specifiy in quotes the current number you want to convert, then the current base of the numberm then the base you want the number you want to be converted to
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

function: SUBSTRING()

A

used for extracting a substring from a string.
ex:

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

TRUNCATE

A

for deleting all rows from a table
(Youre deleting the content inside of the table, not the structure (columns) of the table
TRUNCATE deletes everything at once, DELETE goes ROW by ROW

17
Q

SIGNED

A

default value, allows both pos and neg numbers

18
Q

UNSIGNED

A

attribute for ensuring that an INTEGER only can store non negative values