How to store images in oracle

Source: Internet
Author: User

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:

 
 
  1. SQL> connect chanet/chanet@oradb; 

Connected.

 
 
  1. SQL> CREATE TABLE IMAGE_LOB (T_ID VARCHAR2 (5) NOT NULL,T_IMAGE BLOB  
  2.  
  3. NOT NULL);  

The table has been created.
SQL> CREATE OR REPLACE DIRECTORY IMAGES AS 'C: \ Oracle '; -- image DIRECTORY
The directory has been created.

 
 
  1. SQL> CREATE OR REPLACE PROCEDURE IMG_INSERT (TID VARCHAR2,FILENAME  
  2. VARCHAR2) AS  
  3.    F_LOB BFILE;  
  4.     B_LOB BLOB;  
  5. BEGIN  
  6.    INSERT INTO IMAGE_LOB (T_ID, T_IMAGE)  
  7.      VALUES (TID,EMPTY_BLOB ()) RETURN T_IMAGE INTO B_LOB;  
  8.    F_LOB:= BFILENAME ('IMAGES', FILENAME);  
  9.    DBMS_LOB.FILEOPEN (F_LOB, DBMS_LOB.FILE_READONLY);  
  10.    DBMS_LOB.LOADFROMFILE (B_LOB, F_LOB,  
  11.    DBMS_LOB.GETLENGTH (F_LOB));  
  12.    DBMS_LOB.FILECLOSE (F_LOB);  
  13.    COMMIT;  
  14. END;  
  15. /  
  16.  

The process has been created.

 
 
  1. 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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.