简体   繁体   English

Azure SQL,将数据库的大部分复制到现有服务器(不是新服务器)中

[英]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: 您可以通过几种方式执行此操作:

  1. Through the Azure Portal 通过Azure门户
    • Open your database in the Azure Portal( https://portal.azure.com ) 在Azure门户( https://portal.azure.com )中打开数据库
    • In the overview blade of your database select the "copy" option 在数据库的概述刀片中,选择“复制”选项 在此处输入图片说明
    • Fill in the parameters, in which server would you like the copy 填写参数,您要在哪个服务器中复制 在此处输入图片说明
  2. Using a sql server client and connecting to the server 使用SQL Server客户端并连接到服务器
    • Open your SQL Server blade in Azure 在Azure中打开您的SQL Server刀片服务器
    • Select the "Firewall" option 选择“防火墙”选项
    • Click on "Add client IP" 点击“添加客户端IP”
    • Connect to your database with your connection string and your favorite client, could be SSMS 使用您的连接字符串和您喜欢的客户端连接到数据库,可能是SSMS
    • Execute your sql query to clone the database in the same server 执行您的SQL查询以在同一服务器上克隆数据库
-- 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: 重要笔记:

  1. 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系统数据库 )。

  2. Logins that are not the server-level principal must be members of the dbmanager role in order to copy databases. 不是服务器级别主体的登录名必须是dbmanager角色的成员才能复制数据库。

  3. Use updated version of the SQL Server Management Studio 使用SQL Server Management Studio的更新版本

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我可以将数据从一个数据库表复制到另一个已经存在的数据库表sql服务器吗? - Can i copy data from one database table to another already existing database table sql server? 如何在SQL Server中将现有数据库的体系结构复制到新数据库 - How to copy architecture of an existing database to a new database in SQL Server 将带有加密列的 Azure SQL Server 数据库从一个订阅复制到另一个订阅的最佳方法 - Best way to copy an Azure SQL Server database with encrypted columns from one subscription to another 在不指定列的情况下将数据从一个SQL Server表复制到同一数据库中的其他表 - Copy Data from One SQL Server Table to Other in Same Database Without Specifying Columns SQL Server:将列数据值从一个表复制到同一数据库中的另一表 - SQL Server: copy column data values from one table to another table in the same database 使用同一数据库sql server中的一些过滤器将值从一个表A复制到表B - Copy value from one table A to table B with some filter in the same database sql server 在同一个表中的 SQL Server 中将数据从一行复制到另一行 - Copy data from one row to another in SQL Server in the same table 在 SQL 服务器中将 Partial Table 从一个数据库复制到另一个数据库 - Copy Partial Table from one database to another in SQL Server 将特定表数据从一个数据库复制到SQL Server中的另一个数据库 - Copy specific table data from one database to another in SQL Server 在 SQL Server 中将表从一个数据库复制到另一个数据库 - Copy tables from one database to another in SQL Server
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM