> ## Documentation Index
> Fetch the complete documentation index at: https://cockroachlabs.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# BOOL

export const InternalLink = ({version, path = "", children, ...props}) => {
  let detectedVersion = version || "stable";
  if (typeof window !== 'undefined' && !version) {
    const match = window.location.pathname.match(/\/docs\/([^/]+)/);
    if (match) {
      detectedVersion = match[1];
    }
  }
  const normalizedPath = path.startsWith("/") ? path.slice(1) : path;
  return <a href={`/docs/${detectedVersion}/${normalizedPath}`} {...props}>
      {children}
    </a>;
};

The `BOOL` <InternalLink path="data-types">data type</InternalLink> stores a Boolean value of `false` or `true`.

## Aliases

In CockroachDB, `BOOLEAN` is an alias for `BOOL`.

## Syntax

There are two predefined <InternalLink path="sql-constants#named-constants">named constants</InternalLink> for `BOOL`: `TRUE` and `FALSE` (the names are case-insensitive).

Alternately, a boolean value can be obtained by coercing a numeric value: zero is coerced to `FALSE`, and any non-zero value to `TRUE`.

* `CAST(0 AS BOOL)` (false)
* `CAST(123 AS BOOL)` (true)

## Size

A `BOOL` value is 1 byte in width, but the total storage size is likely to be larger due to CockroachDB metadata.

## Examples

```sql theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
> CREATE TABLE bool (a INT PRIMARY KEY, b BOOL, c BOOLEAN);
```

```sql theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
> SHOW COLUMNS FROM bool;
```

```
  column_name | data_type | is_nullable | column_default | generation_expression |  indices  | is_hidden
--------------+-----------+-------------+----------------+-----------------------+-----------+------------
  a           | INT8      |    false    | NULL           |                       | {primary} |   false
  b           | BOOL      |    true     | NULL           |                       | {primary} |   false
  c           | BOOL      |    true     | NULL           |                       | {primary} |   false
(3 rows)
```

```sql theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
> INSERT INTO bool VALUES (12345, true, CAST(0 AS BOOL));
```

```sql theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
> SELECT * FROM bool;
```

```
+-------+------+-------+
|   a   |  b   |   c   |
+-------+------+-------+
| 12345 | true | false |
+-------+------+-------+
```

## Supported casting and conversion

`BOOL` values can be <InternalLink path="data-types#data-type-conversions-and-casts">cast</InternalLink> to any of the following data types:

| Type      | Details                                |
| --------- | -------------------------------------- |
| `INT`     | Converts `true` to `1`, `false` to `0` |
| `DECIMAL` | Converts `true` to `1`, `false` to `0` |
| `FLOAT`   | Converts `true` to `1`, `false` to `0` |
| `STRING`  | ––                                     |

## See also

<InternalLink path="data-types">Data Types</InternalLink>
