Reputation: 4245
I want to create an empty column with a specific type in a select query.
This is how I can do it without specifying the type:
Select *, Null as new_empty_colum from my_table;
In this examples, it creates it of type string
.
My question is how can I specify the type of new_empty_colum
and why does it make it as string
when I don't specify a type?
Upvotes: 0
Views: 1415
Reputation:
Untyped values default to text
, if you want to force a specific type, you have to cast the null
value:
select *, cast(null as numeric) as new_empty_column
from my_table
Upvotes: 2