Using schedule tasks in snowflake to clone DB's with dynamic names

徘徊边缘 提交于 2020-06-29 03:48:14

问题


I want to use snowflake Task scheduler to clone one or all of the DB's with dynamic clone DB name something like below,Is it possible to do it without creating Stored procedure.As I have multiple DB under my account I would prefer to clone all of the DB's in one task

create database xx_date clone xx

I appreciate your response

Thanks,


回答1:


Is it possible to do it without creating a Stored Procedure

The CREATE TASK statement syntax only allows for a single SQL statement to be specified, and the CREATE … CLONE statement syntax does not permit specifying more than one object at a time.

Given the above, this isn't possible currently. You will need to use an iteration of database names from within a stored procedure call. The same stored procedure can also be used to clean up older dated clones from previous task invocations.

For incorporating dates into a dynamically generated statement within the stored procedure, checkout this question.

P.s. If the underlying goal of the numerous clones is to maintain backups, also consider cross-account, cross-region (and/or) cross-cloud replication for better safety.



来源:https://stackoverflow.com/questions/62186019/using-schedule-tasks-in-snowflake-to-clone-dbs-with-dynamic-names

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