1、視圖
a) 普通視圖:不會存儲數據
b) 物化視圖:1、儲存數據;2、有引擎,在磁盤存儲;3、同步映射表數據
2、表引擎Log系列
4.1 TinyLog 1、最簡單的引擎 2、沒有索引,沒有標記塊 3、寫是追加寫 4、數據以列字段文件存儲 5、不允許同時讀寫 4.2 StripeLog 1、data.bin存儲所有數據 2、index.mrk對數據建立索引 3、size.json 數據大小 4、並發讀寫 4.3 Log 1、*.bin存儲每個字段的數據 2、mark.mrk 數據塊標記 3、支持多線程處理 4、並發讀寫
3、普通建表
create table : default(默認字段)、comment(字段注釋)、默認是UTF8 跨數據庫復制表結構: create table as databaseName.tableName 跨數據庫復制表結構和數據: create table engine=xxx as select * from tableName
4、臨時表
create temporary table log as select * from databaseName.tableName 1、不屬於任何數據庫,不需要指定引擎 2、會話斷開以后表刪除、不會持久化 3、如果本地表和臨時表沖突,臨時表優先 4、作用:數據庫之間的數據遷移
5、分區表DDL
1、創建分區表 create table ....... partition by columnName 2、查看分區內容: select partition ,name ,table from system.parts where .... 3、刪除分區:alter table drop partition "" 4、修改分區:alter table tableName replace partition "" from b 5、清除分區中的某個字段的值:alter table tableName clear columnName id in partition 6、卸載分區數據detach: alter table account detach partition 'AA' 7、裝載分區數據attach: alter table account attach partition 'AA'
6、DDL修改表結構
1、添加字段:alter table tableName add column columnName type 2、刪除字段:alter table tableName drop column columnName type 3、修改字段:alter table tableName modify column columnName type 4、增加注釋:alter table tableName comment columnName '注釋' 5、移動表|重命名: rename table a to b rename table a to newdb.a rename table a to newdb.b
