I'm trying to understand the relationship between two operations in SQL - ADD COLUMN and CAST(). I tried to create a new column containing the lengths of another column's values, while that other column is inconveniently of type INTEGER:
ALTER TABLE inventory
ADD inventory_id_len AS (CHAR_LENGTH(CAST(inventory_id AS VARCHAR)) FROM rental);
But it returns:
ERROR: syntax error at or near "AS"
LINE 4: ADD inventory_id_len AS (CHAR_LENGTH(CAST(inventory_id AS V...
Thanks.