Loading

BOOLEAN,FLOAT, DOUBLE, DECIMAL MYSQL Data Type

BOOLEAN Data Type:- MySQL does not have a BOOLEAN data type. MySQL converts a BOOLEAN value into integer data type TINYINT. So, MySQL considers 0 for false and 1 for true.

Even MySQL uses the BOOLEAN operator in their query like TRUE, FALSE, IS TRUE, IS FALSE, IS NOT TRUE, IS NOT FALSE.

Example:-

CREATE TABLE attendance(

id INT PRIMARY KEY AUTO_INCREMENT,

name VARCHAR(255) NOT NULL,

present BOOLEAN

);

FLOAT, DOUBLE, DECIMAL Data Type:- FLOAT, DOUBLE, DECIMAL Data Type is used for approximate numeric data value.

FLOAT and DECIMAL use four-byte for single-precision value and DOUBLE uses eight-byte for single-precision value.

General Syntax:-

FLOAT(M, D) or REAL(M, D)

DOUBLE(M,D) or DOUBLE PRECISION(M,D)

DECIMAL(M,D) or DEC(M,D)

Where M specified The total number of digits is specified in size. The number of digits after the decimal point is specified in the D parameter.

NOTE:- As of MySQL 8.0.17, the nonstandard FLOAT(M, D) and DOUBLE(M, D) syntax are deprecated and you should expect support for it to be removed in a future version of MySQL.

Share with:


Leave a Reply

Connect with:





z35W7z4v9z8w