To store a file in an Oracle database, you can use the BLOB (Binary Large Object) data type. The following is an example of how to store a file in an Oracle database using SQL*Plus:
- Create a table with a BLOB column to hold the file:
CREATE TABLE file_storage ( id NUMBER PRIMARY KEY, file_name VARCHAR2(100), file_data BLOB );
2. Insert a file into the table using the SQL*Loader utility:
sqlldr userid=username/password control=filename.ctl
The filename.ctl file should contain the following information:
load data infile 'filename' into table file_storage fields terminated by "," (id, file_name, file_data char(20000000))
Replace “filename” with the actual name of the file you want to insert.
3. Query the file from the database:
SELECT file_data FROM file_storage WHERE id = 1;
- Replace “1” with the actual ID of the file you want to retrieve.
Note: The above example uses SQLPlus and SQLLoader to insert the file into the database. You can also use other tools and programming languages to accomplish the same task.