[英]Azure SQL, Copy most of a database into an existing one (not new one) same server
I know I can clone DB into a new one with 我知道我可以使用以下方法将数据库克隆到一个新数据库中
CREATE DATABASE Database1_copy AS COPY OF Database1; 创建数据库Database1_copy作为Database1的副本;
( https://docs.microsoft.com/en-us/azure/sql-database/sql-database-copy-transact-sql ) ( https://docs.microsoft.com/zh-cn/azure/sql-database/sql-database-copy-transact-sql )
and this goes flawesly, except in Azure, where db properties are managed by Azure portal, so I am try to find a way to copy most of the schema/resources/data into an EXISTING DB 这是有缺陷的,除了在Azure中,数据库属性是由Azure门户管理的Azure之外,因此,我尝试寻找一种将大多数架构/资源/数据复制到现有数据库中的方法
would be great for: 将非常适合:
CLONE DATABASE Database_test AS COPY OF Database_production 克隆数据库Database_test作为Database_production的副本
[even first approach has been to "clone" the entire db, indeed few tables on destination db should be kept, so better approach would be to CLONE EVERYTHING EXCEPT ('table1','table2'). [甚至第一种方法都是“克隆”整个数据库,实际上目标数据库上应该保留很少的表,因此更好的方法是克隆所有内容('table1','table2')。 Actually plan to achieving this by scripting the few tables needed on destination db and overwriting them after import, but bet solution would be the other] 实际计划通过编写目标db所需的几个表并将其导入后覆盖这些表的脚本来实现此目的,但下注解决方案是另一种方法]
You can do this in several ways: 您可以通过几种方式执行此操作:
-- Copy a SQL database to the same server
-- Execute on the master database.
-- Start copying.
CREATE DATABASE Database1_copy AS COPY OF Database1;
https://docs.microsoft.com/en-us/azure/sql-database/sql-database-copy-transact-sql https://docs.microsoft.com/zh-cn/azure/sql-database/sql-database-copy-transact-sql
The above SQL statement works perfectly fine as expected in Azure SQL Database. 上面的SQL语句在Azure SQL数据库中可以按预期正常运行。
Important Notes: 重要笔记:
Log on to the master database
( System Databases ) using the server-level principal login
or the login that created the database you want to copy. 使用server-level principal login
或创建要复制的数据库的登录名登录到master database
( 系统数据库 )。
Logins that are not the server-level principal must be members of the dbmanager role in order to copy databases. 不是服务器级别主体的登录名必须是dbmanager角色的成员才能复制数据库。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.