Views (normal, columns) v1

Description

This page provides information about normal views in the database, on a per-column basis.

  1. Notes regarding views

Columns

Name Type
schema_id int8
schema varchar
view_id int8
view varchar
column_ordinal int2
column varchar
data_type_id int8
base_data_type_name varchar
data type varchar

Column Descriptions

schema_id

The schema ID. This column is emitted in CSV exports only.

schema

The schema name.

view_id

The view ID. This column is emitted in CSV exports only.

Surprisingly, view IDs turn out to be unique across all databases.

view

The view name.

column_ordinal

The column ordinal. This column is emitted in CSV exports only.

Column ordinals are unique to a single table.

In pg_attribute, ordinals for user columns count from 1, system columns are negative.

In stv_blocklist, ordinals for user columns count from 0, and system columns have a rather extraordinary numbering, in that they are the numbers after the final user column, which is to say, the system column numbers vary by table.

(I believe stv_blocklist internally is using unsigned variables, in part from this numbering issue, but also because I’ve been able to make num_values overflow, and when it overflows, it looks like an unsigned value which has wrapped and is then having its bit pattern interpreted as a signed value, where Redshift data types are all signed.)

In pg_attribte, you see quite a number of system columns, but in fact most vestigial, left-overs from Postgres, and do not exist on disk. Only three system columns are actually in use, which have the ordinals -2, -8 and -9, being the row ID, MVCC insert transaction ID and MVCC delete transaction ID, although offhand I cannot remember which is which (although I do recall it’s not the order you’d expect - I have a feeling -8 is the row ID).

column

The column name.

data_type_id

The data type ID. This column is emitted in CSV exports only.

base_data_type_name

This is the base data type name, which is to say, the data type name but sans adornment; no length, or precision, or scale. Just the name.

data type

This is the full data type name, which is to say, the data type name with adornment; showing length, or precision and scale.