Skip to content

[2pt] Add columns to existing tables in SQL #1650

@TarantoolBot

Description

@TarantoolBot

Add columns to existing tables in SQL

Product: Tarantool (SQL)
Since: 2.7.1
Audience/target: Tarantool users
Root document: https://www.tarantool.io/en/doc/latest/reference/reference_sql/sql_statements_and_clauses/#alter-table
SME: @romanhabibov
Peer reviewer: @

Details

Now, it is possible to add columns to existing empty spaces using
<ALTER TABLE table_name ADD [COLUMN] column_name column_type ...>
statement. The column definition is the same as in
statement.

  • Space emptiness is Tarantool's restriction. Possibilty to add
    column to non empty space will be implemented later.

For example:

tarantool> box.execute("CREATE TABLE test (a INTEGER PRIMARY KEY)")
---
- row_count: 1
...

tarantool> box.execute([[ALTER TABLE test ADD COLUMN b TEXT
         >                                           CHECK (LENGTH(b) > 1)
         >                                           NOT NULL
         >                                           DEFAULT ('aa')
         >                                           COLLATE "unicode_ci"
         >             ]])
---
- row_count: 1
...

Requested by @romanhabibov in tarantool/tarantool@6cff902.

Metadata

Metadata

Assignees

Labels

reference[location] Tarantool manual, Reference partsql[location] SQL manual

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions