简体   繁体   中英

what is the Best way to store 10MB in sql server

What is the Best way to store object almost equal 10MB in SQL Server , storing files maybe will be PDF or Image.

Do you recommend me to use File System(storing path) or database?

objects smaller than 256K are best stored in a database while objects larger than 1M are best stored in the filesystem

You need to decide what to do with objects between 256K and 1M.

Have a read of this Microsoft Research article - which explains this: To BLOB or Not To BLOB: Large Object Storage in a Database or a Filesystem

Like previous answers have mentioned you should consider if you really need to store binary files in DB in the first place. It may or may not be a good idea. See also this SO question .

Assuming your data set is relatively small and you DO want to give blob storage responsibility to DB then you should consider if you can use FILESTREAM. Note that it rules out DB mirroring, but on upside - it gives great transactional support and integrity over backup/restore scenarios. Something that is quite painful to do properly when storing files in file system directly. Read more about FileStream here .

Assuming you cannot use FileStream or the number of stored files is really small then I'd prefer having a separate blob storage table that contains ONLY the binary + technical PK. That table should never be scanned, just insert/delete/getById. Also, do not use the image type as it is deprecated ( link ):

ntext, text, and image data types will be removed in a future version of Microsoft SQL Server. Avoid using these data types in new development work, and plan to modify applications that currently use them. Use nvarchar(max), varchar(max), and varbinary(max) instead.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM