糟糕!使用保留字来命名列 [英] Oops! used a reserved word to name a column
问题描述
我制作了一个大查询表,其中的一列名为行"(不带引号)... doh!现在,如果我引用该列,则sql无法编译:
I made a bigquery table with one column named "row" (no quotes)... doh! Now my sql won't compile if I reference that column:
SELECT row, etext FROM [hcd.hdctext] LIMIT 1; =ERROR"
我没有在GQL中看到"ROW"作为保留字...
I did not see "ROW" as a reserved word in GQL...
我看到在某些系统中,您可以通过反引号解决该问题:
I saw that in some systems you can get around that problem with backticks :
SELECT `row`, etext FROM [hcd.hdctext] LIMIT 1;
有什么方法可以在bigquery中做同样的事情?否则,我将不得不重新上传200M的数据并重新开始.似乎更改字段名称并不是一个大功能..但是我对数据的存储方式不了解.
Any way to do the same in bigquery? Otherwise I will have to reupload my 200M of data and start again. Seems like changing a field name would not be a big feature.. but I am naive about how the data is stored.
谢谢!
推荐答案
BigQuery旧版SQL使用[]
作为引号字符. BigQuery Standard SQL使用反引号.
BigQuery Legacy SQL uses []
as quote chars. BigQuery Standard SQL uses backticks.
因此,对于旧版SQL,只需使用
So, for Legacy SQL, just use
SELECT [row], etext from [hcd.hdctext]
如果您想永久重命名,目前尚无办法,但是您可以在查询中重命名并保存结果...只需使用
If you want to rename it permanently, there isn't a way to do that currently, but you can rename it in a query and save the results... just use
SELECT [row] as newname, .... FROM [hcd.hdctext]
并指定允许大结果"和目标表名称.
and specify 'allow large results' and a destination table name.
这篇关于糟糕!使用保留字来命名列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!