Posts

Nested WITH Clause in Oracle AI Database 26ai(23.26.2)

  The WITH clause , also known as a Common Table Expression (CTE) , is widely used to make complex SQL statements easier to organize and understand. It allows a query to define an intermediate result and then reference that result from the main query. Previously, Oracle did not support placing a WITH clause inside another WITH query block, resulting in ORA-32034 . Oracle AI Database 26ai removes this restriction and supports nested WITH clauses. This article demonstrates the enhancement by starting with a regular SQL query, rewriting it with a standard WITH clause, and finally using a nested WITH clause in Oracle AI Database 26ai . 1. Execute the Query Without a WITH Clause Imagine we want to display each customer’s name and city, along with the total amount of their completed orders. We can achieve this using a regular SQL statement: SQL > SELECT c.customer_name, c.city, SUM (o.amount) AS total_amount FROM customers c JOIN orders o ON o.customer_id = c.customer_i...

Duplicating a PDB into Another CDB

  In Oracle Database 12c , it is possible to use the DUPLICATE command at the PDB level. However, there is a limitation: a new CDB must also be created as part of the duplication process. Otherwise, the operation fails with an error. [oracle @cdb2 ~] $ rman target sys/sys @cdb1 auxiliary sys/sys @cdb2 connected to target database: cdb1 ( DBID = 4178530773 ) connected to auxiliary database: cdb2 ( DBID = 839691519 ) RMAN > DUPLICATE DATABASE TO CDB2 PLUGGABLE DATABASE pdb12c; RMAN - 05500 : the auxiliary database must be not mounted when issuing a DUPLICATE command Starting with Oracle Database 18c , a PDB can be duplicated into an existing CDB . This is a new capability in Oracle Database 18c. The following example demonstrates how to perform this operation. In this example, the PDB18C PDB in CDB1 is duplicated into CDB2. During the duplication process, changes may occur in the source PDB ( CDB1 ). At the end of the duplication, these changes are applied to the tar...