The BOOLEAN data type is new, clean, and semantically correct. But most Oracle shops have years of NUMBER(1) and CHAR(1) boolean proxies in production schemas. Here’s how to migrate.
Auditing existing boolean-proxy columns:
-- Find NUMBER(1) columns that are likely booleans
SELECT table_name, column_name, data_type, data_length
FROM user_tab_columns
WHERE (data_type = 'NUMBER' AND data_precision = 1 AND data_scale = 0)
OR (data_type = 'CHAR' AND data_length = 1)
ORDER BY table_name, column_name;
Review results with your team. Not every NUMBER(1) is a boolean — some are small integer codes.
Migration pattern — NUMBER(1) to BOOLEAN:
-- Step 1: Add a new BOOLEAN column
ALTER TABLE products ADD is_active_bool BOOLEAN;
-- Step 2: Populate from existing column
UPDATE products SET is_active_bool = CASE WHEN is_active = 1 THEN TRUE ELSE FALSE END;
-- Step 3: Apply constraints
ALTER TABLE products MODIFY is_active_bool NOT NULL;
-- Step 4: Drop old column (after verifying app code is updated)
ALTER TABLE products DROP COLUMN is_active;
-- Step 5: Rename
ALTER TABLE products RENAME COLUMN is_active_bool TO is_active;
Application considerations:
JDBC drivers and ORMs need to be updated to handle Oracle’s BOOLEAN type. Oracle JDBC 23ai drivers support getBoolean()/setBoolean() natively. Older driver versions map Oracle BOOLEAN to NUMBER or VARCHAR2 — verify your driver version before migrating columns that applications read.
Rollout recommendation: Migrate boolean columns in new tables first (greenfield), then tackle high-traffic legacy tables during planned maintenance windows with connection pool drains.
