The BIGINT data type in Oracle is used to store large integer values. It is designed to hold whole numbers ranging from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807. This data type is commonly used when dealing with very large numbers or when the precision of a regular integer data type is not sufficient.
How to Declare a BIGINT Data Type
To declare a column with the BIGINT data type in Oracle, you can use the following syntax:
CREATE TABLE table_name (
column_name BIGINT
);
This creates a table with a column named column_name that can store values of type BIGINT.
Working with BIGINT Data Type
The BIGINT data type supports all standard arithmetic operations such as addition (+), subtraction (-), multiplication (*), and division (/). You can perform these operations on columns or variables of type BIGINT just like any other numeric data types.
In addition to basic arithmetic operations, you can also use various built-in functions and operators specific to the BIGINT data type. These include:
- ABS(): Returns the absolute value of a BIGINT number.
- SIGN(): Returns the sign of a BIGINT number (-1 for negative numbers, 0 for zero, and 1 for positive numbers).
- MOD(): Returns the remainder after dividing one BIGINT number by another.
Example
CREATE TABLE employees (
id BIGINT,
name VARCHAR(100),
salary BIGINT
);
INSERT INTO employees (id, name, salary)
VALUES (1, 'John Doe', 1000000);
SELECT id, name, salary FROM employees;
In the above example, we create a table named employees with three columns: id, name, and salary. The id and salary columns are of type BIGINT.
We then insert a row into the table with the values 1, ‘John Doe’, and 1000000 for the id, name, and salary columns respectively. Finally, we retrieve all rows from the employees table.
Note:
The BIGINT data type is not available in all versions of Oracle. It was introduced in Oracle 12c.
Conclusion
The BIGINT data type in Oracle allows you to store large integer values that may exceed the range of regular integer data types. It provides a higher level of precision for handling very large numbers. By using appropriate functions and operators, you can perform various mathematical operations on columns or variables of type BIGINT.
If you need to work with extremely large whole numbers in your Oracle database, consider using the BIGINT data type to ensure accuracy and efficiency.
9 Related Question Answers Found
What Is Data Type in Oracle? In Oracle, data types define the type of data that can be stored in a column or variable. Each data type has a specific range of values and operations that can be performed on it.
The Real data type in Oracle is used for representing single-precision floating-point numbers. It is a binary floating-point number that can represent values with a decimal part. The Real data type is also known as FLOAT or FLOAT(p), where ‘p’ represents the precision (the total number of digits).
The text data type in Oracle is used to store character data of variable length. It is used to store strings, such as names, addresses, and descriptions. In Oracle, the text data type is called VARCHAR2.
In SQL, the BIGINT data type is used to store integer values that are larger than what can be accommodated by the INT data type. It is commonly used when dealing with large numerical values that may exceed the range of a regular integer. Properties of the BIGINT Data Type:
The BIGINT data type is an extension of the INT data type and can store 8-byte signed integers.
Is Large Object Data Type Supported by Oracle? In Oracle, a large object data type is used to store and manipulate a large amount of data. The two main types of large object data types supported by Oracle are BLOB (Binary Large Object) and CLOB (Character Large Object).
A character data type is a fundamental concept in Oracle databases. It represents any string of characters, such as letters, numbers, or special symbols. In Oracle, there are different character data types available to accommodate various requirements.
The bit data type in Oracle is a binary data type that stores fixed-length binary strings. It is commonly used to represent boolean values, with 0 representing false and 1 representing true. Creating a Bit Data Type
To create a column with the bit data type in Oracle, you can use the RAW or BLOB data types.
In Oracle, the NUMBER data type is used to store numeric values. It is a versatile data type that can store both integer and decimal values with precision and scale. The precision represents the total number of digits that can be stored, while the scale represents the number of decimal places.
What Is LOB Data Type in Oracle? In Oracle, the LOB (Large OBject) data type is used to store large amounts of binary or character data. LOBs are ideal for storing text documents, images, videos, XML files, and other unstructured data that exceed the size limit of traditional data types.