What Is Long Data Type in MySQL?

//

Scott Campbell

The long data type in MySQL is used to store whole numbers that range from -9223372036854775808 to 9223372036854775807. It is an integer data type that can hold values with a length of 8 bytes.

Creating a Long Column

To create a column with the long data type, you can use the CREATE TABLE statement in MySQL:

CREATE TABLE my_table (
    id LONG
);

In the above example, we created a table named “my_table” with a column named “id” of the long data type.

Inserting Values into a Long Column

To insert values into a long column, you can use the INSERT INTO statement:

INSERT INTO my_table (id)
VALUES (1234567890);

In this example, we inserted the value 1234567890 into the “id” column of the “my_table” table.

Retrieving Values from a Long Column

To retrieve values from a long column, you can use the SELECT statement:

SELECT id
FROM my_table;

This query will return all the values stored in the “id” column of the “my_table” table.

Working with Long Data Type in Queries

You can also use comparison operators such as =, >, <, >=, <=, and <> to perform operations on long columns:

SELECT id
FROM my_table
WHERE id > 1000;

This query will retrieve all the values from the “id” column of the “my_table” table where the value is greater than 1000.

Conclusion

The long data type in MySQL is useful for storing large whole numbers within the specified range. It provides a way to efficiently store and retrieve numeric values that require a larger storage size than other integer data types. By understanding how to create, insert, and query long columns, you can effectively work with 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