Kwil v2
Search…
⌃K

Conventions

Various rules regarding deploying Kwil databases

Naming

All names for Kwil database items (names for tables, columns, roles, indexes, databases, etc.) must begin with a letter. Furthermore, the names must only contain letters, numbers, and underscores. Names are not case sensitive.
Names are also constricted by length. See the chart below for specific items, and what their maximum length is:
Name Type
Max Length
Owner
44
Database
32
Table
32
Column
32
Role
32
Query
32
Index
32

Data Types

Kwil supports a restricted set of data types compared to other relational databases. We are constantly building support for more. If there is a data type your application would like to see added, please let us know! Below is a list of currently supported data types
Data Type
Kwil Abbreviation
Restrictions
Enum
Null
null
101
String
string
Can't be greater than 1024 characters
102
Signed 32-bit Integer
int32
103
Signed 64-bit Integer
int64
104
Boolean
boolean
105
UUID
uuid
Must be RFC-4122 compliant UUID
106
Note that for any data-type value you pass into the CLI via a JSON database structure, you will need to encode it.

Attributes

Attributes refer to a the properties and constraints of a column. A column can have multiple attributes. Some attributes require values to be defined with them. Below is a list of supported attributes:
Attribute
Value Type
Description
Enum
primary_key
nil
Defines a table column as a primary key. Only one column per table can have this attribute.
101
unique
nil
Every value in this column must be unique. Inserts/Updates violating a column's uniqueness will fail. This also automatically creates an index on the column.
102
not_null
nil
This column can not be null. Any transaction that makes this column null will be rejected.
103
default
any
If a value is not provided for this column in a transaction, then the specified value will be defaulted to.
104
min
int64
This specifies a minimum value for a column. Transactions violating this constraint will fail. This column must be either an int32 or int64.
105
max
int64
This specifies a maximum value for a column. Transactions violating this constraint will fail. This column must be either an int32 or int64.
106
min_length
int64
This specifies a minimum length for a column. This column must be a string type.
107
max_length
int64
This specifies a maximum length for a column. This column must be a string type.
108

Modifiers

Modifiers are special functions that alter a query input at execution time. An example of a modifier is "caller", which replaces the query input with the address of the function caller (similar to Solidity's msg.sender). Only one modifier can be added to a given input, however they are not required.
Modifier
Description
Requirements
Enum
No Modifier
No modifier is present on the column.
0
Caller
Replaces the input with the caller's address.
The input must be set to static and have a nil default value.
101

Comparison Operators

Comparison operators are used to dictate sorting and selection behavior for where-clauses. A single comparison operator can be assigned to a single where-clause, however multiple where-clauses can be chained together.
Operator
Symbol
Enum
Equal
=
101
Not Equal
!=
102
Greater Than
>
103
Greater Than or Equal
>=
104
Less Than
<
105
Less Than or Equal
<=
106

Query Types

Query types are used to specify the action of a query. Currently, Kwil supports 3 query types:
Type
Description
Enum
Insert
Creates a new row.
101
Update
Updates row(s) value(s) based on a set of where-clauses.
102
Delete
Deletes row(s) based on a set of where-clauses.
103

Index Types

Index types specify the how indexes are created and sorted.
Index Type
Enum
BTREE
101