I'm learning SQL and Snowflake and I'd like to change some metadata of a table. I'm trying to understand what is a good practice in the following case.
I want to change properties for 4 columns (but not all in the Table):
1. COLUMN_DEFAULT for 2 columns
2. IS_NULLABLE for 2 columns
Additionally, the table already is filled with values. I need to preserve data in the table. Only those 4 columns that need to have properties changed will have different values.
What would be the best approach?
- Create new (proper) schema
- Clone table and assigned it to the new schema and add some prefix
- Drop an old table
- Rename the new to the name of the old one
Is that the correct way of doing it?
Or maybe:
- Create a copy of 4 columns that need to have changed properties inside the table. And create them with already poroper properties
- Drop old columns
- Rename freshly created columns.
Or maybe somet other way is better? I'd appreciate your suggestions.