Do we have any File Table / File Stream like support in any other database than MS SQL Server?
-
10-03-2021 - |
Question
I am looking for an alternative to Microsoft SQL Server's File Tables / File Stream feature. The reason is because I really wanted to use SQL Server File Tables but I am on Linux and using docker.
Unfortunately, Microsoft does not provide any support for Linux when it comes to File Tables. See this Issue which is still open. MySQL or PostgreSQL is preferable though.
SQL Server File Tables uses Operating System's File System to store files and synchronize these file values in SQL Tables. It is much faster than saving a BLOB. Also, it is backed up if I run Database Backup. So, its using File System for speed but also keeping it synchronized with Database. I can also access the files via File System and / or via transactions.
Solution
The alternative implementation in the past was to store the files on a shared location and store their location's reference in the database in a table.
Here are the current options for modern DBMS:
Oracle PL/SQL - Loading documents and other file data into the Oracle Database: Full Text or Binary Data with BFiles or External Tables might be closest to what your use case is.
MySQL: BLOB Storage: Seems like there's not much alternative in MySQL (aside from storing the reference to the file's location).
PostgreSQL: Storing Binary Data & Are there performance issues storing files in PostgreSQL?: Can use the bytea data type or the Large Object feature which stores the data in dedicated table.
MongoDB: BSON Types & GridFS: BSON data types can store data up to 16 MB in size, after that GridFS is the solution for larger storage (especially for binary data).
SQLite: Can we store .doc .pdf and .jpg files in SQLite Database (Android)? & Datatypes in SQLite Version 3: BLOBs are the go-to in SQLite.
MariaDB: LOAD_FILE: There doesn't seem to be a lot of support in MariaDB at all, but in general they also use BLOB storage have a LOAD_FILE function.
AWS: SimpleDB: While this isn't achievable via Docker, just for reference for anyone adamant about storing files in the database, their SimpleDB (among some of their other services) offer ways to somewhat store files in the database and use meta-data to tag what kind of file they are (typically leveraging S3 buckets).
Here's also an oldie but goodie on the pros and cons of storing large files in the database.