Can columns be renamed?

Is it possible to issue something like

RENAME COLUMN col1 col2

      

to Google Cloud Spanner? The DDL shows that this is not possible; if not, is it a design choice or limitation while in beta?

+1


source to share


1 answer


No, It is Immpossible. Currently, you can only do the following in relation to changing columns in a table:

  • Add new
  • Remove existing if it is not a key column
  • Change delete behavior (cascading or not)
  • Conversion between STRING

    andBYTES

  • Change the length STRING

    andBYTES

  • Add or remove modifier NOT NULL

You can work by following the following steps:



  • Add new column to table
  • Update your code to read from both columns.
  • Update your code to write only to the new one
  • Run a Cloud Dataflow Job to transfer data from the old column to the new column
  • Update your read-only code from the new column
  • Drop the old column

Keep in mind that the above steps will not work for the primary key column, you will have to do this by creating a new table and migrating the data that way.

+3


source







All Articles