Skip to main content

Columns

A column is one named field of a table, and every column has a PostgreSQL data type. The type constrains which values the column accepts and gives them meaning: a numeric column rejects arbitrary text and can be used in calculations, a text column accepts almost anything but supports string operations instead, and a PostGIS geometry column turns the table into a map layer. See Types for how each type is sent and returned through the API.

The Column API lets you evolve a table's structure after it has been created: add a column, read its definition, rename it, change its type, nullability or default value, and drop it. Because the SQL API does not accept DDL statements, this API, the CLI and the Web App are the ways to alter columns on a GC2 (Geo Compute Cloud) table.

Get column​

You can either get a single column or a collection of columns.

All columns for a table
GET https://api.gc2.io/api/v4/schemas/rockhall/tables/columns HTTP/1.1
Accept: application/json; charset=utf-8
Authorization: Bearer abc123
Specific column
GET https://api.gc2.io/api/v4/schemas/rockhall/tables/inductees/columns/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,
"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 to null.
  • 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 always or by default.

Add column​

Add column in the GC2 Web App

Rename, set type, set nullable, set default​

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

Edit column properties in the GC2 Web App

note

The type of a column can only be changed to a type that is compatible with the existing data.

Delete column​

Delete column in the GC2 Web App