Loading

BOOLEAN, FLOAT, DOUBLE, DECIMAL MYSQL Data Type

Here I am discussing BOOLEAN, FLOAT, DOUBLE, and 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 is 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.

Read Also:-

BIT MySQL Data Type
TINYINT, SMALLINT, MEDIUMINT, INT, BIGINT MySQL Data Type
CHAR and VARCHAR MySQL Data Type
ENUM MySQL Data Type
MYSQLSET Data Type
MySQL BINARY and VARBINARY Data Type

For more detail about Data Type, Please visit Mysql Manual

Share with:


One thought on “BOOLEAN, FLOAT, DOUBLE, DECIMAL MYSQL Data Type

  1. Very nicely explained MySQL Data Type TINYINT, SMALLINT, MEDIUMINT, INT, BIGINT MySQL Data Type BOOLEAN, FLOAT, DOUBLE, DECIMAL MYSQL Data Type CHAR and VARCHAR MySQL Data Type ENUM MySQL Data Type MYSQLSET Data Type MySQL BINARY and VARBINARY [

Leave a Reply

Connect with:

z35W7z4v9z8w
Verified by ExactMetrics