[英]Copy local SQL database onto Azure
I want to do the - should be simple - task of copying a database from local to live... 我想做 - 应该很简单 - 将数据库从本地复制到实时的任务...
I have all the data and table structure I want in my local database. 我在本地数据库中拥有所需的所有数据和表结构。
I have a currently running database live database that has all the backup stuff assigned to it etc so I don't just want to create a brand new database (not that I can find how to do this either)... 我有一个当前运行的数据库实时数据库,其中包含分配给它的所有备份内容等,所以我不只是想创建一个全新的数据库(不是我可以找到如何做到这一点)...
I just want to remove all tables from that database and then copy all my data and tables from the local into the live azure sql database. 我只想从该数据库中删除所有表,然后将我的所有数据和表从本地复制到live azure sql数据库中。
How do I do this??? 我该怎么做呢???
you can try to achieve this with SQL Server Management Studio. 您可以尝试使用SQL Server Management Studio实现此目的。
Jump around because it worked, now run the following command on the azure table to disable foreign key migrations: 跳转因为它工作,现在在azure表上运行以下命令以禁用外键迁移:
DECLARE @sql NVARCHAR(MAX) = N'';
;WITH x AS ( SELECT DISTINCT obj = QUOTENAME(OBJECT_SCHEMA_NAME(parent_object_id)) + '.' + QUOTENAME(OBJECT_NAME(parent_object_id)) FROM sys.foreign_keys ) SELECT @sql += N'ALTER TABLE ' + obj + ' NOCHECK CONSTRAINT ALL; ' FROM x; EXEC sp_executesql @sql;
now go into sql server management studio and right click on your local database and goto tasks and then export data 现在进入sql server management studio并右键单击本地数据库并转到任务然后导出数据
the data is moved, now set the foreign keys back using this on your azure database: 移动数据,现在在azure数据库上使用此键设置外键:
DECLARE @sql NVARCHAR(MAX) = N'';
;WITH x AS ( SELECT DISTINCT obj = QUOTENAME(OBJECT_SCHEMA_NAME(parent_object_id)) + '.' + QUOTENAME(OBJECT_NAME(parent_object_id)) FROM sys.foreign_keys ) SELECT @sql += N'ALTER TABLE ' + obj + ' WITH CHECK CHECK CONSTRAINT ALL; ' FROM x;
EXEC sp_executesql @sql;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.