Skip to content

Support create table

We must support two types of cluster-wide tables:

  • global (data is replicated and modified via raft log) - unsupported by sbroad at the moment
  • sharded - yes, we can!

SQL:

  1. Global table syntax
    create table t (a scalar null, b integer, primary key (a, b)) using memtx
    distributed globally option (timeout = 3.0)
    
    create table t (a scalar, b integer, primary key (a, b)) using memtx
    distributed globally
  2. Sharded table syntax
    create table t (a scalar, b integer not null, primary key (a)) using vinyl
    distributed by (a, b) option (timeout = 3)

Lua:

  1. Global table syntax
       pico.create_space({
           name = 'friends_of_peppa',
           format = {
               {name = 'id', type = 'unsigned', is_nullable = false},
               {name = 'name', type = 'string', is_nullable = false},
           },
           primary_key = {'id'},
           distribution = 'global',
           timeout = 3,
       })
  2. Sharded table syntax
       pico.create_space({
           name = 'wonderland',
           format = {
               {name = 'property', type = 'string', is_nullable = false},
               {name = 'value', type = 'integer', is_nullable = true}
           },
           primary_key = {'property'},
           distribution = 'sharded',
           sharding_key = {'property'},
           timeout = 3,
       })
Edited by Denis Smirnov