我有一个来自大型数据库的
.bacpac
文件。
问题是它包含一个表,该表的文件存储为
varbinary
并且非常大。这张表太大了,无法在本地恢复。
我想恢复
.bacpac
文件,但指示它忽略 varbinary
列。
如果这是 RAW BCP,我知道我可以为此表构建一个格式文件,它只是跳过该列(将其保留为空,这很好)。但是,我无法弄清楚如何或在何处应用 BCP 命令在
.bacpac
文件的结构中执行此操作?
有没有办法为
.bacpac
恢复提供指令以忽略单个表列(就像我在 BCP 中所做的那样)?或者也许是一种编辑.bacpac
文件(zip)内容以在这个单一表上插入BCP操作指令的方法?
我不知道在 bacpac 恢复期间有选择地意识到忽略特定列的直接选项。我能想到的2个选项:
选项一
将数据库恢复到 azure 或 sql server 中的临时数据库
使用脚本创建一个没有 varbinary 列的新数据库,并将数据从临时数据库复制到新数据库。
-- Create a new database
CREATE DATABASE NewDatabase;
GO
-- Switch to the new database
USE NewDatabase;
GO
-- Create the schema and table without the varbinary column
CREATE SCHEMA YourSchema;
GO
CREATE TABLE YourSchema.YourTable (
Column1 DataType1,
Column2 DataType2,
--...
-- Exclude the varbinary column
--...
ColumnN DataTypeN
);
GO
-- Insert data from the temporary database to the new one (excluding the varbinary column)
INSERT INTO YourSchema.YourTable (
Column1, Column2, /*...,*/ ColumnN
)
SELECT
Column1, Column2, /*...,*/ ColumnN
FROM
TempDatabase.YourSchema.YourTable;
GO
选项2