SQL Data Types Flashcards

1
Q

CHAR(size)

A

A FIXED length string (can contain letters, numbers, and special characters). Thesizeparameter specifies the column length in characters - can be from 0 to 255. Default is 1

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

VARCHAR(size)

A

A VARIABLE length string (can contain letters, numbers, and special characters). Thesizeparameter specifies the maximum string length in characters - can be from 0 to 65535

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

BINARY(size)

A

Equal to CHAR(), but stores binary byte strings. Thesizeparameter specifies the column length in bytes. Default is 1

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

VARBINARY(size)

A

Equal to VARCHAR(), but stores binary byte strings. Thesizeparameter specifies the maximum column length in bytes.

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

TINYBLOB

A

For BLOBs (Binary Large Objects). Max length: 255 bytes

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

TINYTEXT

A

Holds a string with a maximum length of 255 characters

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

TEXT(size)

A

Holds a string with a maximum length of 65,535 bytes

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

BLOB(size)

A

For BLOBs (Binary Large Objects). Holds up to 65,535 bytes of data

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

MEDIUMTEXT

A

Holds a string with a maximum length of 16,777,215 characters

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

MEDIUMBLOB

A

For BLOBs (Binary Large Objects). Holds up to 16,777,215 bytes of data

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

LONGTEXT

A

Holds a string with a maximum length of 4,294,967,295 characters

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

LONGBLOB

A

For BLOBs (Binary Large Objects). Holds up to 4,294,967,295 bytes of data

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

ENUM(val1, val2, val3, …)

A

A string object that can have only one value, chosen from a list of possible values. You can list up to 65535 values in an ENUM list. If a value is inserted that is not in the list, a blank value will be inserted. The values are sorted in the order you enter them

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

SET(val1, val2, val3, …)

A

A string object that can have 0 or more values, chosen from a list of possible values. You can list up to 64 values in a SET list

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

BIT(size)

A

A bit-value type. The number of bits per value is specified insize. Thesizeparameter can hold a value from 1 to 64. The default value forsizeis 1.

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

TINYINT(size)

A

A very small integer. Signed range is from -128 to 127. Unsigned range is from 0 to 255. Thesizeparameter specifies the maximum display width (which is 255)

17
Q

BOOL

A

Zero is considered as false, nonzero values are considered as true.

18
Q

BOOLEAN

A

Equal to BOOL

19
Q

SMALLINT(size)

A

A small integer. Signed range is from -32768 to 32767. Unsigned range is from 0 to 65535. Thesizeparameter specifies the maximum display width (which is 255)

20
Q

MEDIUMINT(size)

A

A medium integer. Signed range is from -8388608 to 8388607. Unsigned range is from 0 to 16777215. Thesizeparameter specifies the maximum display width (which is 255)

21
Q

INT(size)

A

A medium integer. Signed range is from -2147483648 to 2147483647. Unsigned range is from 0 to 4294967295. Thesizeparameter specifies the maximum display width (which is 255)

22
Q

INTEGER(size)

A

Equal to INT(size)

23
Q

BIGINT(size)

A

A large integer. Signed range is from -9223372036854775808 to 9223372036854775807. Unsigned range is from 0 to 18446744073709551615. Thesizeparameter specifies the maximum display width (which is 255)

24
Q

FLOAT(size,d)

A

A floating point number. The total number of digits is specified insize. The number of digits after the decimal point is specified in thedparameter. This syntax is deprecated in MySQL 8.0.17, and it will be removed in future MySQL versions

25
Q

FLOAT(p)

A

A floating point number. MySQL uses thepvalue to determine whether to use FLOAT or DOUBLE for the resulting data type. Ifpis from 0 to 24, the data type becomes FLOAT(). Ifpis from 25 to 53, the data type becomes DOUBLE()

26
Q

DOUBLE(size,d)

A

A normal-size floating point number. The total number of digits is specified insize. The number of digits after the decimal point is specified in thedparameter

27
Q

DECIMAL(size,d)

A

An exact fixed-point number. The total number of digits is specified insize. The number of digits after the decimal point is specified in thedparameter. The maximum number forsizeis 65. The maximum number fordis 30. The default value forsizeis 10. The default value fordis 0.

28
Q

DEC(size,d)

A

Equal to DECIMAL(size,d)

29
Q

DATE

A

A date. Format: YYYY-MM-DD. The supported range is from ‘1000-01-01’ to ‘9999-12-31’

30
Q

DATETIME(fsp)

A

A date and time combination. Format: YYYY-MM-DD hh:mm:ss. The supported range is from ‘1000-01-01 00:00:00’ to ‘9999-12-31 23:59:59’. Adding DEFAULT and ON UPDATE in the column definition to get automatic initialization and updating to the current date and time

31
Q

TIMESTAMP(fsp)

A

A timestamp. TIMESTAMP values are stored as the number of seconds since the Unix epoch (‘1970-01-01 00:00:00’ UTC). Format: YYYY-MM-DD hh:mm:ss. The supported range is from ‘1970-01-01 00:00:01’ UTC to ‘2038-01-09 03:14:07’ UTC. Automatic initialization and updating to the current date and time can be specified using DEFAULT CURRENT_TIMESTAMP and ON UPDATE CURRENT_TIMESTAMP in the column definition

32
Q

TIME(fsp)

A

A time. Format: hh:mm:ss. The supported range is from ‘-838:59:59’ to ‘838:59:59’

33
Q

YEAR

A

A year in four-digit format. Values allowed in four-digit format: 1901 to 2155, and 0000.