为什么在数据库 table 中存储文件不是一个好习惯?
Why is not a good practice to store files in a database table?
建议将文件存储到网络服务器上的目录中。为什么不对存储文件的列使用 BLOB
数据类型?有安全性和一致性优势,这样做更容易管理文件。缺点是什么?
主要的原因是 space 和性能损失可能相当大,数据库存储通常比文件系统存储更昂贵。这是一个很好的 resource discussing it.
Also this SO thread 包含了这场辩论的所有内容
It's recommended to store file into a directory on web server
并非总是如此——此外,这根本不适用于没有网络服务器的情况(例如内部本机应用程序)。
Why not use a BLOB data type for a column where store files?
这取决于您的应用程序的规模和用例。这些斑点代表什么?它们会定期更新吗?有缓存或分发系统的机会吗?
There are security and consistency advantages and it's easier to manage files doing that. What are the cons?
性能是主要原因。由于 DBMS 引入的开销,从数据库读取通常总是比从磁盘读取慢。由于数据库系统内部的存储布局,写入也相当昂贵。
建议将文件存储到网络服务器上的目录中。为什么不对存储文件的列使用 BLOB
数据类型?有安全性和一致性优势,这样做更容易管理文件。缺点是什么?
主要的原因是 space 和性能损失可能相当大,数据库存储通常比文件系统存储更昂贵。这是一个很好的 resource discussing it.
Also this SO thread 包含了这场辩论的所有内容
It's recommended to store file into a directory on web server
并非总是如此——此外,这根本不适用于没有网络服务器的情况(例如内部本机应用程序)。
Why not use a BLOB data type for a column where store files?
这取决于您的应用程序的规模和用例。这些斑点代表什么?它们会定期更新吗?有缓存或分发系统的机会吗?
There are security and consistency advantages and it's easier to manage files doing that. What are the cons?
性能是主要原因。由于 DBMS 引入的开销,从数据库读取通常总是比从磁盘读取慢。由于数据库系统内部的存储布局,写入也相当昂贵。