3

I am using the below code:

ALTER TABLE `trim-opus-308402.Covid_Dataset_SQL_Practice_24May21.Percentage vaccine`
ADD COLUMN Vaccine_Coverage numeric AS  ((Rolling_vaccination / population)*100)

I am getting error message:

ALTER TABLE ADD COLUMN does not support generated columns yet at [2:12]

Slava Rozhnev
  • 9,510
  • 6
  • 23
  • 39

1 Answers1

2

You can add an empty column to your schema using this syntax, but I don't think you can fill it in the same operation. You might consider a two step approach:

ALTER TABLE `trim-opus-308402.Covid_Dataset_SQL_Practice_24May21.Percentage vaccine`
ADD COLUMN Vaccine_Coverage NUMERIC;

UPDATE `trim-opus-308402.Covid_Dataset_SQL_Practice_24May21.Percentage vaccine`
SET Vaccine_Coverage = (Rolling_vaccination / population)*100
WHERE TRUE;
Cylldby
  • 1,783
  • 1
  • 4
  • 17