在雪花中使用计划任务克隆具有动态名称的数据库 [英] Using schedule tasks in snowflake to clone DB's with dynamic names

查看:189
本文介绍了在雪花中使用计划任务克隆具有动态名称的数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用雪花任务计划程序来克隆一个或所有具有动态克隆数据库名称的数据库,如下所示,是否可以在不创建存储过程的情况下进行.由于我的帐户下有多个数据库,我希望将所有数据库克隆到一个任务中

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

创建数据库xx_date 克隆xx

create database xx_date clone xx

感谢您的答复

谢谢

推荐答案

是否可以在不创建存储过程的情况下完成该操作

Is it possible to do it without creating a Stored Procedure

CREATE TASK 语句语法允许指定一个SQL语句,并且 语句语法不允许一次指定多个对象.

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.

Ps 如果大量克隆的基本目标是维护备份,也请考虑

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.

这篇关于在雪花中使用计划任务克隆具有动态名称的数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆