Default values for columns in Big Query Tables

萝らか妹 提交于 2021-02-18 21:09:27

问题


Is there a way to set default values for columns in tables in big query? I would like to set 'false' as a default value for a column of boolean data type.


回答1:


A nullable column can (trivially) have a NULL default value, but there is no other notion of default in BigQuery (you either insert a particular value or omit the value and it will have the NULL value).

That said, if you want to wrap your raw table in a View, you can map a NULL column value to any default that you like.




回答2:


There is no default values for columns in BigQuery
The simple way would be just to use NULL (in most cases this should be acceptable from requirements prospective)
Also conside cost aspect of this - storing NULL as a default cost you zero versus storing actual value will cost you column size multipled by count of rows with default values

If NULL will work for you but you still need to have your real default value for use in application - you can use field description to store some metadata about this field including default value, so than application will be able to retrieve it and use it based on whatever application logic is

In BigQuery - View is the best way to expose your real default value



来源:https://stackoverflow.com/questions/37623395/default-values-for-columns-in-big-query-tables

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!