← Back to list

Dealing with Large Objects Using Oracle SQL Query Data Types

Oracle database contains a wide range of data types to fit various requirements related to data storage. This includes large object data…

Tosska Technologies · 2021-10-29 09:38 · 240 claps · 3.3 min read
#query-performance-tuning #dba-tuning #free-tools-for-windows #oracle-database-and-sql #sql-tuning-in-sql-server
Open on Medium ↗
Wiki topics: RAG · RAG & Retrieval

Dealing with Large Objects Using Oracle SQL Query Data Types

Oracle SQL Query

Oracle SQL Query

Oracle database contains a wide range of data types to fit various requirements related to data storage. This includes large object data types (LOB) that prove useful when storing bulkier data, such as large text, images, audio, video, or PDFs in an **Oracle SQL query**.

In this article, we will talk about those data types and a few basic differences between them. Let’s begin with the CLOB and NCLOB data types, which stand for Character Large Object and National Character Large Object, respectively.

Users generally apply both of these when they have to store large XML and text files. CLOB and NCLOB have one major difference: the former takes 1 byte per character when it places characters in the ASCII system. On the other hand, NCLOB uses two or three bytes for each character to store it in the Unicode character set.

When users must work with LOBs, they store them in and retrieve them from, the database. These tasks are possible with the help of basic SQL statements and query tuning in SQL in case of low performance.

Then there is the BLOB (Binary Large Object) and the BFILE (Binary File) data type. As their names suggest, they are capable of storing information in binary format. The BLOB type is generally used to store PDF files as well as other such binary files including video, audio, and image files.

Oracle SQL Query

Oracle SQL Query

The BFILE (Binary File) type enables the storage of binary files outside the database by storing a pointer there. In fact, users can store binary files anywhere, as long as the host’s file system can gain access to that location.

A majority of client-side applications use LOBs for specific purposes. For instance, a client-side application might need to fetch an image from the database and display it because of a user’s **Oracle SQL query**. Conversely, a client-side application may, at times, have to upload an image from a different storage source to save it in the database.

Since such instances, require effective communication between the database and the client-side app, Oracle offers APIs that enable functioning with LOBs. Some of the best examples of this are .NET languages such as C# or Visual Basic, or Java. Additionally, users get an API to allow the use of PL/SQL with LOBs.

Database experts prefer to use PL/SQL when they have to perform the server-side processing for client-side applications to call with the help of a function or a saved procedure. That’s because it lacks the capabilities needed to view images or play media.

Let us consider a SQL table named Item_Reviews as an example. Suppose it stores information using the CLOB data type. In it, the first column holds numerical values that provide unique identities to each row. The second column consists of CLOB values and the user adds three rows to the table.

The insert query makes use of the TO_CLOB function to turn a string literal into a CLOB type. This helps the user achieve two things:

  1. It sets up a LOB locator that indicates a CLOB value.
  2. It adds the characters present in the string literal to the CLOB value.

On the other hand, if we use an INSERT query that utilizes the EMPTY_CLOB function instead, it will do the same. However, it will initialize a LOB locator pointing to a CLOB value without filling any information in the CLOB value.

Let us take a third INSERT statement into consideration. This one saves a NULL value that won’t initialize a LOB pointer like the other two. Entering the COMMIT query commits the alterations made to the database. When the user tries to fetch data from the table using a SELECT statement, they may require **query tuning in SQL** with the help of some tools.

For instance, the user can make the statement gather data from both the columns of the table. Once this is done, they can create another column using the LENGTH function. The purpose behind this is to retrieve the number of characters saved in the database under the CLOB data type.


메타데이터
post_id
daedb3744cd6
slug
dealing-with-large-objects-using-oracle-sql-query-data-types-daedb3744cd6
url
https://medium.com/@tooskasqltech123/dealing-with-large-objects-using-oracle-sql-query-data-types-daedb3744cd6
canonical_url
https://medium.com/@tooskasqltech123/dealing-with-large-objects-using-oracle-sql-query-data-types-daedb3744cd6
author_url
https://medium.com/@tooskasqltech123
status
ok
fetched_at
2026-07-13 06:23:13