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.
- HTTP
- CLI
GET https://api.centia.io/api/v4/schemas/myschema/tables/columns HTTP/1.1
Accept: application/json; charset=utf-8
Authorization: Bearer abc123
GET https://api.centia.io/api/v4/schemas/myschema/tables/mytable/colums/id HTTP/1.1
Accept: application/json; charset=utf-8
Authorization: Bearer abc123
cen column get "myschema" "mytable" "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,
"_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
}
Add column
- HTTP
- CLI
POST https://api.centia.io/api/v4/schemas/myschema/tables/mytable HTTP/1.1
Content-Type: application/json
Authorization: Bearer abc123
{
"name": "id",
"type": "integer"
}
cen table add "myschema" "mytable" "id" integer
Rename, set type, set nullable, set default
You can change name, type, default and nullable of a column or collection of columns.
- HTTP
- CLI
PATCH https://api.centia.io/api/v4/schemas/myschema/tables/mytable/columns/id HTTP/1.1
Content-Type: application/json
Authorization: Bearer abc123
{
"name": "id2",
"type": "varchar",
"default": "Na",
"nullable": true
}
cen schema rename "myschema" "mytable" "id" "id2"
cen schema type "myschema" "mytable" "id" int8
cen schema nullable "myschema" "mytable" "id" true
cen schema default "myschema" "mytable" "id" 100
Delete column
- HTTP
- CLI
DELETE https://api.centia.io/api/v4/schemas/myschema/tables/mytable/columns/id HTTP/1.1
Authorization: Bearer abc123
cen column drop "myschema" "mytable" "id"