<p>I'm about to implement a feature in our application that allows the user to 'upload' a PDF or Microsoft PowerPoint document, which the application will then make available to other users in a viewer (so they don't get to 'download' it in the 'Save as..' sense).</p>

<p>I already know how to save and retrieve arbitrary binary information in database columns, but as this will be a commonly used feature of our application I fear that solution would lead to enormously large database tables (as we know one of our customers will want to put video in PowerPoint documents).</p>

<p>I know there's a way to create a 'directory' object in Oracle, but is there a way to use this feature to store and retrieve binary files saved elsewhere on the Database Server?</p>

<p>Or am I being overly paranoid about the database size?</p>

<p>(for completeness our application is .Net WinForms using <a href="http://www.devart.com/oranet/" rel="nofollow noreferrer">CoreLab / DevArt OraDirect.Net drivers</a> to Oracle 10g)</p>

[{'answer_id': 62968, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 4, 'selected': True, 'text': '<p>Couple of options: You could put the BLOB column in its own tablespace, with its own storage characteristics; you could store the BLOBs in their own table, linked to the other table by an ID column.  In either case as you suggested you could define the column as a BFILE which means the actual file is stored externally from the database in a directory.  What might be a concern there is that BFILE LOBs do not participate in transactions and are not recoverable with the rest of the database.</p>\n\n<p>This is all discussed in the Oracle 10gR2 SQL reference, chapter 2, starting on page 23.</p>\n'}, {'answer_id': 62984, 'author': 'Matthew Watson', 'author_id': 3839, 'author_profile': 'https://Stackoverflow.com/users/3839', 'pm_score': 1, 'selected': False, 'text': '<p>I guess it depends what you consider enormously large.</p>\n\n<p>It really does depend on the use case. If the documents are only being accessed rarely then putting it in the database would be fine (with the advantage of getting "free" backups, eg, with the database).</p>\n\n<p>If these are files which are going to be hit over and over again, you might be better to put them directly on disk and just store the location, or even (if its really high bandwidth) look into something like <a href="http://en.wikipedia.org/wiki/MogileFS" rel="nofollow noreferrer">MogileFS</a></p>\n\n<p>No one is going to be able to give you a Yes or no answer for this.</p>\n'}, {'answer_id': 62997, 'author': 'Bad Hedgehog', 'author_id': 7250, 'author_profile': 'https://Stackoverflow.com/users/7250', 'pm_score': 1, 'selected': False, 'text': "<p>You could use a normal LOB column type and set the storage parameters for that field so it's on a seperate tablespace.  Create the tablespace somewhere that can handle having huge amounts of data thrown at it and you'll minimise the impact.</p>\n\n<p>To be seriously super paranoid about disk usage you could additionally compress the tablespace by marking it as such.  Something along the lines of:</p>\n\n<p>CREATE TABLESPACE\n  binary_data1\nDATAFILE\n  some_san_location\nDEFAULT COMPRESS STORAGE(...)</p>\n"}, {'answer_id': 63003, 'author': 'JosephStyons', 'author_id': 672, 'author_profile': 'https://Stackoverflow.com/users/672', 'pm_score': 1, 'selected': False, 'text': '<p>In my experience, a simple VARCHAR2 field containing the file name of the attachments is a better and easier solution.  File system size is a lot easier to manage than database size.</p>\n'}, {'answer_id': 63040, 'author': 'MarcE', 'author_id': 7262, 'author_profile': 'https://Stackoverflow.com/users/7262', 'pm_score': 1, 'selected': False, 'text': "<p>The data has to live somewhere, whether it's internal to the DB or whether you just store a link to a (server) accessible file path, you're still chewing space.</p>\n\n<p>I've just used simple LOB fields in the past, it seemed to work fine. If you keep the data inside the DB at least you keep your backup hassles low - you may have a lot of data to back up but when you restore it, it'll all be there. Splitting the binary out means you potentially break the DB or lose data if you're not careful about what you backup.</p>\n"}, {'answer_id': 63340, 'author': 'Lost Plugin Writer', 'author_id': 7425, 'author_profile': 'https://Stackoverflow.com/users/7425', 'pm_score': 1, 'selected': False, 'text': "<p>One reason to just store the link or an ID that can be used to build the link is that the storage that you usually use for Oracle DB's is rather expensive.  If you have lots of large files, it is usually much more cost-effective to put them on a less expensive array of disks.</p>\n"}]
['https://Stackoverflow.com/questions/62876', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/5662/']