Tables
A table is much like a table on paper: It consists of rows and columns. The number and order of the columns is fixed, and each column has a name. The number of rows is variable — it reflects how much data is stored at a given moment.
Get table
You can either get a single table or a collection of tables. The schema object contains all nested object like
columns, indexes and constraints. Use the namesOnly
parameter to omit nested objects.
- HTTP
- CLI
All tables, names only
GET https://api.centia.io/api/v4/schemas/myschema/tables?namesOnly HTTP/1.1
Accept: application/json; charset=utf-8
Authorization: Bearer abc123
Specific tables
GET https://api.centia.io/api/v4/schemas/myschema/tables/mytable,anothertable HTTP/1.1
Accept: application/json; charset=utf-8
Authorization: Bearer abc123
cen table get "myschema" "anotherschema"
A table object with nested objects looks like this:
{
"name": "my_new_table",
"columns": [
{
"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
},
{
"name": "name",
"type": "character varying",
"is_nullable": true,
"default_value": null,
"comment": null,
"_num": 2,
"_full_type": "character varying",
"_typname": "varchar",
"_is_array": false,
"_character_maximum_length": -5,
"_numeric_precision": null,
"_numeric_scale": null,
"_max_bytes": 1073741824,
"_reference": null,
"_restriction": null,
"_is_primary": false,
"_is_unique": false,
"_index_method": null,
"_checks": null
}
],
"indices": [
{
"name": "my-new-table-primary",
"method": "btree",
"unique": true,
"columns": [
"id"
]
}
],
"constraints": [
{
"name": "my-new-table-primary",
"constraint": "primary",
"columns": [
"id"
]
}
],
"comment": null
}
Add table
A new table object can be empty (name is the only property) or contain nested columns, indexes and constraints.
- HTTP
- CLI
Create new empty table
POST https://api.centia.io/api/v4/schemas/myschema HTTP/1.1
Content-Type: application/json
Authorization: Bearer abc123
{
"name": "mytable"
}
cen table add "myschema" "mytable"
Rename and move table
You can move a table to another schema by setting the schema
property.
- HTTP
- CLI
PATCH https://api.centia.io/api/v4/schemas/myschema/tables/mytable HTTP/1.1
Content-Type: application/json
Authorization: Bearer abc123
{
"name": "mytable2",
"schema": "myschema2"
}
cen schema rename "myschema" "mytable" "mytable2"
cen schema move "myschema" "mytable" "mytable2"
Delete table
- HTTP
- CLI
DELETE https://api.centia.io/api/v4/schemas/myschema/tables/mytable HTTP/1.1
Authorization: Bearer abc123
cen table drop "myschema" "mytable"