/ Published in: SQL
Boolean values (usually represented as Checkboxes in a User Interface)
This is efficient because is does not suffer the clumsy and inefficient case problems of WHERE UPPER(column) = UPPER(variable);
Expand |
Embed | Plain Text
CREATE TABLE booleans ( isBoolean char(1) DEFAULT 1 NOT NULL CHECK ( isBoolean (1,0) ) ); comment ON COLUMN booleans.isBoolean IS 'boolean: 1 for True, 0 for False'; CREATE bitmap INDEX isBoolean_index_name ON booleans(isBoolean); ALTER TABLE table_name ADD ( is_boolean integer DEFAULT 1 NOT NULL CHECK ( is_boolean IN (1,0) ) ); comment ON COLUMN table_name.is_boolean IS 'boolean: 1 for True, 0 for False'; CREATE bitmap INDEX is_boolean_index_name ON table_name(is_boolean); -- Faster sorting and searching for low-cardinality data SET serveroutput ON begin dbms_output.enable; IF package.boolean_function then dbms_output.put_line('True'); else dbms_output.put_line('False'); end IF; end; /
You need to login to post a comment.
