Oracle Database processing Multimedia Information _oracle

Source: Internet
Author: User
Tags create directory sql using oracle database
The Oracle tutorial you are looking at is: Oracle database processing Multimedia information.

Citation:

For a long time, multimedia information in the computer is stored in file form, managed by the operating system, but with the development of computer network, distributed computing, multimedia information for efficient management, access, query has become an urgent need. But the relational database has the formidable data management ability. The combination of the two, the multimedia database emerged. This article will make an overview of Oracle's multimedia information processing methods, tools, features and some basic principles.

However, we can not but regret to see that the existing database for some multimedia data unique operational capacity is still very limited. The performance tuning for multimedia databases is now encountering a new problem. However, the multimedia database still has a wide application value and foreground.
Of course, this article can not be exhaustive, for Oracle multimedia information processing specific content, please consult Oracle related manuals.

I. Overview of application Prospects

With the computer processing capacity of the first officer to improve, multimedia has been integrated into the computer, if the lack of multimedia, the lack of a variety of images, audio, video, it is difficult to imagine the computer will now go into millions of households. For a long time, multimedia information in the computer are stored in the form of files, by the operating system management, but with the computer network, the development of distributed computing, this simple file-type management has been powerless, multimedia information for efficient management, access, query has become an urgent need. But the relational database has the formidable data management ability. With the combination of two aspects, the multimedia database emerges as a result. It can be foreseen that the application of multimedia database will be more and more extensive with the enhancement of multimedia processing demand.

Oracle as a well-known database manufacturer, in multimedia information processing, is walking in the front. This article will make an overview of Oracle's multimedia information processing methods, tools, features and some basic principles. Hope to enlighten the reader. Of course, there are many relational databases, although the development tools, programming interface statements are different, but in the data type, processing mode is more similar. So we're skipping over here.

Two. Introduction of multimedia data types

In relational databases, large objects such as multimedia information are accessed by LOB fields. In oracle8i, this standard has been introduced to meet the needs of large-scale multimedia object processing. In an Oracle database, there are several types of LOB data:

--------------------------------------------

LOB type description

Clob: Similar to the long type of Oracle7, Clob can store single-byte data

Nclob:nclob storage of Set-width multibyte country character Set data

Blob: Similar to the long raw type in Oracle7. Binary data with no structure can be stored. Oracle8 does not interpret this data, but stores and retrieves it in its original form.

Bfile:bfile allows read-only access to large binaries stored outside of an Oracle database. Unlike the other three types of LOB data, the bfile type data is stored in a separate file that is not maintained by Oracle.

Characteristics:

1. In Oracle7, the corresponding long or long raw field has a 2g limit, and the LOB limit is 4g.

2.lob can be manipulated using the call interface OCI or by Pl/sql using the Dbms_lob package.

3.lob is not as long as the limit of a maximum of one field per table, it can have multiple, and can take advantage of the characteristics of the trigger.

4.lob data processing can obtain the same thing characteristics as other data.

5.lob storage is special, it is not stored in the same database table with other data, but can be stored separately in different tablespaces, with a locator point to the actual LOB data.

[NextPage]

Three. Multimedia large object access routines examples

Follow the steps below to complete each operation:

(1) First set up a database table:

CREATE table Lobdemo (Key number Key,clob_col clob,blob_col Blob,bifle_col BFILE);

The first column of this database stores one code, and the other three columns store lob data.

(2) After the table is built, insert a piece of data into the table:

Insert into Lobdemo (Key,clob_col,blob_col,bfile_col) VALUES (10, ' Abcdefghijklmnopqrsatuvwxyzasdffasfsdafsdafsdfadfsadfsdfsdfdsdsffds ', Empty_blob (), NULL);

In this piece of data, we insert a string that is formatted to store CLOB type data, and the second column we use the Empty_blob () function to initialize a locator, and then we can get the locator to do things like select,update. The third column is null, and it does not get a locator, which is the difference from the Empty_blob () function.

(3) query inserts the data in the table

Select Blob_col from Boldemo where key=20;

Note: The return result of this SQL statement is a locator character (locator) rather than the actual data itself.

(4) Modify the data in the database

Update Lobdemo SET blob_col= ' Aedevbagddgagdfdfasasdfdsa ' where key=10;

From these SQL statements, we see the basic method of LOB data processing and find similar to other types of data processing. But the characteristics of LOB-type data processing in SQL statements are as follows:

(1) Processing of bfile Documents:

bfile type has particularity, differs from Clob,blob. The actual data file is stored outside the operating system: so there are two features: 1. No transactional control 2.bfile is read-only and cannot be modified with Dbms_lob or Oracl8 OCI. Let's take a look at the steps to bfile:

<1> to access external files, the server needs to know where the files are located in the operating system. Below we create a directory:
Create DIRECTORY utils as '/home/utils ';
Utils represents the directory logical name, and '/home/utils ' is the actual directory.

<2> insert a row of data using the Bfilename function:

Insert into Lobdemo (Key,bfile_col) VALUES ( -1,biflename (' utils ', ' file1 '));

The first parameter of the Bfilename function is the logical directory name, and the second parameter is the filename. Note: This line inserts a LOB locator that points to/home/utils/file1, not the file itself.

(2) Using DBMS_LOB packet for LOB data operation

SQL can manipulate only the entire lob, not the data slice. The DBMS_LOB package releases this restriction, which provides operations on the data slices in LOB data. This package contains more than 10 routines that readers can refer to in the Oracle Pl/sql Manual, which describes only three functions: FileOpen () to open an operating system file; LoadFromFile () routines populate an operating system file with the destination LOB field. This function is useful because there are many lob content that is not descriptive in the SQL statement, such as a binary audio file, which can be used to import the contents of the file into the database; the GetLength function calculates the length of the file. Consider the use of these three functions in one of the following stored procedures:

Create or replace procedure fileexec (
P_directory in VARCHAR2,
P_filename in VARCHAR2
) as
V_filelocator BFILE;
V_cloblocator CLOB;
BEGIN
--Initializes a locator for update
SELECT Clob_col
Into V_cloblocator
From Lobdemo
WHERE Key=-1
For UPDATE;

--Initializes a bfile locator for the read file

V

[1] [2] Next page

The Oracle tutorial you are looking at is: Oracle database processing Multimedia information. _filelocator:=bfileopen (P_derectory,p_filename);

--Open an operating system file with the FileOpen of the Dbms_lob package

Dbms_lob. FILEOPEN (V_filelocator,dbms_lob. FILE_READONLY);

--load the entire operating system file into the LOB

Dbms_lob. LoadFromFile (V_cloblocator,v_filelocator,dbms_lob. GetLength (V_filelocator));

End Fileexec;

Four. Introduction to Oracle intermedia Tools

Intermedia is an integrated component of Oracle's extended oracle8i Multimedia feature that makes it easier for Oracle to manage images, audio, video, text, and more. Enables Oracle to enhance the reliability and usability of multimedia data management in the Internet, E-commerce and other fields. It includes image, audio, video three parts. Intermedia uses object types, similar to Java or C + +, to describe image, audio, and video type data, and Oracle defines many methods for manipulating the data in these three types of objects, such as for image type data, You can easily convert graphics format, compress, copy, intercept any part of the graph, and these are the ordinary LOB type data can not be compared to ordinary SQL statements can not complete these operations.

The development of the Internet has highlighted the value of Intermedia in Web application, most of the existing Web applications will be image,audio,video and other multimedia information in the file system, its advantages are simple operation, fast, the disadvantage is the management of complex, In particular, the management of a large number of image is limited by the number of directories. If you save image in a database, unified maintenance by the database, unified backup, so you can simplify management.

Several multimedia object types are defined in Intermedia, such as Ordaudio, which provides manipulation functions for audio object type data. Let's take a look at an example where we define a song object, create a table for a song object, and insert and query the table.

(1) Define a Song object:

CREATE TYPE Songobject as OBJECT (
SongID VARCHAR2 (20),--Song number
Title VARCHAR2 (4000),--title
Artist VARCHAR2 (4000),--writer
Awards VARCHAR2 (4000),--awards
TimePeriod VARCHAR2 (20),--Date time
Txtinroduction CLOB,--Introduction
Audiosource Ordsys. Ordaudio-Audio data, this field is defined by the Ordaudio object.
);

(2) Establish a table named Songtable:

CREATE TABLE songstable of Songobject (UNIQUE (songid), songid not NULL);

(3) Inserting a row of data into the songstable table

INSERT into songstable VALUES (' 00 ',
' Under pressure ',
' Queen ',
' No awards ',
' 80-90 ',
243,
Null
Empty_clob (),
Ordsys. Ordaudio (NULL,
Ordsys. Ordsource (Empty_blob (), Null,null,null,null,null),
NULL, NULL, EMPTY_CLOB (), NULL, NULL, NULL, NULL, NULL, NULL);
Attention:. The Empty_clob,empty_blob () function simply initializes a LOB data locator and does not store the actual data.

(4) Load a row of data into the songstable table:

DECLARE
Audioobj Ordsys. Ordaudio;
CTX RAW (4000): = NULL;
BEGIN

--Get Audiosource field locator

SELECT S.audiosource into Audioobj

From Songstable S
WHERE s.songid = ' 00 '
For UPDATE;

--The following four functions are member functions of the Ordaudio object, see the Oracle Development Manual for specific features

Audioobj.setsource (' file ', ' Auddir ', ' underpressure.au ');--Set file

Audioobj.setmimetype (' Audio/basic '); --Set type

Audioobj.import (CTX); --Loaded into CTX

Audioobj.setproperties (CTX); --Set properties

--Load a song object into a database table

UPDATE songstable S
SET S.audiosource = Audioobj
WHERE s.songid = ' 00 ';

COMMIT;

End;

[NextPage]

Five. Multimedia database technology Difficulties and prospects

It can be said that the efficient management of multimedia data is the inevitable requirement of it technology development, with the further strengthening of multimedia information needs, multimedia database technology will have greater development, from Oracle database we can see that, whether in data type, data management, or development management tools, Now the mainstream relational database already has the very strong multimedia information management ability. However, we can not but regret to see that some of the multimedia data specific operations (such as the multimedia information query) ability is still very limited.

A problem is the special operation of multimedia data, because the LOB data is a large binary object, he can not simply according to the operator of general data calculation. For example, to find a data table with a song similar to the audio. For this ' similar ' operation, it is not supported by the traditional operator, and it will involve very complex algorithms. Fortunately, Oracle9i intermedia already has multimedia data query and matching functions, for example, from the texture (texture), shape, color, color components and other elements of similar image query, in the query can set the weight of each element, the results of the test is still passable. But queries for types of data such as Audio,video are still not ideal.

In addition, how to describe the multimedia information, how to search according to your description of multimedia information, is also a difficult problem, such as the Query task: query out the color is darker and there are forest scenery photos, this is based on descriptive information to query the example. This will require some kind of industry standard and technology implementation. In a word, how to realize and optimize the special operation of multimedia data (such as similar query) will be a hot issue in the research and application of multimedia database.

Another important problem is the performance tuning for multimedia databases, the original tuning methods, such as index optimization, still apply, but now there are new problems: Multimedia data is huge, then the operation of multimedia information (especially retrieval) is expensive, so how to reduce this overhead, shorten the operation time, is also an important topic.

Previous page

prev [1] [2]

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.