Data types of MySQL database

11.4.1.4 define data types when creating a database

Data types of MySQL database

Each column in a database table is required to have a name and a data type.

When creating a table, an SQL developer must decide what type of data will be stored inside each column. The data type is a guideline for SQL to understand what type of data is expected inside each column, and it also identifies how SQL will interact with the stored data.

Data types table

Data types Description Example

INT

The whole number in range (-2147483648 ... 2147483647)

23; -5

DECIMAL

A fixed-point number 4.5; -0.003

 VARCHAR(size)

String (0-65535 characters)

"+7 777 777 77 77";

"Computer science is ..."

BOOL,

BOOLEAN

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

True; 

False

BLOB(size) For BLOBs (Binary Large OBjects). Holds up to 65,535 bytes of data (picture)
FLOAT, DOUBLE A floating point number 0.3 * 105
INT (AUTO_INCREMENT) Usually is used as a primary key 1; 2; 3; ...
DATE A date. Format: YYYY-MM-DD. The supported range is from '1000-01-01' to '9999-12-31' '2024-11-04'

More about Data types

Example

Table "Users"

Different fields have their data type.


Questions:

1. Name three data types.

2. Name three integer data types.

3. Give examples of five different data types.


Exercises:

Ex. 1

Ex. 2


Exam questions:


 

Категория: Relational databases | Добавил: bzfar77 (02.11.2020)
Просмотров: 7388 | Комментарии: 1 | Теги: double, time, varchar, date, mysql, data type, float, boolean, database, Int, integer | Рейтинг: 5.0/3
Всего комментариев: 1
avatar
0
1 ayetatar756 • 12:41, 15.12.2024
The past is history, and the future is mystery. present is gifted. That's why it's called present.
avatar