英文:
How to generate random string of specific length in Google Cloud SQL and/or Bigquery?
问题
I'm trying to update a table that has missing data with some unique strings, that I try to generate randomly.
SELECT CODE_POINTS_TO_BYTES(
[CAST(FLOOR(100RAND()) AS INT64),
CAST(FLOOR(100RAND()) AS INT64),
CAST(FLOOR(100RAND()) AS INT64),
CAST(FLOOR(100RAND()) AS INT64)]) AS bytes;
This is what I've tried but I'm getting the following error:
英文:
I'm trying to update a table that has missing data with some unique strings, that I try to generate randomly.
SELECT CODE_POINTS_TO_BYTES(
[CAST(FLOOR(100*RAND()) AS INT64),
CAST(FLOOR(100*RAND()) AS INT64),
CAST(FLOOR(100*RAND()) AS INT64),
CAST(FLOOR(100*RAND()) AS INT64)]) AS bytes;
This is what I've tried but I'm getting the following error:
答案1
得分: 0
看起来在添加第四个参数时出现了问题,它能够查询到第三个转换。
并且在添加第四个参数时捕获了相同的错误。
正如 @nbk 提到的,您可以尝试使用 uuid
> 选择 GENERATE_UUID() AS uuid;
英文:
It looks like it is having problems when adding the fourth parameter.it is able to query up to the 3rd cast.
and captures the same error when added the 4th parameter.
As @nbk mentioned you can try using uuid
> SELECT GENERATE_UUID() AS uuid;
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论