1 開啟clickhouse
service clickhouse-server start 開啟 clickhouse
clickhouse-client -m 進入clickhouse客戶端 -m 可以多行寫
2 建資料庫
create database db_name ; 建資料庫
use db_name ; 切換資料庫 ;
select currentdatabase()
; 檢視當前使用的資料庫
drop database db_doit19 ; 刪除資料庫
、
3 建表常用的資料型別
– 資料型別
int8 … int256log 引擎適用於臨時資料uint8 uint256 (age)
float32 float64 (double)
string
date
datetime
log 引擎不支援索引
如果寫入表失敗,則該錶將被破壞,並且從該錶讀取將返回錯誤
/var/lib/clickhouse/data/
default
/tb_user 資料儲存在這個位置下
log引擎的特點**資料儲存在本地的預設位置
資料是以列為檔案儲存
插入資料的時候是向檔案後面追加資料
xx.bin 對應的列資料
size.json 儲存的是每個檔案的大小
不支援索引
讀寫分離**
(1)建表
create table `tb_user`(
id string , 資料型別首字母大寫
name string ,
age uint8 ,
birthday date
)engine = log; 設定引擎
(2) 插入資料
不能同時讀寫自己 造成表損壞 刪除表目錄 重啟服務 刪除表(3) linux 位置下的檢視結果
-rw-r-----. 1 clickhouse clickhouse 54 dec 3 21:58 age.bin和log引擎比較底層資料儲存不會分塊 沒有__marks.mrk檔案-rw-r-----. 1 clickhouse clickhouse 56 dec 3 21:58 birthday.bin
-rw-r-----. 1 clickhouse clickhouse 68 dec 3 21:58 id.bin
-rw-r-----. 1 clickhouse clickhouse 64 dec 3 21:58 __marks.mrk
資料的塊偏移量(標記的縮寫)
-rw-r-----. 1 clickhouse clickhouse 69 dec 3 21:58 name.bin
-rw-r-----. 1 clickhouse clickhouse 151 dec 3 21:58 sizes.json – 長度
(描述檔案的大小)
Oracle資料庫 建庫 建表空間,建使用者
oracle資料庫 建庫 建表空間,建使用者 oracle安裝完後,其中有乙個預設的資料庫,除了這個預設的資料庫外,我們還可以建立自己的資料庫。對於初學者來說,為了避免麻煩,可以用 database configuration assistant 嚮導來建立資料庫。建立完資料庫後,並不能立即在資料庫...
Oracle資料庫 建庫 建表空間,建使用者
oracle安裝完後,其中有乙個預設的資料庫,除了這個預設的資料庫外,我們還可以建立自己的資料庫。對於初學者來說,為了避免麻煩,可以用 database configuration assistant 嚮導來建立資料庫。建立完資料庫後,並不能立即在資料庫中建表,必須先建立該資料庫的使用者,並且為該使...
Oracle資料庫 建庫 建表空間,建使用者
oracle安裝完後,其中有乙個預設的資料庫,除了這個預設的資料庫外,我們還可以建立自己的資料庫。對於初學者來說,為了避免麻煩,可以用 database configuration assistant 嚮導來建立資料庫。建立完資料庫後,並不能立即在資料庫中建表,必須先建立該資料庫的使用者,並且為該使...