Search code examples
google-cloud-platformlooker-studiogoogle-cloud-spanner

GCP SPANNER: What options can be set on a column in table other than allow_commit_timestamp=true for timestamp datatype


I want to understand what properties can be set on a Column in Spanner table. I only see length, not null, allow_commit_timestamp=true (for timestamp).

Do we have any options like: - Unique property - so that record insert gives an error if another record has the same value (not same as not null) - Default value or bounded list - if not provided by application layer or for validation - Comments: like a short description of that column and who created it

My impression is that all these are not available in SPANNER for a column and has to be handled in the business layer. Can someone confirm!


Solution

    1. Unique Property: Cloud spanner does support unique indexes. We can create unique index on the column that we want to enforce uniqueness.
    2. Default values: Cloud Spanner doesn't allow any default value to be specified regardless of type. This means the implicit default is Null, or Error, depending on whether to column was specified with NOT NULL.
    3. Comments: This isn't supported currently.