是否可以在SQL数据库中存储图片,声音,视频? [英] Is it possible to store pictures,sounds,videos in SQL Database?

查看:394
本文介绍了是否可以在SQL数据库中存储图片,声音,视频?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在SQL数据库(或任何其他数据库)中存储图片,声音,视频?如果是的,它应该是什么格式,请指定必须配置的特殊设置(如果有的话)。提前感谢。

Is it possible to store pictures,sounds,videos in SQL Database (or any other database) ? If yes what format should it be and please specifiy about the special settings that has to be configured if any. Thanks in advance.

推荐答案

在MySQL中,您可以使用BINARY或VARBINARY数据类型在列中存储任何二进制内容。所有数据库系统都是这样的数据类型。它可以用于存储完整的文件内容,如图片,视频,声音,或只是一个二进制片段。

In MySQL you can store any binary content in a table using the BINARY or VARBINARY data type for a column. Quite all database system as such a data type. It can be used to store a full file content such as picture, video, sound,... or just a binary snippet.

然而,将二进制文件存储在数据库被认为是一个坏的做法,因为它总是带来失望。实际上,存储在数据库中的文件不能被容易地处理用于下载,包括在HTML页面中,流式传输等。并且由于它的长度操作是相当总是复杂的。通常,与存储在目录中的文件相比,在数据库中排序的文件是不利的。建议将文件名存储在数据库库中,并将实际文件保存在物理目录中。

Nevertheless, storing binary files in a database is considered as a bad practice, because it quite always brings to disappointments. Indeed, a file stored in database cannot be easily processed for a download, an inclusion in a HTML page, a streaming, ... . And it is quite always complicated to manipulate because of its length. Most often, a file sorted in a database is disadvantageous compared to a file stored in a directory. Its is advised to store the file name in the database base, and save the actual file in a physical directory.

这篇关于是否可以在SQL数据库中存储图片,声音,视频?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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