Skip to content

Commit

Permalink
Create how-to-convert-ordinary-to-atomic.md
Browse files Browse the repository at this point in the history
  • Loading branch information
den-crane committed Oct 13, 2021
1 parent 39c48aa commit c214358
Showing 1 changed file with 53 additions and 0 deletions.
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 │
└───────────────────────────────────┘
```

0 comments on commit c214358

Please sign in to comment.