问题
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