Columns
Each column has a data type. The data type constrains the set of possible values that can be assigned to a column and assigns semantics to the data stored in the column so that it can be used for computations. For instance, a column declared to be of a numerical type will not accept arbitrary text strings, and the data stored in such a column can be used for mathematical computations. By contrast, a column declared to be of a character string type will accept almost any kind of data but it does not lend itself to mathematical calculations, although other operations such as string concatenation are available.
Get column
You can either get a single column or a collection of columns.
- Web App
- HTTP
- CLI
GET https://api.centia.io/api/v4/schemas/rockhall/tables/columns HTTP/1.1
Accept: application/json; charset=utf-8
Authorization: Bearer abc123
GET https://api.centia.io/api/v4/schemas/rockhall/tables/inductees/columns/id HTTP/1.1
Accept: application/json; charset=utf-8
Authorization: Bearer abc123
centia column get "rockhall" "inductees" "id"
A column object with nested objects looks like this. All properties prefixed with an _ (underscore) is read only.
If submitted in a POST or PATCH they will be ignored.
{
"name": "id",
"type": "integer",
"is_nullable": false,
"default_value": null,
"comment": null,
"identity_generation": null,
"_num": 1,
"_full_type": "integer",
"_typname": "int4",
"_is_array": false,
"_character_maximum_length": null,
"_numeric_precision": 32,
"_numeric_scale": 0,
"_max_bytes": 4,
"_reference": null,
"_restriction": null,
"_is_primary": true,
"_is_unique": true,
"_index_method": [
"btree"
],
"_checks": null
}
Properties
- name: Name of the column.
- type: The type of the column, such as
varchar,integer,boolean, etc. - is_nullable: If
true, the column can be set tonull. - default_value: The column is set to the default value if no value is provided.
- comment: A comment or description for the column.
- identity_generation: An identity column is a special column generated automatically from an implicit sequence. It can be used to generate key values. Possible values are
alwaysorby default.
Add column
- Web App
- HTTP
- CLI
POST https://api.centia.io/api/v4/schemas/rockhall/tables/inductees HTTP/1.1
Content-Type: application/json
Authorization: Bearer abc123
{
"name": "id",
"type": "integer"
}
POST https://api.centia.io/api/v4/schemas/rockhall/tables/inductees HTTP/1.1
Content-Type: application/json
Authorization: Bearer abc123
[
{ "name": "id", "type": "integer"},
{ "name": "name", "type": "varchar(50)"}
]
centia table add "rockhall" "inductees" "id" integer
Rename, set type, set nullable, set default
You can change name, type, default and nullable of a column or collection of columns.
- Web App
- HTTP
- CLI
PATCH https://api.centia.io/api/v4/schemas/rockhall/tables/inductees/columns/name HTTP/1.1
Content-Type: application/json
Authorization: Bearer abc123
{
"name": "name2",
"type": "varchar(100)",
"default_value": "Empty",
"is_nullable": false
}
centia schema rename "rockhall" "inductees" "id" "id2"
centia schema type "rockhall" "inductees" "name" varchar(100)
centia schema nullable "rockhall" "inductees" "name" false
centia schema default "rockhall" "inductees" "name" "Empty"
The type of a column can only be changed to a type that is compatible with the existing data.
Delete column
- Web App
- HTTP
- CLI
DELETE https://api.centia.io/api/v4/schemas/rockhall/tables/inductees/columns/id,name HTTP/1.1
Authorization: Bearer abc123
centia column drop "rockhall" "inductees" "id"