如何在 SQL Server 中声明一个 blob [英] How to declare a blob in SQL Server

查看:38
本文介绍了如何在 SQL Server 中声明一个 blob的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想对我的数据库做一些测试(比如在机器还在写东西的时候关掉它).为此,我计划将一个 700 mb 的电影文件插入到数据库中,以便我有时间插入并关闭它(而不是立即完成某事).

I want to do some tests to my database (like turning off the machine while it's still writing something). To do this, I'm planning to insert a movie file into the database with 700mb, so that I can have time to insert it and turn it off (instead of being something done instantaneously).

我使用的是 SQL Server 2008,我能在数据类型中找到的最接近的是 Binary(50).这足以满足我的要求吗?

I'm using SQL Server 2008, and the closest I can find in the data types is Binary(50). Is this enough for what I want?

我想知道存储这个大文件的列必须是哪种数据类型.

I want to know which data type must the column that will store this large file be.

推荐答案

Binary(50) 将容纳 50 个字节 - 这不足以容纳 700mb.

Binary(50) will hold 50 bytes - this is not going to be enough to hold 700mb.

来自 MSDN:

二进制 [ ( n ) ]

binary [ ( n ) ]

长度为 n 字节的定长二进制数据,其中 n 是 1 到 8,000 之间的值.存储大小为 n 字节.

Fixed-length binary data with a length of n bytes, where n is a value from 1 through 8,000. The storage size is n bytes.

你应该使用VARBINARY(MAX):

可变长度的二进制数据.n 可以是 1 到 8,000 之间的值.max 表示最大存储大小为 2^31-1 字节.存储大小为输入数据的实际长度+2个字节.

Variable-length binary data. n can be a value from 1 through 8,000. max indicates that the maximum storage size is 2^31-1 bytes. The storage size is the actual length of the data entered + 2 bytes.

您也可以使用 Image,虽然它已被弃用.

You could also use Image, though it is deprecated.

这篇关于如何在 SQL Server 中声明一个 blob的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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