lightdb轻松创建分布表
熟悉分布式的,都知道,创建分布式表,至少需要两步
CREATE TABLE t1(a int,b text);
SELECT create_distributed_table('t1', 'a');
lightdb即将分布的版本,将支持一步创建分布式表
在原先CREATE TABLE语法中增加DISTRIBUTED BY和DISTRIBUTED REPLICATED关键字,分别用来创建Distributed Table 和Reference Table
--Create reference tables:
CREATE TABLE dist_reference_table(a int, b text) DISTRIBUTED REPLICATED;
--Create distributed hash tables:
CREATE TABLE dist_table(a int, b text) DISTRIBUTED BY(a);
CREATE TABLE dist_hash_table(a int, b text) DISTRIBUTED BY HASH(a);
--Create distributed append tables:
CREATE TABLE dist_append_table(a int, b text) DISTRIBUTED BY APPEND(a);
--Create distributed tables, specify 4 shard count:
CREATE TABLE dist_shard_table(a int, b text) DISTRIBUTED BY(a) shard_count(4);
--Create distributed tables, specify colocate with dist_table.
CREATE TABLE dist_colocate_table(a int, b text) DISTRIBUTED BY (a) colocate_with('dist_table');
语义与原生的SELECT create_distributed_table()、SELECT create_reference_table()一致