During the development process, images are often stored in oracle. The following describes how to easily store images in oracle. It is helpful to you.
Any development tool can store image files in a database by calling the process.
Detailed steps for saving images in oracle:
- SQL> connect chanet/chanet@oradb;
Connected.
- SQL> CREATE TABLE IMAGE_LOB (T_ID VARCHAR2 (5) NOT NULL,T_IMAGE BLOB
-
- NOT NULL);
The table has been created.
SQL> CREATE OR REPLACE DIRECTORY IMAGES AS 'C: \ Oracle '; -- image DIRECTORY
The directory has been created.
- SQL> CREATE OR REPLACE PROCEDURE IMG_INSERT (TID VARCHAR2,FILENAME
- VARCHAR2) AS
- F_LOB BFILE;
- B_LOB BLOB;
- BEGIN
- INSERT INTO IMAGE_LOB (T_ID, T_IMAGE)
- VALUES (TID,EMPTY_BLOB ()) RETURN T_IMAGE INTO B_LOB;
- F_LOB:= BFILENAME ('IMAGES', FILENAME);
- DBMS_LOB.FILEOPEN (F_LOB, DBMS_LOB.FILE_READONLY);
- DBMS_LOB.LOADFROMFILE (B_LOB, F_LOB,
- DBMS_LOB.GETLENGTH (F_LOB));
- DBMS_LOB.FILECLOSE (F_LOB);
- COMMIT;
- END;
- /
-
The process has been created.
- SQL> EXEC IMG_INSERT('1','f_TEST.jpg');
The PL/SQL process is successfully completed.
Implementation of oracle tree Query
Oracle table space query statements
Learn more about Oracle hierarchical Query
Provides you with an in-depth understanding of Oracle temporary tables
Learn how Oracle queries work