Skip to main content

Difference between CLOB and BLOB Datatypes in ORACLE/MYSQL Vijay Sinha The Crazy Programmer

In this article we look into the difference between CLOB and BLOB datatypes in Oracle/MYSQL. We will also see about the description of each datatype and how to create attributes in a table with these datatypes.

So, CLOB and BLOB are types of Large Object Datatypes (LOB). LOB’s are a set of datatypes used to store or hold large amounts of data to access and manipulate the data efficiently. To learn more about Large Objects refer to Oracle Documentations.

Also Read: Difference Between MySQL and ORACLE

CLOB

CLOB stands for Character Large Object. It is a built in datatype used to store large textual data with variable length holding up to 2,147,483,647 bytes of characters i.e. up to 2 GB long. It can store both single byte or multiple byte character streams. The CLOB datatype is represented using the java.sql.Clob interface in the JDBC API in Java. The CLOB object in JDBC holds a logical pointer to SQL CLOB. In other words, the object points to the location of the data instead of holding its character data.

CLOB Datatype Attribute in Oracle:

Column_Name CLOB

Note: We do not need to specify CLOB Size while declaring the attribute by default size is 2,147,483,647.

MYSQL supports CLOB Datatype Attribute using only TINYTEXT, TEXT, MEDIUMTEXT, LONGTEXT.

Example: 

Column_Name LONGTEXT

BLOB

BLOB stands for Binary Large Object, a built in datatype used to store large data in form of binary streams with a maximum length of 65,535 bytes or 64 KB. It generally stores non-traditional data such as files including voice, images and mixed data etc. The BLOB datatype is represented using the java.sql.Blob interface in the JDBC API in Java. The BLOB object in JDBC holds a logical pointer to SQL BLOB i.e. the object points to the location of the data instead of holding its binary data.

In ORACLE as well as in MYSQL, BLOB datatype is defined as:

Column_Name BLOB

However, MYSQL supports BLOB with following datatypes as well : TINYBLOB, MEDIUMBLOB and, LONGBLOB.

Now, Let us look how these datatypes fit in the schema while creating a table in ORACLE.

CREATE TABLE BOOK_DETAILS
(
Book_Id NUMBER,
About_Book CLOB,
Book_Logo BLOB
);

Explanation:

About_Book attribute of table BOOK_DETAILS contains description about a book which may require large textual data so in this case it is more appropriate to use CLOB and field Book_Logo stores the book logo, an image resource so BLOB datatype goes well with this field.

In MYSQL this is implemented as follows:

CREATE TABLE BOOK_DETAILS
(
Book_Id NUMBER,
About_Book LONGTEXT,
Book_Logo BLOB
);

Difference between CLOB and BLOB

Now, let’s look at some key differences between the two and compare them.

CLOB BLOB
1. The abbreviation stands for Character Large Object. 1. It stands for Binary Large Object.
2.This datatype stores large textual data in the form of character streams with a maximum length of 2,147,483,647 character bytes i.e. up to 2GB  long. 2. This datatype stores large binary data in the form of binary or bitstreams with a maximum of 65535 characters or 64 KB long.
3. Mainly used to store files with text information such as text files, PDF documents etc. 3. Generally stores files including media data such as images, videos ,audio files etc.
4. Oracle supports this using CLOB while MYQL supports this datatype using only alias of TEXT type such as:
  • TINYTEXT
  • MEDIUMTEXT
  • LONGTEXT
4. Oracle as well as MYSQL supports this datatype using BLOB after field name. However MYSQL also has various implementations of this such as:
  • TINYBLOB
  • MEDIUMBLOB
  • LONGBLOB
5. Present in JDBC API as java.sql.Clob interface and implemented using SQL Locator. 5. Present in JDBC API as java.sql.Blob interface and implemented using SQL Locator.

That’s all for the article you can create a table with the following attributes shown in the example, add some records and see it in working!

You can ask your queries in the comment section below.

The post Difference between CLOB and BLOB Datatypes in ORACLE/MYSQL appeared first on The Crazy Programmer.



from The Crazy Programmer https://ift.tt/2LPksWq

Comments

Popular posts from this blog

Difference between Web Designer and Web Developer Neeraj Mishra The Crazy Programmer

Have you ever wondered about the distinctions between web developers’ and web designers’ duties and obligations? You’re not alone! Many people have trouble distinguishing between these two. Although they collaborate to publish new websites on the internet, web developers and web designers play very different roles. To put these job possibilities into perspective, consider the construction of a house. To create a vision for the house, including the visual components, the space planning and layout, the materials, and the overall appearance and sense of the space, you need an architect. That said, to translate an idea into a building, you need construction professionals to take those architectural drawings and put them into practice. Image Source In a similar vein, web development and design work together to create websites. Let’s examine the major responsibilities and distinctions between web developers and web designers. Let’s get going, shall we? What Does a Web Designer Do?

A guide to data integration tools

CData Software is a leader in data access and connectivity solutions. It specializes in the development of data drivers and data access technologies for real-time access to online or on-premise applications, databases and web APIs. The company is focused on bringing data connectivity capabilities natively into tools organizations already use. It also features ETL/ELT solutions, enterprise connectors, and data visualization. Matillion ’s data transformation software empowers customers to extract data from a wide number of sources, load it into their chosen cloud data warehouse (CDW) and transform that data from its siloed source state, into analytics-ready insights – prepared for advanced analytics, machine learning, and artificial intelligence use cases. Only Matillion is purpose-built for Snowflake, Amazon Redshift, Google BigQuery, and Microsoft Azure, enabling businesses to achieve new levels of simplicity, speed, scale, and savings. Trusted by companies of all sizes to meet

2022: The year of hybrid work

Remote work was once considered a luxury to many, but in 2020, it became a necessity for a large portion of the workforce, as the scary and unknown COVID-19 virus sickened and even took the lives of so many people around the world.  Some workers were able to thrive in a remote setting, while others felt isolated and struggled to keep up a balance between their work and home lives. Last year saw the availability of life-saving vaccines, so companies were able to start having the conversation about what to do next. Should they keep everyone remote? Should they go back to working in the office full time? Or should they do something in between? Enter hybrid work, which offers a mix of the two. A Fall 2021 study conducted by Google revealed that over 75% of survey respondents expect hybrid work to become a standard practice within their organization within the next three years.  Thus, two years after the world abruptly shifted to widespread adoption of remote work, we are declaring 20