You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/guides/creating-tables.md
+18-16Lines changed: 18 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,21 +1,23 @@
1
1
---
2
2
sidebar_position: 1
3
-
sidebar_label: 'Creating Tables'
4
-
title: 'Creating Tables in ClickHouse'
3
+
sidebar_label: 'Creating tables'
4
+
title: 'Creating tables in ClickHouse'
5
5
slug: /guides/creating-tables
6
6
description: 'Learn about Creating Tables in ClickHouse'
7
7
---
8
8
9
-
# Creating Tables in ClickHouse
9
+
# Creating tables in ClickHouse
10
10
11
11
Like most databases, ClickHouse logically groups tables into **databases**. Use the `CREATE DATABASE` command to create a new database in ClickHouse:
12
12
13
-
```sql
14
-
CREATEDATABASEIF NOT EXISTS helloworld
15
-
```
13
+
```sql
14
+
CREATEDATABASEIF NOT EXISTS helloworld
15
+
```
16
16
17
-
Similarly, use `CREATE TABLE` to define a new table. (If you do not specify the database name, the table will be in the
18
-
`default` database.) The following table named is `my_first_table` in the `helloworld` database:
17
+
Similarly, use `CREATE TABLE` to define a new table. If you do not specify the database name, the table will be in the
18
+
`default` database.
19
+
20
+
The following table named `my_first_table` is created in the `helloworld` database:
19
21
20
22
```sql
21
23
CREATETABLEhelloworld.my_first_table
@@ -36,21 +38,21 @@ In the example above, `my_first_table` is a `MergeTree` table with four columns:
36
38
-`timestamp`: a `DateTime` value, which represents an instant in time
37
39
-`metric`: a 32-bit floating point number
38
40
39
-
:::note
40
-
The table engine determines:
41
-
- How and where the data is stored
42
-
- Which queries are supported
43
-
- Whether or not the data is replicated
41
+
:::note
42
+
The table engine determines:
43
+
- How and where the data is stored
44
+
- Which queries are supported
45
+
- Whether or not the data is replicated
44
46
45
-
There are many engines to choose from, but for a simple table on a single-node ClickHouse server, [MergeTree](/engines/table-engines/mergetree-family/mergetree.md) is your likely choice.
46
-
:::
47
+
There are many engines to choose from, but for a simple table on a single-node ClickHouse server, [MergeTree](/engines/table-engines/mergetree-family/mergetree.md) is your likely choice.
48
+
:::
47
49
48
50
## A Brief Intro to Primary Keys {#a-brief-intro-to-primary-keys}
49
51
50
52
Before you go any further, it is important to understand how primary keys work in ClickHouse (the implementation
51
53
of primary keys might seem unexpected!):
52
54
53
-
- primary keys in ClickHouse are **_not unique_** for each row in a table
55
+
- primary keys in ClickHouse are **_not unique_** for each row in a table
54
56
55
57
The primary key of a ClickHouse table determines how the data is sorted when written to disk. Every 8,192 rows or 10MB of
56
58
data (referred to as the **index granularity**) creates an entry in the primary key index file. This granularity concept
0 commit comments