- Installation
- Guides
- Data Import & Export
- CSV Import
- CSV Export
- Parquet Import
- Parquet Export
- Query Parquet
- HTTP Parquet Import
- S3 Parquet Import
- Meta Queries
- Python
- SQL Editors
- Documentation
- Connect
- Data Import
- Client APIs
- Overview
- Python
- R
- Java
- C
- Overview
- Startup
- Configure
- Query
- Data Chunks
- Values
- Types
- Prepared Statements
- Appender
- Table Functions
- Replacement Scans
- API Reference
- C++
- Node.js
- Wasm
- CLI
- SQL
- Introduction
- Statements
- Overview
- Select
- Insert
- Delete
- Update
- Create Schema
- Create Table
- Create View
- Create Sequence
- Create Macro
- Drop
- Alter Table
- Copy
- Export
- Query Syntax
- Data Types
- Expressions
- Functions
- Overview
- Numeric Functions
- Text Functions
- Pattern Matching
- Date Functions
- Timestamp Functions
- Time Functions
- Interval Functions
- Date Formats
- Date Parts
- Blob Functions
- Nested Functions
- Utility Functions
- Indexes
- Aggregates
- Window Functions
- Samples
- Information Schema
- Configuration
- Pragmas
- Extensions
- Development
- Sitemap
- Why DuckDB
- FAQ
- Code of Conduct
- Live Demo
Name | Aliases | Description |
---|---|---|
BOOLEAN |
bool | logical boolean (true/false) |
The BOOLEAN
type represents a statement of truth (“true” or “false”). In SQL, the boolean field can also have a third state “unknown” which is represented by the SQL NULL value.
-- select the three possible values of a boolean column
SELECT TRUE, FALSE, NULL::BOOLEAN;
Boolean values can be explicitly created using the literals TRUE
and FALSE
. However, they are most often created as a result of comparisons or conjunctions. For example, the comparison i > 10
results in a boolean value. Boolean values can be used in the WHERE
and HAVING
clauses of a SQL statement to filter out tuples from the result. In this case, tuples for which the predicate evaluates to TRUE
will pass the filter, and tuples for which the predicate evaluates to FALSE
or NULL
will be filtered out. Consider the following example:
-- create a table with the value (5), (15) and (NULL)
CREATE TABLE integers(i INTEGER);
INSERT INTO integers VALUES (5), (15), (NULL);
-- select all entries where i > 10
SELECT * FROM integers WHERE i > 10;
-- in this case (5) and (NULL) are filtered out:
-- 5 > 10 = FALSE
-- NULL > 10 = NULL
-- The result is (15)
Expressions
See Logical Operators and Comparison Operators.