SQLite BIGINT

The BIGINT data type in SQLite is used to store large integer values, which are 64-bit signed integers. This means BIGINT can hold values ranging from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807, making it suitable for storing large numeric data such as timestamps, unique identifiers, or other numeric data requiring a wide range.

Syntax

Here’s the syntax for creating a table with a BIGINT column in SQLite:

CREATE TABLE table_name (
    column_name BIGINT
);

You can also specify additional constraints or attributes like PRIMARY KEY, NOT NULL, UNIQUE, AUTOINCREMENT, etc., as needed.

Example

Here’s an example of creating a table called “employee” with a BIGINT column for storing employee IDs:

CREATE TABLE employee (
    employee_id BIGINT PRIMARY KEY,
    first_name TEXT,
    last_name TEXT,
    salary BIGINT
);

In this example, the “employee_id” column is defined as a BIGINT and is also set as the primary key for the “employee” table. You can add more columns as per your requirements.

To insert data into the table, you can use an INSERT statement like this:

INSERT INTO employee (employee_id, first_name, last_name, salary)
VALUES (1001, 'John', 'Doe', 75000);

You can perform various operations on BIGINT columns, including arithmetic operations, comparisons, and aggregations, just like any other numeric data type in SQL.

Here’s an example of a SQL query to find the average salary of employees with a salary greater than 50,000:

SELECT AVG(salary) 
FROM employee 
WHERE salary > 50000;

In summary, the BIGINT data type in SQLite allows you to store large integer values in a 64-bit signed format, making it suitable for a wide range of numeric data storage needs in your database tables.