-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create how-to-convert-ordinary-to-atomic.md
- Loading branch information
Showing
1 changed file
with
53 additions
and
0 deletions.
There are no files selected for viewing
53 changes: 53 additions & 0 deletions
53
...engines/altinity-kb-atomic-database-engine/how-to-convert-ordinary-to-atomic.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
--- | ||
title: "How to Convert Ordinary to Atomic" | ||
linkTitle: "Ordinary to Atomic" | ||
weight: 100 | ||
description: >- | ||
Clickhouse Howto Convert Ordinary to Atomic | ||
--- | ||
|
||
## Example How to Convert Ordinary to Atomic | ||
|
||
```sql | ||
create database db engine=Ordinary; | ||
create table db.test(A Int64) Engine=MergeTree order by A; | ||
|
||
create materialized view db.test_mv(A Int64) | ||
Engine=MergeTree order by A as select * from db.test; | ||
|
||
insert into db.test select * from numbers(1000); | ||
|
||
create database db_temp engine=Atomic; | ||
|
||
rename table db.test to db_temp.test; | ||
rename table db.test_mv to db_temp.test_mv; | ||
|
||
drop database db; | ||
rename database db_temp to db; | ||
|
||
use db; | ||
show tables; | ||
┌─name───────────────────────────────────────────┐ | ||
│ .inner_id.37db402c-fc46-421d-b7db-402cfc46921d │ | ||
│ test │ | ||
│ test_mv │ | ||
└────────────────────────────────────────────────┘ | ||
|
||
insert into db.test select * from numbers(1000); | ||
|
||
select count() from test; | ||
┌─count()─┐ | ||
│ 2000 │ | ||
└─────────┘ | ||
|
||
select count() from test_mv; | ||
┌─count()─┐ | ||
│ 2000 │ | ||
└─────────┘ | ||
|
||
show create database db; | ||
┌─statement─────────────────────────┐ | ||
│ CREATE DATABASE db | ||
ENGINE = Atomic │ | ||
└───────────────────────────────────┘ | ||
``` |