Oracle databases do not have a native BOOLEAN data type like some other database systems. However, you can work with boolean-like values using alternatives, such as:
1. Number Type: Use NUMBER(1) to represent boolean values, where 0 represents FALSE and 1 represents TRUE. For example:
CREATE TABLE my_table (
is_active NUMBER(1)
);
2. Character Type: You can also use CHAR(1) or VARCHAR2 with values like ‘Y’ and ‘N’ to represent boolean states:
CREATE TABLE my_table (
is_active CHAR(1)
);
3. PL/SQL BOOLEAN: In PL/SQL (Oracle’s procedural extension), a BOOLEAN type exists, but it’s used only within the procedural code and not in the database schema. Example:
DECLARE
is_active BOOLEAN := TRUE;
BEGIN
— Use the boolean variable in logic
END;
While Oracle doesn’t directly support a BOOLEAN type in tables, these alternatives can effectively mimic boolean behavior.