DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workkloads.

Secure your stack and shape the future! Help dev teams across the globe navigate their software supply chain security challenges.

Releasing software shouldn't be stressful or risky. Learn how to leverage progressive delivery techniques to ensure safer deployments.

Avoid machine learning mistakes and boost model performance! Discover key ML patterns, anti-patterns, data strategies, and more.

Related

  • Doris vs Elasticsearch: A Comparison and Practical Cost Case Study
  • Keep Calm and Column Wise
  • Accelerating Insights With Couchbase Columnar
  • Migrating MuleSoft System API to AWS Lambda (Part 1)

Trending

  • Evolution of Cloud Services for MCP/A2A Protocols in AI Agents
  • Java's Quiet Revolution: Thriving in the Serverless Kubernetes Era
  • AI, ML, and Data Science: Shaping the Future of Automation
  • Recurrent Workflows With Cloud Native Dapr Jobs
  1. DZone
  2. Data Engineering
  3. Databases
  4. A Comparison of JSON Values in a Database

A Comparison of JSON Values in a Database

In this article, I will talk about some of the new SQL functions that come with Oracle 18c and look at what we can do by trying a few different scenarios.

By 
Emrah Mete user avatar
Emrah Mete
·
Updated Sep. 05, 18 · Analysis
Likes (3)
Comment
Save
Tweet
Share
15.8K Views

Join the DZone community and get the full member experience.

Join For Free

In this article, I will talk about some of the new SQL functions that come with Oracle 18c. I hope this article is useful in the sense of awareness. 

As we know, Oracle 18c was announced in February last year, and users are made available for use in Cloud environments. Following this announcement, Oracle has introduced a new version for its end users via the LiveSQL platform. 

I will perform the function tests that are the subject of this article through the LiveSQL platform.

The new SQL functions, which are the subject of the article, check the content of the JSON data we have stored in the database and understand if the JSONs match. With the existing infrastructure, it is necessary to develop complex SQL queries in order to be able to control the content of JSONs, and this control can be done very quickly and easily with newly developed functions.

Now let's look at what we can do by trying a few different scenarios. Let's start by creating a sample table and data.

CREATE TABLE comp_json_values
(
   json_val_1   VARCHAR2 (2000),
   json_val_2   VARCHAR2 (2000),
   use_case_desc VARCHAR2(2000)
);

INSERT INTO comp_json_values
     VALUES (
               '{"key":"k1","value":"v1"}',
               '{"key":"k1","value":"v1"}',
               'Exactly Same');

INSERT INTO comp_json_values
     VALUES (
               '{"key":"k1","value":"v1"}',
               '{"key":"k1" ,  "value":"v1"   }',
               'Exactly Same but having whitespaces');    

INSERT INTO comp_json_values
     VALUES (
               '{"key":"k1","value":"v1"}',
               '{"key":"k2","value":"v2"}',
               'Format:Same - Order:Same - Values:Different');

INSERT INTO comp_json_values
     VALUES (
               '{"key":"k1","value":"v1"}',
               '{"key":"k2","value":"v2","value2":"v3"}',
               'Format:Different - Order:Different - Values:Different');

INSERT INTO comp_json_values
     VALUES (
               '{"key":"k1","value":"v1"}',
               '{"value":"v1","key":"k1"}',
               'Format:Same - Order:Different - Values:Same');

INSERT INTO comp_json_values
     VALUES (
               '{"key":"k1","value":"v1"}',
               '{"value":"v21","key":"k21"}',
               'Format:Same - Order:Different - Values:Different');

INSERT INTO comp_json_values
     VALUES (
               '{"key":"k1","value":"v1"}',
               '{"value2":"v2","key2":"k2"}',
               'Format:Different - Order:Different - Values:Different');

COMMIT;

select * from comp_json_values;


Now let's check the JSON data with the functions that the new subroutine has to offer. In what scenario do we get the results?

SELECT json_val_1,
       json_val_2,
       use_case_desc,
       CASE
          WHEN json_equal (json_val_1, json_val_2) THEN 'Match'
          ELSE 'Mismatch'
       END
          json_comp
FROM comp_json_values;

We can use this in the CASE, WHEN, and WHERE clauses.

SELECT json_val_1, json_val_2, use_case_desc
  FROM comp_json_values
 WHERE json_equal (json_val_1, json_val_2);

select json_val_1, 
       json_val_2, 
       use_case_desc
from comp_json_values
where not json_equal(json_val_1,json_val_2);

The new functions that come with the new infrastructure can also be used in PL/SQL basically.

Thanks, and let me know your thoughts in the comments section. 

JSON Database Comparison (grammar)

Opinions expressed by DZone contributors are their own.

Related

  • Doris vs Elasticsearch: A Comparison and Practical Cost Case Study
  • Keep Calm and Column Wise
  • Accelerating Insights With Couchbase Columnar
  • Migrating MuleSoft System API to AWS Lambda (Part 1)

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!