The ORACLE tutorial is: Oracle Database processing multimedia information.
Citation:
For a long time, multimedia information has been stored in the computer as files and managed by the operating system. However, with the development of computer networks and distributed computing, multimedia information has been efficiently managed and accessed, query has become an urgent requirement. Relational databases have powerful data management capabilities. Combined with the two aspects, multimedia databases emerged. This article will give a summary of Oracle's multimedia information processing methods, tools, features and some basic principles.
However, we can't help but regret to see that the existing database has limited operation capabilities for some multimedia data. Performance Tuning for multimedia databases has now encountered new problems. Even so, multimedia databases still have broad application values and prospects.
Of course, this article cannot cover all aspects. For details about Oracle multimedia information processing, please refer to the relevant Oracle manual.
I. Application Prospects
With the increase in computer processing capabilities, multimedia has already been integrated into the computer. If multimedia is missing, there is a lack of images, audios, and videos from multiple sources, it is hard to imagine that computers will enter thousands of households today. For a long time, multimedia information has been stored in the computer in the form of files and managed by the operating system. However, with the development of computer networks and distributed computing, this simple file-based management is far from enough, efficient management, access, and query of multimedia information has become an urgent requirement. Relational databases have powerful data management capabilities. These two aspects work closely together and multimedia databases emerged. It is foreseeable that with the increasing demand for multimedia processing, multimedia databases will become more and more widely used.
Oracle, as a well-known database vendor, is still at the forefront of multimedia information processing. This article will give a summary of Oracle's multimedia information processing methods, tools, features and some basic principles. Hope to inspire readers. Of course, there are many other relational databases. Although the development tools and programming interface statements vary, the data types and processing methods are similar. So we skipped it here.
II. Introduction to multimedia data types
In relational databases, large objects such as multimedia information are accessed by lob fields. This standard was officially introduced in Oracle8i to meet the needs of multimedia large object processing. In Oracle databases, lob data includes the following types:
--------------------------------------------
Lob type description
Clob: similar to the long type of Oracle7, clob can store single-byte data.
Nclob: Nclob stores fixed-width multi-byte National Character Set Data
Blob: similar to the long raw type in Oracle7. Unstructured binary data can be stored. Oracle8 does not explain this data, but stores and retrieves it in the original form.
Bfile: Bfile allows read-only access to large binary files stored outside the Oracle database. Unlike the other three lob data types, bfile data is stored in a separate file, which is not maintained by Oracle.
Features:
1. In Oracle7, the corresponding long or long raw field has a limit of 2 GB, while the lob limit is 4 GB.
2. lob can be manipulated by calling the interface OCI or by pl/SQL using the dbms_lob package.
3. Unlike the long type, lob has only one field at most in each table. It can have multiple fields and use the trigger features.
4. lob data processing can obtain the same things and features as other data.
5. the storage of lob is special. It is not stored in the same database table as other data, but can be separately stored in different tablespaces, with a locator pointing to the actual lob data.
[NextPage]
Iii. Examples of large multimedia Object Access routines
Follow these steps:
(1) Create a database table first:
Create table lobdemo (key number key, clob_col CLOB, blob_col BLOB, bifle_col BFILE );
The first column of the database stores a code, and the other three columns store lob data.
(2) Insert a data entry to the table after the table is created:
Insert into lobdemo (key, clob_col, blob_col, bfile_col) values (10, 'clerk', empty_blob (), null );
In this piece of data, we insert a string in the second column, which is formatted as clob data for storage. In the second column, we use the empty_blob () function to initialize a locator, later, you can obtain the locator for operations such as select and update. If the third column is assigned a null value, it does not obtain a locator, which is different from the empty_blob () function.
(3) query the data in the inserted Table
Select blob_col from boldemo where key = 20;
Note: The returned result of this SQL statement is a locator, rather than the actual data.
(4) modify data in the database
Update lobdemo SET blob_col = 'aedevbagddgagdfdfasasdfdsa 'where key = 10;
From these SQL statements, we can see the basic lob-type data processing method, and find that it is similar to other types of data processing. However, lob data processing in SQL statements is special in the following aspects:
(1) Processing bfile:
The bfile type has its own particularity, which is different from clob and blob. The actual data files are stored outside the operating system. Therefore, there are two features: 1. No transactional Control 2. bfile is read-only and cannot be modified using dbms_lob or oracl8 oci. Let's take a look at the bfile operation steps:
<1> to access external files, the server must know the location of the files in the operating system. Next we will create a directory:
Create DIRECTORY utils AS '/home/utils ';
Utils indicates the directory logic name. '/home/utils' indicates the actual directory.
<2> use the bfilename function to insert a row of data:
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 file name. Note: This line inserts a lob locator pointing to/home/utils/file1, not the file itself.
(2) Use the dbms_lob package for lob Data Operations
SQL can only manipulate the entire lob, but cannot manipulate data slices. The dbms_lob package releases this restriction, which provides operations on data slices in the lob data. This package contains more than a dozen routines. You can refer to the Oracle pl/SQL manual. This article only introduces three functions: fileopen () used to open an operating system file; loadfromfile () the routine fills an operating system file with the lob field of the target. This function is very useful because many lob contents cannot be described in SQL statements, such as a binary audio file, this function can be used to import the file content to the database. The getlength function calculates the file length. See the usage of the three functions in the following stored procedure:
Create or replace procedure FileExec (
P_Directory in VARCHAR2,
P_Filename IN VARCHAR2
)
V_FileLocator BFILE;
V_CLOBLocator CLOB;
BEGIN
-- Initialize a locator for update
SELECT clob_col
INTO v_CLOBLocator
FROM lobdemo
WHERE key =-1
For update;
-- Initialize a BFILE locator for the Read File
V
[1] [2] Next page
The ORACLE tutorial is: Oracle Database processing multimedia information. _ FileLocator: = BFILEOPEN (p_derecloud, p_Filename );
-- Open an operating system file with fileopen of dbms_lob package
DBMS_LOB.FILEOPEN (v_FileLocator, DBMS_LOB.FILE_READONLY );
-- Load the entire operating system file into lob
DBMS_LOB.LOADFROMFILE (v_CLOBLocator, v_FileLocator, DBMS_LOB.GETLENGTH (v_FileLocator ));
END FileExec;
Iv. Oracle InterMedia tool Introduction
InterMedia is an integrated component launched by Oracle to expand the Oracle8i multimedia function. It enables Oracle to conveniently manage images, audio, video, text, and other information. This improves the reliability and availability of Oracle multimedia data management in the internet, e-commerce and other fields. It includes three parts: image, audio, and video. InterMedia uses Object Types, similar to JAVA or C ++, to describe data of the image, audio, and video types. Oracle defines many methods in these three object types to operate on the data, for image data, you can easily convert, compress, copy, and intercept any part of the image, these are incomparable to common LOB data, and common SQL statements cannot complete these operations.
The development of Internet highlights the value of interMedia in WEB applications. Most existing WEB applications store image, audio, video, and other multimedia information in a file system. The advantage is that the operation is simple, the speed is fast, but the disadvantage is that the management is complicated, especially when managing a large number of images, it is limited by the number of directories. If the image is stored in the database, it is maintained and backed up in a unified manner, which simplifies management.
Intermedia defines several multimedia object types. For example, ORDAUDIO is one of them. It provides some audio object-type data manipulation functions. Let's take an example. In this example, we define a song object, create a table for the 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), -- question
Artist VARCHAR2 (4000), a writer
Awards VARCHAR2 (4000)-awards
TimePeriod VARCHAR2 (20), -- Date and Time
Txtinroduction CLOB, -- Introduction
AudioSource ORDSYS. ORDAUDIO -- audio data. This field is defined by the ORDAUDIO object.
);
(2) create a table named songtable:
Create table songable of songObject (UNIQUE (songId), songId not null );
(3) Insert a row of data to the sonstable table
Insert into sonstable VALUES ('00 ',
'Under Pressure ',
'Queen ',
'No awards ',
'80-90 ',
243,
NULL,
EMPTY_CLOB (),
ORDSYS. ORDAudio (NULL,
ORDSYS. ORDSource (EMPTY_BLOB (), NULL, NULL ),
NULL, NULL, EMPTY_CLOB (), NULL, NULL ));
Note :. EMPTY_CLOB, EMPTY_BLOB () function only initializes a lob data locator and does not store actual data.
(4) load a row of data into the sonstable table:
DECLARE
AudioObj ORDSYS. ORDAUDIO;
Ctx RAW (4000): = NULL;
BEGIN
-- Get the 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. For specific functions, see the Oracle development manual.
AudioObj. setSource ('file', 'audiodir', 'underpressure. au '); -- sets the FILE
AudioObj. setMimeType ('audio/basic '); -- set the type
AudioObj. import (ctx); -- load ctx
AudioObj. setProperties (ctx); -- Set Properties
-- Load the song object into the database table
UPDATE SongsTable S
Set s. audioSource = audioObj
Where s. songId = '00 ';
COMMIT;
END;
[NextPage]
V. technical difficulties and prospects of Multimedia Databases
It can be said that the efficient management of multimedia data is an inevitable requirement for the development of IT technology. With the further strengthening of multimedia information requirements, multimedia database technology will develop even more. From the Oracle database, we can see that, mainstream relational databases have strong multimedia information management capabilities in terms of data types, data management, and development management tools. However, we can't help but regret to see that the ability to perform operations specific to multimedia data (such as querying multimedia information) is still very limited.
One problem is the special operation implementation of multimedia data. Because lob data is a large binary object, it cannot be simply calculated according to the general data operator. For example, you need to find the audio that is similar to a song in a data table. For this 'similarity 'operation, it cannot be supported by traditional operators, and it will involve complicated algorithms. Fortunately, Oracle9i Intermedia already has the function of querying and matching multimedia data. For example, you can query similar images by texture, shape, color, and color components, you can set the weights of each element during the query. The test results are still unsatisfactory. However, the query for audio, video, and other types of data is still not ideal.
In addition, how to describe multimedia information and how to search multimedia information is also a difficult issue, such as the query task: this is an example of querying landscape photos with dark colors and forests based on descriptive information. This will require some industry standards and technical implementation. In short, how to implement and optimize special operations for multimedia data (such as similar queries) will be a hot issue in multimedia database research and application in the future.
Another important problem is Performance Tuning for multimedia databases. The original optimization method, such as index optimization, is still applicable, but now it has encountered a new problem: multimedia data is huge, therefore, operations on multimedia information (especially retrieval) are costly. Therefore, it is an important task to reduce the overhead and shorten the operation time.
Previous Page
Previous Page [1] [2]