Showing posts with label Oracle Database 12c. Show all posts
Showing posts with label Oracle Database 12c. Show all posts

Tuesday, February 14, 2023

Navigating the Oracle 1Z0-062 Exam: Common Questions and Tips for Success

1Z0-062, 1Z0-062 Sample Questions, oracle database 12c administration 1z0-062 pdf, oracle database 12c administrator certified associate study guide pdf, Oracle Database 12c, 1Z0-062 Study Guide, 1Z0-062 Practice Test, 1Z0-062 Simulator, 1Z0-062 Certification, Oracle Database 12c - Administration, Oracle Database 12.1 Mock Test, 1z0-062 dumps, 1z0-062 exam questions, Oracle 1Z0-062 Questions and Answers, Oracle Database 12c Administrator Certified Associate (OCA), Oracle Database Administration Certification Questions, Oracle Database Administration Online Exam, Database Administration Exam Questions, Database Administration, 1Z0-062 Study Guide PDF, 1Z0-062 Online Practice Test, 1Z0-062 questions, 1Z0-062 exam guide, 1Z0-062 tips, 1Z0-062 preparation tips, 1Z0-062 books, 1Z0-062 study materials

The Oracle Database 12c - Administration exam, also known as the 1Z0-062 exam, is a challenging test that requires a thorough understanding of database administration concepts and practices. This article will answer some common questions about the exam and provide tips for success.

What is the Oracle 1Z0-062 Exam?

The Oracle 1Z0-062 exam is an Oracle certification exam that tests your knowledge of database administration for Oracle Database 12c. Passing the 1Z0-062 exam is a significant achievement and is recognized by many companies as evidence of a candidate's expertise in database administration.

The exam consists of 67 multiple-choice questions and has a time limit of 120 minutes. The passing score for the exam is 64%, and the exam fee varies by location.

What are some Tips for Success on the Oracle 1Z0-062 Exam?

To pass the Oracle 1Z0-062 exam, you must understand database administration concepts and practices. Here are some tips to help you prepare for the exam:

Study the Exam Content

The exam content for the 1Z0-062 exam is available on the Oracle website. Study the content carefully and ensure that you have a thorough understanding of the topics covered.

The exam covers a wide range of topics, including:



Use Study Materials

Use study materials such as textbooks, online courses, and practice exams to reinforce your understanding of the exam content. Choose materials that are up-to-date and relevant to the exam.

There are many study materials available for the 1Z0-062 Oracle Database 12c - Administration exam. These materials can help you build a solid foundation of knowledge and develop the skills you need to pass the exam.

Practice exams are also an excellent resource for preparing for the exam. They allow you to familiarize yourself with the exam format and identify areas where you need to focus your studies.

Practice with Oracle Database

Practical experience with Oracle Database is essential to passing the exam. Set up a database on your computer and practice performing administrative tasks such as creating users, backing up data, and managing performance.

Hands-on experience with the database will help you understand how the concepts you've learned apply in a real-world setting. It will also help you develop the problem-solving skills you need to succeed on the exam.

Take Practice Exams

Practice exams can help you get a feel for the exam format and identify areas where you need to focus your studies. It's essential to practice taking the exam under timed conditions. Set a timer for 120 minutes (the exam's duration) and take the practice test under similar conditions.

By taking the practice test under timed conditions, you will also get used to the pressure of working within the time constraints, which can help reduce anxiety during the actual exam. Ensure that the practice exams you choose are up-to-date and relevant to the 1Z0-062 exam.

Join Study Groups

Joining study groups can provide a collaborative and supportive learning environment where you can exchange knowledge and ideas with other exam takers. You can join study groups online or in person.

Study groups can help you stay motivated and accountable and provide valuable insights and strategies for passing the exam.

What are the Benefits of Passing the Oracle 1Z0-062 Exam?

Passing the 1Z0-062 exam demonstrates your knowledge and skills in database administration for Oracle Database 12c and can open up new career opportunities. Here are some benefits of passing the exam:

Enhanced Career Opportunities

Oracle certification is highly valued in the IT industry, and passing the Oracle 1Z0-062 exam can open up new career opportunities. It demonstrates to potential employers that you have the knowledge and skills to manage and administer Oracle Database 12c, which can lead to higher-paying jobs and career advancement.

Increased Knowledge and Skills

Preparing for the 1Z0-062 exam requires significant study and hands-on experience with Oracle Database 12c. By passing the exam, you'll have a deeper understanding of database administration concepts and practices, which can help you become a more valuable asset to your organization.

Improved Credibility

Oracle certification is recognized and respected throughout the IT industry, and passing the 1Z0-062 exam can improve your credibility as a database administrator. It demonstrates to your peers and colleagues that you have the skills and knowledge to manage and administer Oracle Database 12c.

Frequently Asked Questions about the 1Z0-062 Exam

Q1: How long is the 1Z0-062 exam?

The 1Z0-062 exam is 120 minutes long.

Q2: How many questions are on the exam?

The exam consists of 67 multiple-choice questions.

Q3: What is the passing score for the exam?

The passing score for the 1Z0-062 exam is 64%.

Q4: How much does the exam cost?

The exam fee varies by location. Check the Oracle website for pricing information in your area.

Q5: How often can I retake the exam if I don't pass?

Read the policy on exam retakes on the official site.

Conclusion

The 1Z0-062 exam is a challenging test that requires a thorough understanding of database administration concepts and practices. By studying the exam content, using study materials, practicing with Oracle Database, taking practice exams, and joining study groups, you can prepare yourself for success on the exam.

Passing the 1Z0-062 exam can open up new career opportunities, enhance your knowledge and skills, and improve your credibility as a database administrator. So, start preparing for the exam today and take your career to the next level.

Saturday, May 14, 2022

In-Place Upgrade for Database Cloud Service (DBCS) VM DB Systems

We are pleased to announce the general availability (GA) of upgrading the Operating System (OS) and Grid Infrastructure (GI) stack on Database Cloud Service (DBCS) VM DB Systems.

This feature provides an in-place upgrade option for DB Systems running Oracle Linux 6 (OL6) and Grid Infrastructure 12.2 or 18c to Oracle Linux 7 (OL7) with Grid Infrastructure 19c while keeping the database version the same. Additionally, customers can also upgrade their database to 19c and optionally convert it to CDB/PDB architecture.

Read More: 1Z0-068: Oracle Database 12c - RAC and Grid Infrastructure Administration

With the in-place upgrade capability of OS and GI for VM DB Systems, you can now

◉ Perform an in-place upgrade which keeps the characteristics of your VM DB System – such as SCAN Name, SCAN IPs, private IP addresses, and hostnames intact - during the upgrade process

◉ Upgrade Oracle Linux version from OL6 to OL7

◉ Upgrade the Grid Infrastructure to the latest or the previous GI 19c version (N-1)

◉ Upgrade with minimal downtime in approximately 2 hours using cloning technology

◉ Fallback to a snapshot if a roll back is required

OCI Console Experience

The Console has been redesigned to use a single execution page for updates and upgrades. From the Bare Metal, VM, and Exadata service home page, navigate to DB Systems and click on the 'View' button in the newly displayed version information section:

Database Cloud Service (DBCS), Oracle Database Exam Prep, Database Preparation, Oracle Database Career, Database Skills, Database Jobs

On the Updates screen, you will find GI and database updates and upgrades. If your VM OS version is OL6, database upgrades to 19c are not possible until the OS is upgraded to OL7.

So, let's first upgrade the DB System to OL7 and 19c by choosing "Run Precheck" to ensure there are no common errors detected and then APPLY to upgrade the VM DB System to OL7 and 19c. The OS version relates to the GI version, but this will be separated in a future release.

Database Cloud Service (DBCS), Oracle Database Exam Prep, Database Preparation, Oracle Database Career, Database Skills, Database Jobs

A confirmation dialog is displayed which requires you to type in the DB System name. For this upgrade, all nodes will be shut down, including both RAC nodes.

Database Cloud Service (DBCS), Oracle Database Exam Prep, Database Preparation, Oracle Database Career, Database Skills, Database Jobs

Once "Upgrade DB System" is pressed, the upgrade process will start. A "Rollback" option becomes available in the "Update History" screen if upgrade is not successful.

Database Cloud Service (DBCS), Oracle Database Exam Prep, Database Preparation, Oracle Database Career, Database Skills, Database Jobs

Considerations


◉ Only supports upgrade to GI Version 19c.

◉ The upgrade process will incur downtime on your DB Systems, so this should be planned accordingly.

◉ It is advisable to have a complete standalone backup of the database before trying the upgrade.

◉ As of today, while private IP addresses and hostnames are kept, the ephemeral Public IP addresses will change.

◉ Avoid launching new VM DB Systems within the same subnet during the upgrade process. There is a short time interval when private IP addresses and hostnames are freed, and it will block the upgrade process if another VM DB Systems uses the same IP or hostname.

◉ OS customizations will need to be reapplied as the upgrade exchanges the boot volume.

◉ Any GI clusterware customizations, such as services, additional VIPS, will need to be reapplied since the Grid Infrastructure is reinstalled.

◉ It is recommended to disable the automatic backups before executing the upgrade so archive log backups are not kicked off during the upgrade time. The upgrade process will disable and re-enable the automatic backups.

◉ For databases with a Data Guard association, the upgrade must first be performed on the Standby database. This ensures no re-instantiation is required in case of a rollback as the standby will continue be a higher release than that of the primary.

◉ For Data Guard association, it is advised for the protection mode to be switched to "Maximum Performance" before the upgrade to avoid primary database running into NET_TIMEOUT. Once the upgrade is completed, the protetion mode can be turned back to "Maximum Availability".

Availability


OS and GI upgrade of VM DB Systems is available in all OCI commercial regions via OCI console, API, and SDK.

Source: oracle.com

Tuesday, May 3, 2022

PL/SQL Object Types for JSON in Oracle Database 12c Release 2 (12.2)

Oracle 12c Release 2 (12.2) includes several enhancements to the JSON functionality in the database including native support for JSON parsing and generation in PL/SQL.

◉ Introduction

In Oracle Database 12c Release 1 (12.1) the JSON functionality was focused on consuming JSON data and converting it into relation data. Generation of JSON relied on string handling or packages such as the APEX_JSON package. Oracle Database 12c Release 2 (12.2) includes new JSON object types to support the in-memory parsing, generation and update of JSON data directly from PL/SQL.

PL/SQL, JSON, Oracle Database 12c, Oracle Database Exam Prep, Database Career, Database Skills, Database Jobs, Database Guides

- JSON_ELEMENT_T : The supertype some of the other object types extend. You will not often use this type directly. You can cast a JSON_ELEMENT_T to a subtype using TREAT AS. For example, "l_obj := TREAT (l_elem AS JSON_OBJECT_T);"

- JSON_OBJECT_T : An object representing a JSON object.

- JSON_ARRAY_T : An object representing a JSON array.

- JSON_SCALAR_T : A scalar value associated with a key such as a string, number, boolean or NULL.

- JSON_KEY_LIST : An array of key names, typically returned by the GET_KEYS method.

At the time of writing the documentation is full of mistakes, which the documentation team are now aware of. I would suggest regularly crosschecking the documentation against the object definitions in the database, which you can get by describing them ie. "DESC JSON_OBJECT_T".

◉ Constructors

You will typically create new instances of the object types in one of three ways.

SET SERVEROUTPUT ON

DECLARE

  l_obj JSON_OBJECT_T;

BEGIN

  -- New empty object using constructor.

  -- With or without the NEW keyword.

  l_obj := JSON_OBJECT_T();

  DBMS_OUTPUT.put_line('l_obj.stringify = ' || l_obj.stringify);

  l_obj := NEW JSON_OBJECT_T();

  DBMS_OUTPUT.put_line('l_obj.stringify = ' || l_obj.stringify);

  -- New object based on some JSON text using constructor.

  -- With or without the NEW keyword.

  l_obj := JSON_OBJECT_T('{ "employee_no":9999 }');

  DBMS_OUTPUT.put_line('l_obj.stringify = ' || l_obj.stringify);

  l_obj := NEW JSON_OBJECT_T('{ "employee_no":9999 }');

  DBMS_OUTPUT.put_line('l_obj.stringify = ' || l_obj.stringify);

  -- New object based on some JSON text using PARSE method.

  l_obj := JSON_OBJECT_T.parse('{ "employee_no":9999 }');

  DBMS_OUTPUT.put_line('l_obj.stringify = ' || l_obj.stringify);

END;

/

l_obj.stringify = {}

l_obj.stringify = {}

l_obj.stringify = {"employee_no":9999}

l_obj.stringify = {"employee_no":9999}

l_obj.stringify = {"employee_no":9999}

PL/SQL procedure successfully completed.

SQL>

◉ Serialization Methods

From a JSON perspective, serialization means converting an object to a string, but in PL/SQL it means converting it to another data type. The contents of the JSON object types can be serialized using member functions or procedures, which support conversion to several data types. If the value being returned does not conform to the specific data type required, a conversion is attempted. The STRINGIFY and TO_STRING functions do the same thing, but the former will be more familiar to JavaScript developers.

 MEMBER FUNCTION STRINGIFY RETURNS VARCHAR2

 MEMBER FUNCTION TO_STRING RETURNS VARCHAR2

 MEMBER FUNCTION TO_BOOLEAN RETURNS BOOLEAN

 MEMBER FUNCTION TO_NUMBER RETURNS NUMBER

 MEMBER FUNCTION TO_DATE RETURNS DATE

 MEMBER FUNCTION TO_TIMESTAMP RETURNS TIMESTAMP

 MEMBER FUNCTION TO_CLOB RETURNS CLOB

 MEMBER PROCEDURE TO_CLOB

 Argument Name               Type                    In/Out Default?

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

 C                                        CLOB                    IN/OUT NOCOPY


 MEMBER FUNCTION TO_BLOB RETURNS BLOB

 MEMBER PROCEDURE TO_BLOB

 Argument Name               Type                    In/Out Default?

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

 B                                         BLOB                    IN/OUT NOCOPY

◉ Introspection Methods

The JSON object types include type-introspection member functions that can be used to identify their contents.

 MEMBER FUNCTION IS_OBJECT RETURNS BOOLEAN

 MEMBER FUNCTION IS_ARRAY RETURNS BOOLEAN

 MEMBER FUNCTION IS_SCALAR RETURNS BOOLEAN

 MEMBER FUNCTION IS_STRING RETURNS BOOLEAN

 MEMBER FUNCTION IS_NUMBER RETURNS BOOLEAN

 MEMBER FUNCTION IS_BOOLEAN RETURNS BOOLEAN

 MEMBER FUNCTION IS_TRUE RETURNS BOOLEAN

 MEMBER FUNCTION IS_FALSE RETURNS BOOLEAN

 MEMBER FUNCTION IS_NULL RETURNS BOOLEAN

 MEMBER FUNCTION IS_DATE RETURNS BOOLEAN

 MEMBER FUNCTION IS_TIMESTAMP RETURNS BOOLEAN

 MEMBER FUNCTION GET_SIZE RETURNS NUMBER

With the exception of the GET_SIZE method they should all be self explanatory. Depending on the object type, the GET_SIZE method returns the following.

- JSON_SCALAR_T : Returns 1

- JSON_OBJECT_T : Returns the number of top-level keys.

- JSON_ARRAY_T : Returns the number of array elements.

◉ Error Handling

By default any problems when calling a member function result in a return value of NULL. This default behaviour can be altered by the ON_ERROR procedure which accepts one of the following values.

- 0 : Return NULL instead of raising an error (default).

- 1 : Raise all errors.

- 2 : Raise error if no value found.

- 3 : Raise error is return value doesn't match required data type.

- 4 : Raise error for invalid inputs.

The example below deliberately causes a data type conversion error, attempting to convert an employee name into a number. The first conversion error is ignored and a NULL is returned. After switching the error handling to "1", the error is raised.

SET SERVEROUTPUT ON

DECLARE

  l_obj JSON_OBJECT_T;

BEGIN

  l_obj := JSON_OBJECT_T('{ "employee_name":"CLARK" }');

  -- Default : l_obj.on_error(0); 

  DBMS_OUTPUT.put_line('Error 0 : l_obj.get_number = ' || l_obj.get_number('employee_name'));

  l_obj.on_error(1);

  DBMS_OUTPUT.put_line('Error 1 : l_obj.get_number = ' || l_obj.get_number('employee_name'));

END;

/

Error 0 : l_obj.get_number =

DECLARE

*

ERROR at line 1:

ORA-40566: JSON path expression selected a value of different data type.

ORA-06512: at "SYS.JDOM_T", line 418

ORA-06512: at "SYS.JSON_OBJECT_T", line 256

ORA-06512: at line 8

SQL>

Each object can have its error handling set separately.

◉ Traversing and Amending JSON

The JSON object types include several member functions and procedures that allow JSON data to be traversed and amended. These member functions and procedures vary depending on the JSON object type.

The get style methods are summarised below.

◉ GET : Returns the JSON_ELEMENT_T associated with the specified key.

◉ GET_OBJECT : Returns the JSON_OBJECT_T associated with the specified key.

◉ GET_ARRAY : Returns the JSON_ARRAY_T associated with the specified key.

◉ GET_* : When applied to an object or array, it returns the data type specified in the method name associated with the specified key. Some JSON object types support calls to GET_STRING without a key. There is a member function and procedure for GET_CLOB and GET_BLOB.

◉ CLONE : Creates a full copy of the object specified by the key.

The following methods are used to amend the JSON data.

◉ PUT : For an object, amend the specified key with the specified value, or create it if it is missing. For an array, add a new element in the specified position, making room if the current index already exists. The examples below will demonstrate this difference.

◉ PUT_NULL : For an object, set the specified key value to NULL, or create it if it is missing. For an array, add a new NULL element in the specified position, making room if the current index already exists.

◉ REMOVE : Removed the specified key from an object, element in an array.

◉ RENAME_KEY : As the name suggests, it renames the specified key with the new value in an object.

◉ APPEND : Append a new element to the end of an array.

The use of these methods will become clearer when you examine the examples below.

◉ Example 1: Amending a JSON Object

The following example creates a new JSON object, then amends it several times using the PUT, PUT_NULL, RENAME_KEY and REMOVE methods.

SET SERVEROUT ON FORMAT WRAPPED LINESIZE 1000

DECLARE

  l_obj JSON_OBJECT_T;

  PROCEDURE display (p_obj IN JSON_OBJECT_T) IS

  BEGIN

    DBMS_OUTPUT.put_line(p_obj.stringify);

  END;

BEGIN

  -- Create a new object.

  l_obj := JSON_OBJECT_T('{"employee_no":9999}');

  display(l_obj);

  -- Add a new element to the object.

  l_obj.put('a_string_value', 'A String');

  display(l_obj);

  -- Amend an existing element in the object.

  l_obj.put('a_string_value', 'A New String');

  display(l_obj);

  -- Rename the key of an existing element in the object.

  l_obj.rename_key('a_string_value', 'a_renamed_string_value');

  display(l_obj);

  -- Remove an element.

  l_obj.remove('a_renamed_string_value');

  display(l_obj);

  -- Add a new object element.

  l_obj.put('an_object_value', JSON_OBJECT_T('{"an_object":9999}'));

  display(l_obj);

  -- Remove an element.

  l_obj.remove('an_object_value');

  display(l_obj);

  -- Add a new array element.

  l_obj.put('an_array_value', JSON_ARRAY_T('["text","in","an","arry"]'));

  display(l_obj);

  -- Set an existing element to NULL.

  l_obj.put_null('an_array_value');

  display(l_obj);

END;

/

{"employee_no":9999}

{"employee_no":9999,"a_string_value":"A String"}

{"employee_no":9999,"a_string_value":"A New String"}

{"employee_no":9999,"a_renamed_string_value":"A New String"}

{"employee_no":9999}

{"employee_no":9999,"an_object_value":{"an_object":9999}}

{"employee_no":9999}

{"employee_no":9999,"an_array_value":["text","in","an","arry"]}

{"employee_no":9999,"an_array_value":null}

PL/SQL procedure successfully completed.

SQL>

◉ Example 2: Amending a JSON Array

The following example creates a new JSON array, then amends it several times using the APPEND, APPEND_NULL, PUT, PUT_NULL and REMOVE methods.

SET SERVEROUT ON FORMAT WRAPPED LINESIZE 1000

DECLARE

  l_arr JSON_ARRAY_T;

  PROCEDURE display (p_arr IN JSON_ARRAY_T) IS

  BEGIN

    DBMS_OUTPUT.put_line(p_arr.stringify);

  END;

BEGIN

  -- Create a new array.

  l_arr := JSON_ARRAY_T('["apple","orange","banana"]');

  display(l_arr);

  -- Append a new element to the array.

  l_arr.append('pear');

  display(l_arr);

  -- Append a NULL element to the array.

  l_arr.append_null;

  display(l_arr);

  -- Add a new element to the array.

  -- 0-based, so 3 is position 4.

  l_arr.put(3, 'grape');

  display(l_arr);

  -- Add a NULL element to the array.

  -- 0-based, so 3 is position 4.

  l_arr.put_null(3);

  display(l_arr);

  -- Remove elements from the array.

  -- Notice reverse order, as positions are automatically shuffled.

  l_arr.remove(6);

  l_arr.remove(3);

  display(l_arr);

  -- Amend an element in the array.

  l_arr.remove(3);

  l_arr.put(3, 'pineapple');

  display(l_arr);

  -- Append a new object to the array.

  l_arr.append(JSON_OBJECT_T('{"grape":6}'));

  display(l_arr);

  -- Append a new array to the array.

  l_arr.append(JSON_ARRAY_T('[1,2,3,4,5]'));

  display(l_arr);

END;

/

["apple","orange","banana"]

["apple","orange","banana","pear"]

["apple","orange","banana","pear",null]

["apple","orange","banana","grape","pear",null]

["apple","orange","banana",null,"grape","pear",null]

["apple","orange","banana","grape","pear"]

["apple","orange","banana","pineapple","pear"]

["apple","orange","banana","pineapple","pear",{"grape":6}]

["apple","orange","banana","pineapple","pear",{"grape":6},[1,2,3,4,5]]

PL/SQL procedure successfully completed.

SQL>

In this second JSON array example, we amend the values in the nested JSON array.

SET SERVEROUTPUT ON FORMAT WRAPPED LINESIZE 1000

DECLARE

  l_obj  JSON_OBJECT_T;

  l_arr  JSON_ARRAY_T;

  PROCEDURE display (p_obj IN JSON_OBJECT_T) IS

  BEGIN

    DBMS_OUTPUT.put_line(p_obj.stringify);

  END;

  PROCEDURE display (p_arr IN JSON_ARRAY_T) IS

  BEGIN

    DBMS_OUTPUT.put_line(p_arr.stringify);

  END;

BEGIN

  -- Create a new object containing an array.

  l_obj := JSON_OBJECT_T('{"order":1234,"order_items":[{"1":"apple"},{"2":"orange"},{"3":"banana"}]}');

  display(l_obj);

  -- Get the array out of the object.

  l_arr := l_obj.get_Array('order_items');

  display(l_arr);

  -- Amend an element in the array.

  l_arr.put(2, JSON_ELEMENT_T.parse('{"3":"green banana"}'), TRUE);

  display(l_arr);

  -- Append a new element into the array.

  l_arr.append(JSON_ELEMENT_T.parse('{"4":"pineapple"}'));

  display(l_arr);

  -- Overwrite the array in the object.

  l_obj.put('order_items',l_arr);

  display(l_obj);

END;

/

{"order":1234,"order_items":[{"1":"apple"},{"2":"orange"},{"3":"banana"}]}

[{"1":"apple"},{"2":"orange"},{"3":"banana"}]

[{"1":"apple"},{"2":"orange"},{"3":"green banana"}]

[{"1":"apple"},{"2":"orange"},{"3":"green banana"},{"4":"pineapple"}]

{"order":1234,"order_items":[{"1":"apple"},{"2":"orange"},{"3":"green banana"},{"4":"pineapple"}]}

PL/SQL procedure successfully completed.

SQL>

◉ Example 3 : Parse JSON Data 1

The examples in the remainder of this article require the following table.

CREATE TABLE json_documents (

  id    NUMBER,

  data  CLOB,

  CONSTRAINT json_documents_pk PRIMARY KEY (id),

  CONSTRAINT json_documents_json_chk CHECK (data IS JSON)

);

INSERT INTO json_documents (id, data)

VALUES (1, '{

  "departments":[

    {

      "department":{

        "department_name":"DEV",

        "department_no":70,

        "employees":[

          {

            "employee_number":9000,

            "employee_name":"JONES",

            "salary":1000

          },

          {

            "employee_number":9001,

            "employee_name":"SMITH",

            "salary":2000

          }

        ]

      }

    },

    {

      "department":{

        "department_name":"DBA",

        "department_no":80,

        "employees":[

          {

            "employee_number":9002,

            "employee_name":"HALL",

            "salary":3000

          }

        ]

      }

    }

  ]

}');

COMMIT;

In the following example we know the basic structure of the JSON data, so we loop through the departments array and nested employees array, explicitly requesting the keys of interest to display the data.

SET SERVEROUT ON FORMAT WRAPPED LINESIZE 1000

DECLARE

  l_clob         CLOB;

  l_top_obj      JSON_OBJECT_T;

  l_dept_arr     JSON_ARRAY_T;

  l_dept_obj     JSON_OBJECT_T;

  l_emp_arr      JSON_ARRAY_T;

  l_emp_obj      JSON_OBJECT_T;

BEGIN

  SELECT data

  INTO   l_clob

  FROM   json_documents

  WHERE  id = 1;

  l_top_obj := JSON_OBJECT_T(l_clob);

  l_dept_arr := l_top_obj.get_array('departments');

  FOR i IN 0 .. l_dept_arr.get_size - 1 LOOP

    DBMS_OUTPUT.put_line('-------------------------------------------');

    l_dept_obj := TREAT(l_dept_arr.get(i) AS JSON_OBJECT_T).get_object('department');

    DBMS_OUTPUT.put_line('index           : ' || i);

    DBMS_OUTPUT.put_line('department_name : ' || l_dept_obj.get_string('department_name'));

    DBMS_OUTPUT.put_line('department_no   : ' || l_dept_obj.get_number('department_no'));

    l_emp_arr := l_dept_obj.get_array('employees');

    FOR j IN 0 .. l_emp_arr.get_size - 1 LOOP

      l_emp_obj := TREAT(l_emp_arr.get(j) AS JSON_OBJECT_T);

      DBMS_OUTPUT.put_line('  --');

      DBMS_OUTPUT.put_line('  index           : ' || j);

      DBMS_OUTPUT.put_line('  employee_number : ' || l_emp_obj.get_number('employee_number'));

      DBMS_OUTPUT.put_line('  employee_name   : ' || l_emp_obj.get_string('employee_name'));

      DBMS_OUTPUT.put_line('  salary          : ' || l_emp_obj.get_number('salary'));

    END LOOP;

  END LOOP;

END;

/

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

index           : 0

department_name : DEV

department_no   : 70

  --

  index           : 0

  employee_number : 9000

  employee_name   : JONES

  salary          : 1000

  --

  index           : 1

  employee_number : 9001

  employee_name   : SMITH

  salary          : 2000

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

index           : 1

department_name : DBA

department_no   : 80

  --

  index           : 0

  employee_number : 9002

  employee_name   : HALL

  salary          : 3000

PL/SQL procedure successfully completed.

SQL>

◉ Example 4 : Parse JSON Data 2

In the following example, we understand the basic structure of the JSON data, an array of departments, with each department containing an array of employees, but we are not sure what keys are present in each department and employee, so we can't request them by name. Instead, we loop through the key list and use introspection to decide how to process the values associated with the keys.

SET SERVEROUT ON FORMAT WRAPPED LINESIZE 1000

DECLARE

  l_clob           CLOB;

  l_top_obj        JSON_OBJECT_T;

  l_dept_arr       JSON_ARRAY_T;

  l_dept_obj       JSON_OBJECT_T;

  l_dept_key_list  JSON_KEY_LIST;

  l_emp_arr        JSON_ARRAY_T;

  l_emp_obj        JSON_OBJECT_T;

  l_emp_key_list   JSON_KEY_LIST;

BEGIN

  SELECT data

  INTO   l_clob

  FROM   json_documents

  WHERE  id = 1;

  l_top_obj := JSON_OBJECT_T(l_clob);

  l_dept_arr := l_top_obj.get_array('departments');

  << departments_loop >>

  FOR i IN 0 .. l_dept_arr.get_size - 1 LOOP

    DBMS_OUTPUT.put_line('-------------------------------------------');

    DBMS_OUTPUT.put_line('index : ' || i);

    l_dept_obj := TREAT(l_dept_arr.get(i) AS JSON_OBJECT_T).get_object('department');

    l_dept_key_list := l_dept_obj.get_keys;

    << department_keys_loop >>

    FOR j IN 1 .. l_dept_key_list.count LOOP

      IF l_dept_obj.get(l_dept_key_list(j)).is_array THEN

        -- This element contains an array, so we must process the array.

        l_emp_arr := TREAT(l_dept_obj.get(l_dept_key_list(j)) AS JSON_ARRAY_T); 

        << employees_loop >>

        FOR j IN 0 .. l_emp_arr.get_size - 1 LOOP

          DBMS_OUTPUT.put_line('  --');

          DBMS_OUTPUT.put_line('  index : ' || j);

          IF l_emp_arr.get(j).is_object THEN

            l_emp_obj := TREAT(l_emp_arr.get(j) AS JSON_OBJECT_T);

            l_emp_key_list := l_emp_obj.get_keys;

            << employee_keys_loop >>

            FOR k IN 1 .. l_emp_key_list.count LOOP

              DBMS_OUTPUT.put_line('  ' || l_emp_key_list(k) || ' : ' || l_emp_obj.get_string(l_emp_key_list(k)));

            END LOOP;

            NULL;

          ELSE

            DBMS_OUTPUT.put_line('We were expecting an employee to be an object!');

          END IF;

        END LOOP;

      ELSIF l_dept_obj.get(l_dept_key_list(j)).is_number THEN

        -- It is a number.

        DBMS_OUTPUT.put_line(l_dept_key_list(j) || ' : ' || l_dept_obj.get_number(l_dept_key_list(j)));

      ELSIF l_dept_obj.get(l_dept_key_list(j)).is_string THEN

        -- It is a number.

        DBMS_OUTPUT.put_line(l_dept_key_list(j) || ' : ' || l_dept_obj.get_string(l_dept_key_list(j)));

      ELSE

        -- Catch-all. Stringify.

        DBMS_OUTPUT.put_line(l_dept_key_list(j) || ' : ' || l_dept_obj.get(l_dept_key_list(j)).stringify);

      END IF;

    END LOOP;

  END LOOP;

END;

/

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

index : 0

department_name : DEV

department_no : 70

  --

  index : 0

  employee_number : 9000

  employee_name : JONES

  salary : 1000

  --

  index : 1

  employee_number : 9001

  employee_name : SMITH

  salary : 2000

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

index : 1

department_name : DBA

department_no : 80

  --

  index : 0

  employee_number : 9002

  employee_name : HALL

  salary : 3000

PL/SQL procedure successfully completed.

SQL>

◉ JSON Data Type Support (21c)

Oracle database 21c introduced a new JSON data type to provide native JSON support and improve the performance of JSON processing. PL/SQL Object Type for JSON have been updated to allow interaction with the new data type. The JSON_OBJECT_T constructor supports the new JSON data type, and there are a number of new member functions, as well as overloads of existing member functions that support the new data type.

Source: oracle-base.com

Friday, October 15, 2021

Using Expressions in Initialization Parameters in Oracle Database 21c

Oracle Database 21c, Oracle Database Tutorial and Material, Oracle Database Exam Prep, Oracle Database Certification, Oracle Database Career

Oracle database 21c introduced the ability to use expressions to set initialization parameters. These expressions can reference other parameters and environment variables.

1. Referencing Parameters

We check the values of the JOB_QUEUE_PROCESSES and PROCESSES parameters. We see the values are 80 and 400 respectively.

SQL> show parameter processes

NAME                                        TYPE        VALUE

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

aq_tm_processes                       integer            1

db_writer_processes                  integer           1

gcs_server_processes                 integer           0

global_txn_processes                 integer          1

job_queue_processes                  integer         80

log_archive_max_processes       integer         4

processes                                    integer         400

SQL>

We set the JOB_QUEUE_PROCESSES parameter to 1/10 of the PROCESSES parameter. In this case we use the MAX function, to make sure the JOB_QUEUE_PROCESSES parameter value never drops below 10.

SQL> alter system set job_queue_processes='max(processes/10,10)';

System altered.

SQL>

We check the JOB_QUEUE_PROCESSES parameter again, and we see it has been set to the correct value.

SQL> show parameter job_queue_processes

NAME                                       TYPE        VALUE

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

job_queue_processes               integer         40

SQL>

We create a parameter file based on the current spfile.

SQL> create pfile='/tmp/pfile.txt' from spfile;

File created.

SQL>

We check the setting of the JOB_QUEUE_PROCESSES parameter in the resulting pfile.

SQL> host fgrep job_queue_processes /tmp/pfile.txt

*.job_queue_processes=max(processes/10,10)

SQL>

So this has not only set the correct JOB_QUEUE_PROCESSES parameter value, but maintained the relationship to the PROCESSES parameter in the parameter definition.

As a result, if we alter the PROCESSES parameter value, we will also be altering the JOB_QUEUE_PROCESSES parameter value.

SQL> alter system set processes=600 scope=spfile;

System altered.

SQL> shutdown immediate;

Database closed.

Database dismounted.

ORACLE instance shut down.

SQL> startup;

ORACLE instance started.

Total System Global Area 1.4496E+10 bytes

Fixed Size                  9702824 bytes

Variable Size            2147483648 bytes

Database Buffers         1.2314E+10 bytes

Redo Buffers               23851008 bytes

Database mounted.

Database opened.

SQL> show parameter job_queue_processes

NAME                                        TYPE        VALUE

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

job_queue_processes                  integer         60

SQL>

2. Referencing Environment Variables

We check the current setting of the ORACLE_BASE environment variable.

SQL> host echo $ORACLE_BASE

/u01/app/oracle

SQL>

We check the current value of the AUDIT_FILE_DEST parameter.

SQL> show parameter audit_file_dest

NAME                                 TYPE         VALUE

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

audit_file_dest                      string        /u01/app/oracle/admin/cdb1_lhr

                                                               12p/adump

SQL>

We replace the path with one containing the ORACLE_BASE environment variable.

SQL> alter system set audit_file_dest='$ORACLE_BASE/admin/cdb1_lhr12p/adump' scope=spfile;

System altered.

SQL>

We create a parameter file based on the current spfile.

SQL> create pfile='/tmp/pfile.txt' from spfile;

File created.

SQL>

We check the setting of the AUDIT_FILE_DEST parameter in the resulting pfile.

SQL> host fgrep audit_file_dest /tmp/pfile.txt

*.audit_file_dest='$ORACLE_BASE/admin/cdb1_lhr12p/adump'

SQL>

So now the audit location is based on the value of the ORACLE_BASE environment variable, as it was set at instance startup.

We need to make sure any required environment variables are set before startup time, or the instance will not start. As an example, we unset the ORACLE_BASE environment variable value.

$ unset ORACLE_BASE

$ echo $ORACLE_BASE;

$

We shutdown the instance, and when we attempt to start it we get an error.

SQL> shutdown immediate;

Database closed.

Database dismounted.

ORACLE instance shut down.

SQL> startup;

ORA-07217: sltln: environment variable cannot be evaluated.

SQL>

We exit SQL*Plus and set the environment variable again.

$ export ORACLE_BASE=/u01/app/oracle

Now the instance starts as expected.

SQL> startup;

ORACLE instance started.

Total System Global Area 1.4496E+10 bytes

Fixed Size                  9702624 bytes

Variable Size            2147483648 bytes

Database Buffers         1.2314E+10 bytes

Redo Buffers               23851008 bytes

Database mounted.

Database opened.

SQL>

3. Considerations

Some things to consider when using expressions.

◉ When issued from the ALTER SYSTEM or ALTER SESSION commands, the expression must be enclosed in single quotes.

◉ When setting parameters we have access to the MIN and MAX functions, both of which accept two values. The MIN function returns the lower of the two values, and so may be useful in defining a maximum value for a parameter. The MAX function returns the higher of the two values, and so may be useful in defining a minimum value for a parameter. These aren't to be confused with the SQL functions of the same name.

◉ Environment variables must be set before instance startup, and their values are read at that point only.

◉ Expressions can be used in a spfile or a pfile.

Source: oracle-base.com

Monday, January 18, 2021

Introducing Oracle Database 21c

The latest Innovation release of the world's most popular database, Oracle Database 21c, is now generally available "cloud first" in the Oracle Cloud Database Service Virtual Machine (for RAC and single instance) and Bare Metal Service (single instance). It's also available in the Autonomous Database Free Tier Service in Ashburn (IAD), Phoenix (PHX), Frankfurt (FRA) and London (LHR) regions. General availability of Oracle Database 21c for on-prem platforms (including Exadata, Linux and Windows) will follow along in 2021.

Enabling a Data-Driven Future

Oracle has consistently taken the approach that storing and managing data in a converged database is more efficient and productive than breaking up into multiple single-use engines - which inevitably results in data integrity, consistency and security issues. Simply put, a converged database is a multi-model, multi-tenant, multi-workload database. Oracle Database fully supports multiple data models and access methods, simplifies consolidation while ensuring isolation, and excels in typical database workload use cases - both operational and analytical. Click the image below for a video introduction to Oracle's converged database.

Oracle Database 21c, Oracle Database Tutorial and Material, Oracle Database Exam Prep, Oracle Database Certification, Database Guides

The 21c generation of Oracle's converged database therefore offers customers: best of breed support for all data types (e.g. relational, JSON, XML, spatial, graph, OLAP, etc.), and industry-leading performance, scalability, availability and security for all their operational, analytical and other mixed workloads. Oracle's converged strategy also ensures that developers benefit from all Oracle Database 21c key capabilities (e.g. ACID transactions, read consistency, parallel scans and DML, online backups, etc.) - freeing them to focus on developing applications without having to worry about data persistence.

New in Oracle Database 21c


This latest Innovation release introduces a number of new features and enhancements that further extend database use cases, improves developer, analyst and data scientist productivity, and increases query performance.  Listed below is a subset of what's new in Oracle Database 21c.

Blockchain Tables


Blockchain as a technology has promised much in terms of solving many of the problems associated with the verification of transactions. While considerable progress has been made in bringing this technology to the enterprise, a number of problems exist. Arguably, the largest being the complex nature of building applications that can support a distributed ledger. Oracle Database 21c addresses this problem with the introduction of Blockchain Tables. These tables operate like any normal heap table, but with a number of important differences. The most notable of these being that rows are cryptographically hashed as they are inserted into the table, ensuring that the row can no longer be changed at a later date.

Oracle Database 21c, Oracle Database Tutorial and Material, Oracle Database Exam Prep, Oracle Database Certification, Database Guides

This essentially creates an insert only table, and users are unable to update or delete Blockchain Table rows. In addition, users are also prevented from truncating data, dropping partitions or dropping Blockchain Tables within certain time limits. These important capabilities mean that other users can trust that the data held in a Blockchain Table is an accurate record of events. 

Native JSON Datatype


Oracle introduced support for JSON in Oracle Database 12c, storing JSON data as a VARCHAR2 or a LOB (CLOB or BLOB). This enabled developers to build applications with the flexibility of a schemaless design model, with all the power of Oracle Database. For example, users could query JSON documents using standard SQL, take advantage of advanced analytics, index individual attributes or whole documents, and process billions of JSON documents in parallel. Oracle also provided tools to discover what attributes make up the JSON documents, and thereby trivially create relational views on top of the collections. It was also possible for developers to treat their Oracle Database as if it were a NoSQL database by accessing it with the SODA (Simple Object Data API) APIs available for Java, Node.js, Python, C and REST.

In Oracle Database 21c, JSON support is further enhanced by offering a native data type, "JSON". This means that instead of having to parse JSON on read or update operations, the parse only happens on an insert and the JSON is then held in an internal binary format which makes access much faster. This can result in read and update operations being 4 or 5 times faster and updates to very large JSON documents being 20 to 30 times faster.

CREATE TABLE j_order
(
   id     INTEGER PRIMARY KEY,
   po_doc JSON
); 

The new data type wasn't the only change that got introduced for JSON in Oracle Database 21c, Oracle also added a new JSON function JSON_TRANSFORM which makes it much simpler to update and remove multiple attributes in a document in a single operation.

 
UPDATE j_order SET po_doc = JSON_TRANSFORM( po_doc,
                                            SET '$.address.city' = 'Santa Cruz',
                                            REMOVE'$.phones[*]?(@.type == "office")'
                                          )
WHERE id = 555; 

Oracle has also added compatibility for the new JSON datatype to integration drivers and utilities like Datapump and GoldenGate.

Executing JavaScript inside Oracle Database


JavaScript is a ubiquitous scripting language that, among its many uses, enables richer user interaction in web applications and mobile apps. It's one of the few languages that runs in a web browser, and can be used to develop both client-side and server-side code. There is a large collection of existing JavaScript libraries for implementing complex programs, and JavaScript works in conjunction with popular development technologies such as JSON and REST.

In Oracle Database 21c, developers can now execute JavaScript code snippets inside the database, where the data resides. This allows them to execute short computational tasks easily expressed in JavaScript, without having to move the data to a mid-tier or browser. The Multilingual Engine (MLE) in Oracle Database 21c, powered by GraalVM, automatically maps JavaScript data types to Oracle Database data types and vice versa so that developers don’t have to deal with data type conversion themselves. Additionally, the JavaScript code itself can execute PL/SQL and SQL through a built-in JavaScript module. All this also enables APEX developers to use JavaScript as a first-class language within their APEX apps, without having to sacrifice the power of PL/SQL and SQL. Here is some sample code that uses the DBMS_MLE PL/SQL package to execute JavaScript code:

set serveroutput on;

DECLARE
  ctx dbms_mle.context_handle_t;
  source CLOB;
  greeting VARCHAR2(100);
BEGIN
  ctx := dbms_mle.create_context(); -- Create execution context for MLE execution

  dbms_mle.export_to_mle(ctx, 'person', 'World'); -- Export value from PL/SQL

  source := q'~
    var bindings = require("mle-js-bindings");
    var person = bindings.importValue("person"); // Import value previously exported from PL/SQL
    var greeting = "Hello, " + person + "!";
    bindings.exportValue("greeting", greeting); // Export value to PL/SQL
  ~';

  dbms_mle.eval(ctx, 'JAVASCRIPT', source); -- Evaluate the source code snippet in the execution context

  dbms_mle.import_from_mle(ctx, 'greeting', greeting); -- Import value previously exported from MLE

  dbms_output.put_line('Greetings from MLE: ' || greeting);

  dbms_mle.drop_context(ctx); -- Drop the execution context once no longer required
END;
/

SQL Macros


It is not unusual for a SQL statement to grow in complexity as the number of joins increase, or the operations performed on the retrieved data becomes more involved. It is also not uncommon for developers to try and solve this problem by using stored procedures and table functions to simplify these commonly used operations. This works extremely well to simplify code, but can potentially sacrifice performance as the SQL engine switches context with the PL/SQL Engine. In Oracle Database 21c, SQL Macros solve this problem by allowing SQL expressions and table functions to be replaced by calls to stored procedures which return a string literal to be inserted in the SQL we want to execute. It's an incredibly simple concept and one that C and Rust programmers will be familiar with. The following trivial example shows it in action.

First, let's create a table and insert a few rows.

CREATE TABLE line_items
(
   id        NUMBER,
   name      VARCHAR2(30),
   item_type VARCHAR2(30),
   price     FLOAT
);

INSERT INTO line_items VALUES (1, 'Red Red Wine', 'ALCOHOL', 15.6);
INSERT INTO line_items VALUES (2, 'Its Cold Out There Heater', 'RADIATOR', 200.49);
INSERT INTO line_items VALUES (3, 'How Sweet It Is Cake', 'FOOD', 4.56);
COMMIT;

The SQL below calculates the value added tax on rows in our LINE_ITEMS table

SELECT id,
  CASE
    WHEN item_type = 'ALCOHOL'     THEN ROUND(1.2 * price, 2)
    WHEN item_type = 'SOLAR PANEL' THEN ROUND(1.05 * price, 2)
    WHEN item_type = 'RADIATOR'    THEN ROUND(1.05 * price, 2)
    ELSE price
  END AS total_price_with_tax
FROM line_items; 

However, Oracle Database 21c can simplify by creating a function with the new SQL_MACRO keyword and returning a string.

CREATE OR REPLACE FUNCTION total_price_with_tax(the_price FLOAT, the_item_type VARCHAR2)
  RETURN VARCHAR2 SQL_MACRO(SCALAR) IS
BEGIN
  RETURN q'[CASE
    WHEN the_item_type = 'ALCOHOL'     THEN ROUND(1.2 * the_price, 2)
    WHEN the_item_type = 'SOLAR PANEL' THEN ROUND(1.05 * the_price, 2)
    WHEN the_item_type = 'RADIATOR'    THEN ROUND(1.05 * the_price, 2)
    ELSE the_price END]';
END;
/

Developers then simply reference the SQL Macro inside a select statement. The SQL that's executed is exactly the same as the original SQL Statement without the overhead of a context switch each time the row is fetched to execute this function.

SQL> SELECT id, total_price_with_tax(price, item_type) AS total_price_with_tax
        FROM line_items;

ID TOTAL_PRICE_WITH_TAX
---------- --------------------
1   18.72
2 210.51
3    4.56

It's also worth noting that developers can use the same approach when creating Parameterized Views and Polymorphic Tables.

In-Memory Enhancements


Analyzing data using a columnar model can result in massive performance improvements as compared to using a row-based model. However, updating data is significantly faster when using data held in rows. Oracle Database In-Memory is unique in that it allows users to benefit from both approaches. With this capability users can run their applications unchanged and Oracle Database In-Memory will maintain a columnar store supporting blazingly fast real-time analytical queries.

Oracle Database 21c introduces three major improvements to enhance performance and ease of use when using Oracle Database In-Memory:

◉ Database In-Memory Vector Joins : Through the use of its newly enhanced Deep Vectorization SIMD Framework, Oracle Database In-Memory can accelerate operations like hash joins on columns held inside of the in-memory column store. In the case of a hash join, the join is broken down into smaller operations that can be passed to the vector processor. The key-value table used is SIMD optimized and used to match rows on the left and right-hand sides of the join. This approach can result in join performance improvements of up to 10 times over traditional methods.

◉ Self-Managing In-Memory Column Store : When Oracle Database In-Memory was first released, users had to explicitly declare which columns were to be populated into the In-Memory Column Store. This gave users a high degree of control if memory was tight. Oracle Database 18c introduced functionality that would automatically place objects in the Column Store if they are actively used and removed objects that weren't. However, users still had to indicate the objects to be considered. In Oracle Database 21c setting INMEMORY_AUTOMATIC_LEVEL to HIGH, ensures that all objects are considered - thereby simplifying the job of managing the in-memory column store.

◉ In-Memory Hybrid Columnar Scans : It is often not possible to have every column of every table populated in the Column Store because memory is limited. In many instances, this isn't an issue but every once in a while users may encounter a query which needs data(columns) from the Column Store and data that's only available in the row store. In previous releases of Oracle Database In-Memory, such querys would simply run against the row store. In Oracle Database 21c users can now use both! The optimizer can now elect to scan the In-Memory Column Store and fetch projected column values from the row store if needed. This can result in a significant improvements in performance.

Oracle Database 21c, Oracle Database Tutorial and Material, Oracle Database Exam Prep, Oracle Database Certification, Database Guides
Hybrid Columnar Scan

Other Notable Enhancements


Please refer to the Oracle Database 21c New Features Guide for complete (long) list, but here are a few more notable enhancements that will be of interest to DBAs, developers, analysts and data scientists:

◉ Expression based init.ora parameters : It's now possible to base database parameters (init.ora) on calculations made on the configuration of the system, i.e. set the database parameter CPU_COUNT on half the number of CPUs available to the operating system.

◉ Automatic Zone Maps : Oracle Database 21c on Exadata can now automatically create Zone Maps based on the predicates used in queries. Previously, this was a manual operation requiring users to understand how the data would be accessed. Automatic zone maps can dramatically reduce the number of blocks that need to be scanned.

◉ In-Database Machine Learning (ML) algorithms built into Oracle Database enables data scientists to leverage the power of Oracle Database to build predictive models (using over 30 ML algorithms) running directly on data held in database tables (as opposed to extracting data into a file system or specialist database for 'sandbox' analysis). Oracle's approach of moving ML algorithms to the underlying data minimizes data movement, achieves scalability, preserves data security, and accelerates time-to-model deployment for predictive-type analytics Oracle Database 21c adds support for the MSET-SPRT and XGBoost algorithms, and the Adam Optimization solver for the Neural Network Algorithm.

◉ AutoML : Oracle Database 21c makes it even simpler for data scientists and analysts to take advantage of in-database machine learning by providing a Python machine learning interfaces to the database. This new client tool compliments existing R and SQL interfaces already available. AutoML simplifies the development of predictive machine learning models by automating the model selection, feature selection and parameter tuning processes required for building accurate models

◉ Optimized Graph Models : Graphs can consist of millions or even billions of edges and vertices and so the storage optimizations we've made to the graph capabilities in Oracle Database 21c preview release can result in big space and performance improvements for your models.

◉ Sharding Enhancements : Oracle Sharding enables linear scalability, fault isolation and geo-distribution for hyperscale applications while retaining the flexibility of SQL. To make it easier to develop Java applications against Oracle Sharding we've introduced a new Java Data Source that makes it simple to obtain connections without having to define the shard key or manage the connection key explicitly. We have also made sharding more fault-tolerant by automatically looking for alternates if the shard you are working on fails during execution. 

◉ Persistent Memory (PMEM) Support : Oracle Database 21c includes support for PMEM file systems that can offer significant latency and bandwidth improvements over traditional file systems that use SSD or spinning disks. However, the applications using them need to understand how to safely write to them and the most efficient way to use them in conjunction with other OS resources. Oracle Database 21c's implementation provides atomic writes, safe guarding against partial writes during unexpected power outages. It also offers Fast I/O operations using memory copy. In addition, it efficiently uses database buffer cache by bypassing and reading directly from PMEM storage.

Source: oracle.com

Saturday, January 9, 2021

Oracle Database 12c Network configuration

This post will help you completely configure your client/server network.

For a client application and a database to communicate, the client application must be able to identify the database it wants to connect to, and the database must provide an identification. You can use a service name to connect to a database. A service name is a logical representation of a database, which is the way a database is presented to clients. A single database can be presented as multiple services.

Service names can provide location transparency so that the client application does not have to know the server’s location. If the database is moved to another location, then you must reconfigure only Oracle Net. No changes are necessary to client applications.

Configuring a database listener with Oracle Net Manager

Oracle Net Manager provides various network configuration features, including the ability to configure profiles.

Note that you can also configure a database listener using NetCA.

In order to create and configure a listener from Oracle Net Manager, you will need to

1. launch it from Windows start menu

2. scroll down to “Listeners” and hit the “Create” button (+)

Oracle Database 12c Network configuration, Oracle Database 12c, Oracle Database Learning, Oracle Database Exam Prep, Oracle Database Certification

Next, provide a unique identifier for the listener. In this example, we use “LISTENER_GIT2”.

Oracle Database 12c Network configuration, Oracle Database 12c, Oracle Database Learning, Oracle Database Exam Prep, Oracle Database Certification

Select protocol addresses that identify the database. This address defines the protocol the listener is listening on and any other protocol-specific information. Click the “Add Address” button to add a listening protocol address.

Oracle Database 12c Network configuration, Oracle Database 12c, Oracle Database Learning, Oracle Database Exam Prep, Oracle Database Certification

Provide a hostname or IP address, a port number for the listening protocols TCP/IP and TCP/IP with SSL

Oracle Database 12c Network configuration, Oracle Database 12c, Oracle Database Learning, Oracle Database Exam Prep, Oracle Database Certification

After specifying protocol addresses, you will need to attach your listener to an Oracle database instance. To do so, select “Database Services” from the drop-down menu.

Oracle Database 12c Network configuration, Oracle Database 12c, Oracle Database Learning, Oracle Database Exam Prep, Oracle Database Certification

Provide the global name and SID of your database and the Oracle Home Directory in order to link your listener with your instance.

Important: Don’t forget to save your network configuration. Go to “File” and “Save Network Configuration”

Oracle Database 12c Network configuration, Oracle Database 12c, Oracle Database Learning, Oracle Database Exam Prep, Oracle Database Certification

Once you save your configuration, you can start or see the newly created listener using the integrated tool LSNRCTL.

Oracle Database 12c Network configuration, Oracle Database 12c, Oracle Database Learning, Oracle Database Exam Prep, Oracle Database Certification

To start a specific listener, you will need to enter the following command

start listener_name

If no name is specified, LSNRCTL will try to start the default listener (configured with TCP/IP and port number 1521).

Oracle Database 12c Network configuration, Oracle Database 12c, Oracle Database Learning, Oracle Database Exam Prep, Oracle Database Certification

The status command of LSNRCTL will give you detailed informations of the listener configuration such as the listener identifier, start date, listener parameter file, protocol descriptions (hostname or host IP address and port numbers), the linked database.

Oracle Database 12c Network configuration, Oracle Database 12c, Oracle Database Learning, Oracle Database Exam Prep, Oracle Database Certification

Oracle database 12c Client configuration


This section describes how to use SQL*Plus to connect to an Oracle database from a client computer. SQL*Plus is typically installed when you install Oracle Database client software.

After client installation, Oracle provide bunch of tools to access or manage the database from the client. For example, from the client computer, you can test the connectivity of your database using tnsping utility. In the following, we check if the database service dic2git is available on server.ept.sn listening on port number 1599. 

Oracle Database 12c Network configuration, Oracle Database 12c, Oracle Database Learning, Oracle Database Exam Prep, Oracle Database Certification

Once, the availability of the instance verified, we can connect to the database from the client using an easy connect connection string. The easy connect naming method provides TCP/IP connectivity to databases without requiring you to configure Oracle Net Services.

Oracle Database 12c Network configuration, Oracle Database 12c, Oracle Database Learning, Oracle Database Exam Prep, Oracle Database Certification

Configuring Oracle Net Services from the client


To configure Oracle Net Services, you will need to start Oracle Net Manager from Windows start menu. In this section, we will configure only Service naming methods to create a network SID.

Select “Service Naming” and click on the “Create” button.

Oracle Database 12c Network configuration, Oracle Database 12c, Oracle Database Learning, Oracle Database Exam Prep, Oracle Database Certification

Provide then a service name. This network SID will be used to access the database remotely from the client. Make sure the name you select refers to the remote instance. In this example, we use git2client.

Oracle Database 12c Network configuration, Oracle Database 12c, Oracle Database Learning, Oracle Database Exam Prep, Oracle Database Certification

Next, select a network protocol you want to use to access the database. Make sure the protocol is configured on the server side.

Oracle Database 12c Network configuration, Oracle Database 12c, Oracle Database Learning, Oracle Database Exam Prep, Oracle Database Certification

Provide the server hostname or IP address and a port number. This information can be found on the listener configuration (server side). In our case, the server name is server.ept.sn and the port number is 1599 (see Page 1)

Oracle Database 12c Network configuration, Oracle Database 12c, Oracle Database Learning, Oracle Database Exam Prep, Oracle Database Certification

Next, you will need to enter the database global name you want to access and select a connection mode (dedicated mode, shared server, …)

Oracle Database 12c Network configuration, Oracle Database 12c, Oracle Database Learning, Oracle Database Exam Prep, Oracle Database Certification

The last step allow you test your network SID configuration. The wizard will try to connect to the remote database using a prebuilt user account, namely Scott. If there are no configuration issues, the wizard will be able to connect to the instance.

Oracle Database 12c Network configuration, Oracle Database 12c, Oracle Database Learning, Oracle Database Exam Prep, Oracle Database Certification

The connection attempt fails since Scott account is locked. On the other hand, it means the wizard was able to access the database server remotely. We can perform the test again using a non-locked account on the database.

Oracle Database 12c Network configuration, Oracle Database 12c, Oracle Database Learning, Oracle Database Exam Prep, Oracle Database Certification

If the HR account is not locked, we may use it to perform another test.

Oracle Database 12c Network configuration, Oracle Database 12c, Oracle Database Learning, Oracle Database Exam Prep, Oracle Database Certification

Oracle Database 12c Network configuration, Oracle Database 12c, Oracle Database Learning, Oracle Database Exam Prep, Oracle Database Certification

One last thing you will to do is to save the current network configuration. Otherwise, no change will be made on the client computer and all the configuration may be lost.

Oracle Database 12c Network configuration, Oracle Database 12c, Oracle Database Learning, Oracle Database Exam Prep, Oracle Database Certification

After saving your configuration, you can test the service you have configured using the tnsping utility. Since the service is configured on the client computer, we will provide only the SID.

Oracle Database 12c Network configuration, Oracle Database 12c, Oracle Database Learning, Oracle Database Exam Prep, Oracle Database Certification

The service is available on the network and allow us to connect to the remote database using a simplified connection string.

Oracle Database 12c Network configuration, Oracle Database 12c, Oracle Database Learning, Oracle Database Exam Prep, Oracle Database Certification