Skip to content

Commit

Permalink
Update boolean.md
Browse files Browse the repository at this point in the history
  • Loading branch information
den-crane authored May 17, 2022
1 parent 23a61b1 commit f7ead85
Showing 1 changed file with 30 additions and 2 deletions.
32 changes: 30 additions & 2 deletions docs/ru/sql-reference/data-types/boolean.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,35 @@ sidebar_position: 43
sidebar_label: "Булевы значения"
---

# Булевы значения {#bulevy-znacheniia}
# Булевы значения bool (boolean) {#bulevy-znacheniia}

Отдельного типа для булевых значений нет. Для них используется тип UInt8, в котором используются только значения 0 и 1.
Тип `bool` хранится как UInt8. Значения `true` (1), `false` (0).

```sql
select true as col, toTypeName(col);
┌─col──┬─toTypeName(true)─┐
│ true │ Bool │
└──────┴──────────────────┘

select true == 1 as col, toTypeName(col);
┌─col─┬─toTypeName(equals(true, 1))─┐
1 │ UInt8 │
└─────┴─────────────────────────────┘
```

```sql
CREATE TABLE test_bool
(
`A` Int64,
`B` Bool
)
ENGINE = Memory;

INSERT INTO test_bool VALUES (1, true),(2,0);

SELECT * FROM test_bool;
┌─A─┬─B─────┐
1 │ true │
2 │ false │
└───┴───────┘
```

0 comments on commit f7ead85

Please sign in to comment.