SQLite INT

SQLite database supports various data types, including the INT data type, which is used to store integer values. INT is short for INTEGER, and it allows you to store whole numbers without a fractional component. SQLite provides several variations of the INT data type, depending on the size and range of integer values you want to store. Here’s the syntax and an example of using the INT data type in SQLite:

Syntax

column_name INT

Example

You can specify the INT data type when creating a table in SQLite to define a column that will store integer values. For example:

CREATE TABLE Employee (
    EmployeeID INT PRIMARY KEY,
    FirstName TEXT,
    LastName TEXT,
    Age INT
);

In this example, we’ve created a table named “Employee” with four columns. The “EmployeeID” and “Age” columns are defined with the INT data type. The “EmployeeID” column is also set as the primary key, which means it must contain unique values for each row.

Now, let’s insert some data into the “Employee” table using the INT data type:

INSERT INTO Employee (EmployeeID, FirstName, LastName, Age)
VALUES
    (1, 'John', 'Doe', 30),
    (2, 'Jane', 'Smith', 28),
    (3, 'Bob', 'Johnson', 35);

In this INSERT statement, we’ve added three rows of employee data to the “Employee” table. The “EmployeeID” and “Age” columns are populated with integer values.

You can perform various operations and queries on columns with the INT data type, such as filtering, sorting, and mathematical calculations. For example, you can retrieve all employees older than 30 years old with the following query:

SELECT FirstName, LastName
FROM Employee
WHERE Age > 30;

In summary, the INT data type in SQLite is used to store integer values, and it allows you to work with whole numbers in your database tables. It is versatile and commonly used for various applications where integer data is required, such as representing IDs, ages, quantities, and more.