What Is Data Type for Long in MySQL?


Scott Campbell

In MySQL, the data type LONG is used to store large integers. It is a 4-byte signed integer that can hold values from -2,147,483,648 to 2,147,483,647. The LONG data type is commonly used when you need to store numeric values that are expected to be larger than what the INT data type can handle.


The syntax for creating a column with the LONG data type in MySQL is as follows:

CREATE TABLE table_name (
    column_name LONG

You can also specify the length of the LONG data type by using the following syntax:

CREATE TABLE table_name (
    column_name LONG(length)

The length parameter specifies the maximum number of digits that can be stored in the column. If no length is specified, MySQL will use a default length of 11.


To better understand how the LONG data type works, consider an example where you want to store employee IDs in a table called “employees”. You can create this table with a column named “employee_id” of type LONG:

CREATE TABLE employees (
    employee_id LONG

This will create a table with an “employee_id” column that can store large integers.


  • The LONGLONG, which is an 8-byte signed integer, provides an even larger range for storing integers.
  • The LONG data type is commonly used for auto-incrementing primary keys.
  • When selecting or manipulating data stored as a LONG, you can use mathematical operations and functions that are applicable to integers.


The LONG data type in MySQL is ideal for storing large integer values. It provides a range that exceeds what the INT data type can handle, making it suitable for various use cases such as storing unique identifiers or auto-incrementing primary keys. By understanding how to create tables with the LONG data type and its syntax, you can effectively utilize this data type in your MySQL databases.

Discord Server - Web Server - Private Server - DNS Server - Object-Oriented Programming - Scripting - Data Types - Data Structures

Privacy Policy