Skip to main content

Schemas

A schema is a named namespace inside your GC2 (Geo Compute Cloud) database that groups tables, views and sequences. Within one schema two tables cannot share a name, but the same table name can be reused in different schemas; schema1.inductees and schema2.inductees are distinct tables.

In GC2 the schema is also the unit of ownership and addressing. Every sub-user owns a schema named after itself, and several APIs are schema-qualified: the SQL API and GraphQL resolve unqualified table names within a schema, and the OGC services expose one endpoint per schema. The Schema API below creates, lists, renames and deletes schemas, and a new schema can be created together with nested table definitions in a single request.

Add schema​

A new schema object can be empty (name is the only property) or contain nested tables.

Create new empty schema
POST https://api.gc2.io/api/v4/schemas HTTP/1.1
Content-Type: application/json
Authorization: Bearer abc123

{
"name": "rockhall"
}

Get schema​

You can either get a single schema or a collection of schemas. The schema object contains all nested object like tables, columns, indices and constraints. Use the namesOnly parameter to omit nested objects.

All schemas, names only
GET https://api.gc2.io/api/v4/schemas?namesOnly HTTP/1.1
Accept: application/json; charset=utf-8
Authorization: Bearer abc123
Specific schemas
GET https://api.gc2.io/api/v4/schemas/rockhall,anotherschema HTTP/1.1
Accept: application/json; charset=utf-8
Authorization: Bearer abc123

A schema object with nested objects looks like this.

{
"name": "rockhall",
"tables": [
{
"name": "inductees",
"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
}
]
}

Rename schema​

PATCH https://api.gc2.io/api/v4/schemas/rockhall HTTP/1.1
Content-Type: application/json
Authorization: Bearer abc123

{
"name": "rock_roll_of_hall"
}

Delete schema​

danger

Be careful when deleting schemas - all nested objects will also be deleted!

DELETE https://api.gc2.io/api/v4/schemas/rock_roll_of_hall HTTP/1.1
Authorization: Bearer abc123