Documentation

CREATE TABLE

   
ℹ️NOTE This page contains information that only applies to SQL Preview functionality (more information here). Additionally, this page represents a work in progress that is subject to frequent changes.

Creates a FeatureBase table. The the table already exists and IF NOT EXISTS is not specified the statement will not be successful. The identifier for the table must conform to the rules of FeatureBase identifiers.

Syntax

expr

column_def

expr

You must specify an _id column for CREATE TABLE to be successful. The type for the _id column can be id for a non-keyed table or string for a keyed table. No column constraints are permitted for the _id column. The identifier for each column must conform to the rules of FeatureBase identifiers. Valid type names are specified in Data Types. decimal types require a scale to be specified.

type_name

expr

See also Data Types.

column_constraint

Column constraints are optional for columns.

expr

Constraint Type Applies to Comment
TIMEQUANTUM
optional: TTL
IDSET, STRINGSET Input:
timequantum:
YMD ,YM,Y
ttl:
<integer>+ h, m, s, ms, us, ns
Defaults:
timequantum:
Not set by default
ttl:
0s
CACHETYPE (type and size) IDSET, STRINGSET, ID, STRING Input:
type:ranked, none
size:
Integer? boundary?
Defaults:
type:ranked
size:50000
MIN, MAX INT Input:
Integer values only
Defaults:
Min Defaults to -2^63
Max Defaults to 2^63 - 1
TIMEUNIT TIMESTAMP Input:
”s”, “ms”, “us”, “ns” (basically go Duration)
Defaults:
“s”
EPOCH TIMESTAMP Input:
RFC339 time stamp string
The epoch which timestamps should be relative to. The value may specify a timezone, for example 1980-11-30T14:20:28.000+07:00, or use zulu time (i.e. +00:00) 1980-11-30T14:20:28.000Z.
Defaults:
The Unix epoch (1970-01-01T00:00:00Z)

table_options

expr

Table Option Comment
KEYPARTITIONS integer literal; between 1-10000
SHARDWIDTH integer literal; must be a power of two greater than or equal to 2^16

Example

create table allcoltypes (
	_id id,
	intcol int min 0 max 10000, 
	boolcol bool, 
	timestampcol timestamp timeunit 'ms' epoch '2022-01-01T00:00:00Z', 
	decimalcol decimal(2), 
	stringcol string cachetype ranked size 1000, 
	stringsetcol stringset cachetype lru size 1000, 
	stringsetcolq stringset cachetype lru size 1000 timequantum 'ymd' ttl '24h', 
	idcol id cachetype ranked size 1000, 
    idsetcol idset cachetype lru size 1000,
	idsetcolq idset cachetype lru size 1000 timequantum 'ymd' ttl '24h'
) keypartitions 12 shardwidth 65536
Something missing or incorrect?
Help improve this article or join us on Discord!

© 2022 Molecula Corp. (DBA FeatureBase). All rights reserved.