Check column data type in mysql

Using the DESCRIBE or SHOW COLUMNS command in MySQL, you may determine the data type of a column in a table.

To get details about the columns in a table, use the DESCRIBE command. The command takes the table name as an argument and returns information such as the column name, data type, and other attributes of the columns in the table.

Here is an example of how to use the DESCRIBE command to check the data type of a column in a table named “YourTableName”:

Below is the script to check the data type of a column in MySQL

DESC `YourTableName` `YourColumnName`;

It will give you the output like this:

+-----------+-------------+------+-----+---------+-------+

| Field     | Type        | Null | Key | Default | Extra |

+-----------+-------------+------+-----+---------+-------+

| Username | varchar(100) | YES  |     | NULL    |       |

+-----------+-------------+------+-----+---------+-------+

Similar to the DESCRIBE command, the SHOW COLUMNS command is used to display details about the columns in a table. Below is the script for using SHOW COLUMNS:

SHOW COLUMNS FROM `YourTableName` WHERE Field='YourColumnName';

The output of the above query will be like this:

Field	Type	Null	Key	Default	Extra
UserName	varchar(100)	YES		NULL