Hop til hovedindhold

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.

All columns for a table
GET https://api.centia.io/api/v4/schemas/myschema/tables/columns HTTP/1.1
Accept: application/json; charset=utf-8
Authorization: Bearer abc123
Specific column
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

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

Create new column
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"
}

Rename, set type, set nullable, set default

You can change name, type, default and nullable of a column or collection of columns.

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
}

Delete column

DELETE https://api.centia.io/api/v4/schemas/myschema/tables/mytable/columns/id HTTP/1.1
Authorization: Bearer abc123