Friday, February 10, 2023

Pre-creating Oracle database users in PDBs and CDBs

In a previous blog post, I gave an example on how to copy a schema using a database link within the same (pluggable) database.

Few people asked me about the errors during the Data Pump import, mostly because of a pre-created user: ORA-31684: Object type USER:”KERRY” already exists.

The user was created with just the DBA role (for simplicity) but often you need to know in advance, that is prior to creation, the roles and privileges needed for that user. That is, what to grant the user before the import!

Oracle Database, Oracle Database Career, Oracle Database Skills, Oracle Database Jobs, Oracle Database Prep, Oracle Database Preparation, Oracle Database Guides, Oracle Database Learning, Oracle Database Guides

Here is how to extract all with one command which creates a script for running the necessary privileges and roles, let us assume that the use is called JDONTCHEFF:

select 'grant '||GRANTED_ROLE||' to JDONTCHEFF;' from DBA_ROLE_PRIVS where grantee = 'JDONTCHEFF'
union all
select 'grant '||PRIVILEGE||' to JDONTCHEFF;' from DBA_SYS_PRIVS where grantee = 'JDONTCHEFF'
union all
select 'grant '||PRIVILEGE||' on '||GRANTOR||'.'||TABLE_NAME||' to JDONTCHEFF;' from DBA_TAB_PRIVS where grantee = 'JDONTCHEFF';

Oracle Database, Oracle Database Career, Oracle Database Skills, Oracle Database Jobs, Oracle Database Prep, Oracle Database Preparation, Oracle Database Guides, Oracle Database Learning, Oracle Database Guides

As you can see, all the information can be found/extracted from DBA_ROLE_PRIVS, DBA_SYS_PRIVS and DBA_TAB_PRIVS.

Note that you need to run this in the PDB where the local user is, if you run it in the CDB you will most likely get “no rows selected”.

If you do not have DBA access for some reason, then just modify the above queries to view the privileges just for the current user. This is done by alternatively querying the USER_ versions of the above DBA_ views. And you run them as the current user.

Here is another example which shows that things are not after all that simple:

Oracle Database, Oracle Database Career, Oracle Database Skills, Oracle Database Jobs, Oracle Database Prep, Oracle Database Preparation, Oracle Database Guides, Oracle Database Learning, Oracle Database Guides

Note that I have a role called HACKER which has been already granted to the DBA role:

SQL> grant HACKER to DBA;

Grant succeeded.

Oracle Database, Oracle Database Career, Oracle Database Skills, Oracle Database Jobs, Oracle Database Prep, Oracle Database Preparation, Oracle Database Guides, Oracle Database Learning, Oracle Database Guides

So, why is the HACKER role missing from the script above? It is because the DBA_ privilege views only display GRANTEES with directly assigned access – note here that the role HACKER is inherited from another role. Well, all fine – it will be eventually granted indirectly. Such roles are not just shown.

select * from dba_role_roles; will show which roles have been granted to roles.

Oracle Database, Oracle Database Career, Oracle Database Skills, Oracle Database Jobs, Oracle Database Prep, Oracle Database Preparation, Oracle Database Guides, Oracle Database Learning, Oracle Database Guides

Note also that you need to extract the user profile and the tablespace quotas before pre-creating the user. Use DBA_TS_QUOTAS and DBA_PROFILES. Plus the password!

Source: juliandontcheff.wordpress.com

Monday, February 6, 2023

Key Considerations Before Migrating Oracle Databases to the Cloud

Moving your on-premises workloads to the cloud can offer many benefits, such as downsizing data centers, eliminating infrastructure management, accelerating application deployments, simplifying administration with automated and autonomous services, and lowering cost. If you’re ready to start moving existing Oracle databases to the cloud, it’s important to carefully evaluate your requirements to determine which cloud provider can best meet your application and operational needs.


1. Does the cloud service support your database requirements?
2. Can you achieve the required service levels?
3. How will you meet your compliance requirements?
4. What security controls are available to protect your data?
5. What are your options for migrating your databases?
6. What is the cost impact?

Let’s discuss each of these in more detail.

1. Does the cloud service support your database requirements?


Although many of you are developing new cloud-native applications, you will still need to migrate existing on-premises applications to the cloud. The easiest approach that requires the least amount of effort is to move your applications with no changes. If your applications are already written for Oracle Database, you should ensure your cloud service provider supports it without compromises. For example, if you are running Oracle Database with Oracle RAC on-premises, it’s important to choose a cloud service that can support all of the Oracle Database features that you currently use. Oracle Cloud is the only cloud that offers Exadata, Autonomous Database, and supports Oracle RAC - enterprise-grade functionality essential for many customers moving their critical workloads from on-premises to the cloud. For those already committed to other clouds, multicloud offerings such as the Oracle Database Service for Azure, allow you to benefit from database services in Oracle Cloud with your applications running in other clouds.

Migrating Oracle Databases, Oracle Database, Oracle Database, Database Skills, Database Jobs, Oracle Database Tutorial and Materials

2. Can you achieve the required service levels?


Ensuring you choose a cloud provider that enables you to achieve your required service levels is another critical factor to consider before migrating your databases to the cloud. You’ll especially want to consider your options carefully if your applications require high performance, are critical to your operations, and protect vital data. Migrating to a cloud that cannot match or exceed your on-premises performance, reliability, security, and operational requirements could spell disaster for your organization. Doing the research upfront to select a cloud provider that meets your needs will save you the headaches associated with migrating to the cloud and struggling to meet your required service levels.

Oracle offers cloud database services to meet any workload requirement starting with Oracle Database on standard virtual machines. For more demanding requirements, Oracle offers the performance, availability, and security of its premier Exadata platform as cloud infrastructure, which serves as the foundation for Autonomous Database and Exadata Database Service. Oracle Cloud automation deploys Oracle Database services with Maximum Availability Architecture (MAA) best practices uniquely featuring Oracle RAC to improve your service levels. Autonomous Database deploys all MAA best practices automatically to provide the highest service levels.

Migrating Oracle Databases, Oracle Database, Oracle Database, Database Skills, Database Jobs, Oracle Database Tutorial and Materials

3. How will you meet your compliance requirements?


Compliance is another area you must consider before making the decision to migrate your databases to the cloud. Oracle is committed to helping address an ever more complex regulatory environment by providing information regarding industry-standard programs that demonstrate how Oracle Cloud services adhere to compliance programs. These programs can assist in your compliance and reporting, providing an independent assessment of the security, privacy, and compliance of Oracle Cloud services.

Many industries are subject to additional compliance requirements that can prevent public cloud adoption, such as the requirement for full physical control over data, and in some cases limitations on where data may be geographically stored. To meet the needs of customers who cannot bring their data to the public cloud, Oracle offers Exadata Cloud@Customer, which brings the cloud to customer data centers. It provides cloud benefits while meeting stringent data residency requirements. Since the data is stored in customer data centers next to existing on-premises applications, customers can also easily maintain their current system dependencies.

4. What security controls are available to protect your data?


Security is top of mind for anyone migrating to the cloud. Data protection from external threats or misuse, plus monitoring and auditing tools, are critical for your organization. Oracle’s comprehensive defense in depth security strategy integrates preventive, detective, and responsive security controls throughout the entire stack - not just the database. These include authentication controls for databases, virtual machines, and infrastructure; isolation controls for networks; and encryption for data at rest and in transit. Infrastructure and database maintenance is also a key component of data protection. Infrastructure for all Oracle Database services is maintained by Oracle. Database updates are regularly released for the co-managed database services. Since Autonomous Database is a fully-managed service, the latest updates are automatically applied with zero downtime.

In addition to external threats, some customers may be uncomfortable with a cloud provider’s access to infrastructure and services they use. Since cloud providers may have elevated privileges, maintaining security and isolation requires additional controls. To address this concern, Oracle provides Operator Access Control (OpCtl) to limit access by Oracle Cloud Operations to sensitive systems and their underlying infrastructure. With OpCtl, customers approve operator access with reduced privileges to specific components for a period of time. Customers can also monitor access with command and keystroke auditing as well as revoke access permissions. These additional protections address compliance requirements for customers in regulated industries such as utilities and financial services, which removes a previous impediment to cloud service adoption. To enable customers to offload administration, Database Vault is used with Autonomous Database to provide secure isolation between customer data and Oracle Cloud Operations. Database Vault can also be used with all Oracle Database services to enforce customer policies for data access. To further help customers manage security and compliance requirements, Oracle includes Data Safe with all Oracle Database services in Oracle Cloud to provide security and user privilege assessments, drift detection, database auditing, and much more.

These are just a few examples of the security controls available in Oracle Cloud that help protect your data.

5. What are your options for migrating your databases?


Migrating your applications to the cloud impacts your entire stack including your databases. You can migrate the entire stack as is, make small improvements, or re-architect it as part of your cloud journey. The amount of effort required and your tolerance for application disruption will help determine the type of database migration to pursue. Since Oracle Database is 100% compatible between on-premises and cloud deployments, all you need to do is move the data.

With Oracle Database you can use familiar migration methods, such as backup and recovery, provided you can tolerate some downtime. Since downtime can be a problem for critical databases, Oracle offers an automated solution using Zero Downtime Migration (ZDM) to simplify your database migration. ZDM can be used to deploy a replica database in Oracle Cloud, synchronized with your production database on-premises. Once you are ready, you switch your applications to the cloud database to complete your cloud migration.

Migrating Oracle Databases, Oracle Database, Oracle Database, Database Skills, Database Jobs, Oracle Database Tutorial and Materials

6. What is the cost impact?


Cloud deployments can provide efficiency, reduced management, and automation of common tasks that lower operational costs. However, not everyone who moves their databases to the cloud experiences a reduction in total costs – often because of the database service and cloud provider they select. To fully benefit from the cost reductions associated with migrating Oracle databases to the cloud, you should select database services that provide superior performance, let you pay only for what you use, reduce complexity through consolidation, and allow you to bring your own licenses.

Superior performance enables you to use less infrastructure, but it’s also important to align license spend with your actual requirements. Rather than operating servers in the cloud that are configured to handle peak workloads, Oracle enables you to adjust compute resources as required for Oracle Database services in Oracle Cloud. Autonomous Database automatically scales compute resources in real time as workload requirements change – all without impacting database availability. Exadata Database Service supports user initiated online compute resource scaling and provides APIs to automate scaling based on resource utilization. The pay-for-use elasticity of Autonomous Database and Exadata Database Service can dramatically reduce your Oracle Database licensing costs over time.

Migrating Oracle Databases, Oracle Database, Oracle Database, Database Skills, Database Jobs, Oracle Database Tutorial and Materials

Database consolidation is another way to lower your total database costs, by reducing the total amount of cloud infrastructure resources. In the same way that dynamic resizing of database consumption helps reduce licensing costs, database consolidation enables you to improve infrastructure utilization. Analyst studies from ESG, Wikibon, and others have shown that database consolidation on Exadata in Oracle Cloud significantly reduces complexity and overall costs while still meeting your performance objectives. Dynamic scaling of database consumption coupled with database consolidation provides the most cost-effective way of running mission-critical databases. With Oracle Cloud, you also have the choice of license-included or bringing your own licenses to the database services for all Oracle Database Enterprise Edition features. Providing license mobility enables you to leverage your on-premises Oracle Database investments.

Key Takeaways


There are many considerations involved in migrating Oracle databases to the cloud. The right cloud provider must meet your performance, reliability, security, compliance, migration, operational, and cost requirements. Oracle Cloud eliminates many of the pitfalls that can hinder your cloud database migration. Running Oracle Database with its converged capabilities in the Oracle Cloud not only reduces complexity and simplifies application development, but can also provide the benefits of the fully-managed Autonomous Database, the performance of Exadata, and Oracle’s second generation cloud infrastructure that optimizes MAA. Oracle has decades of experience delivering technologies that support enterprise-grade database workloads on-premises. With careful planning, you too will be successful in migrating your on-premises Oracle databases to the cloud.

Source: oracle.com

Monday, January 30, 2023

1Z0-1069-22 Exam Tips to Pass Oracle Certification In 2023

Oracle Recruiting Cloud 2022 Certified Implementation Professional, Oracle, 1Z0-1069-22, 1Z0-1069-22 Exam,  Oracle 1Z0-1069-22

Earning an Oracle Recruiting Cloud 2022 Implementation Professional certification will help you learn new technologies and skills, thus increasing your probability of a promotion. Oracle professionals believe that getting an Oracle 1Z0-1069-22 certification can help grow their careers.

The development of science and technology has brought a wave of competition in the cloud industry. One of the best measures to survive in this cut-throat competitive world is demonstrating your skills and getting certified. The Oracle Recruiting Cloud 2022 Implementation Professional 1Z0-1069-22 exam serves this goal, and the Oracle 1Z0-1069-22 exam plays a crucial role in achieving your dreams. The Oracle certifications are globally accepted and improve your opportunities for higher salaries.

Oracle 1Z0-1069-22 exam is high enough for all those professionals who need to boost their career in IT. This exam is an opportunity to open new realms in your career. We present the preparation guide for the Oracle 1Z0-1069-22 exam to assist you in this process. To complete the loop, it is equally important to have all the essential elements related to the exam.

Why Choose the Oracle 1Z0-1069-22 Exam?

Oracle 1Z0-1069-22 validates your skills to become an Oracle Recruiting Cloud 2022 Certified Implementation Professional and supplies you with an edge over your competitors. Moreover, Oracle certifications are well-recognized around the globe.

Therefore you can derive the following benefits from this certification:

  • To begin with, the 1Z0-1069-22 exam develops your knowledge, and an Oracle certification is demanding to your prospective employers.
  • Also, it enhances your potential earning power to command a higher salary.
  • Subsequently, you receive access to a secure digital badge to add to your social media profiles.
  • Moreover, through this exam, you get to join the 80% of Oracle certification holders who reported a promotion or salary increase and career improvement.

This certification exam is undoubtedly a move ahead in your career advancements. If you need clarification about the exam preparations, relax because we will provide you with a specially curated guide that solves all your doubts.

Study Tips for Oracle 1Z0-1069-22 Exam

We know how overwhelming can all this information be for you, and you might be wondering about all these questions. Just strap in because we provide you with preparation tips specially curated by experts. This study guide will help you throughout your journey for this exam and act as a bridge for your career advancements.

So Let’s start step by step:

1. Understand the 1Z0-1069-22 Exam Topics

The course domains act as a blueprint for the exam. You should be very clear with the syllabus of the Oracle 1Z0-1069-22 exam. Remember to refer to the official website before commencing your preparations.

2. Take a Look at Study Resources

Many online and offline study resources are available to prepare for this exam. Hence you should look over all the study resources and choose from the plethora of options.

3. Prepare from Oracle 1Z0-1069-22 Books

Books have always been the golden way to prepare for an exam. They guarantee in-depth clarity of complicated topics and are easy to refer to. There are different books available for this certification exam. You may review them and choose the one that suits you the best.

4. Online Training Course

This exam is practically oriented; therefore, it requires hands-on experience in labs and clarity of the topics. Training is essential to answer questions timely and accurate. Oracle offers a training program for your preparations. The training program provided in Oracle Talent Management Cloud Learning Subscription

5. Start Taking 1Z0-1069-22 Practice Test

1Z0-1069-22 practice tests are a must for any exam preparations. Practice tests help you evaluate your performance and evaluate your weaker areas. They provide a similar exam environment to check your accuracy and speed. Attempt multiple practice tests to improve and excel in this field.

You can refer to the online expert learning resources designed to practice for the 1Z0-1069-22 exam to provide a genuine exam experience. Also, you must refer to a unique set of questions shuffled with different levels, which will help you check your preparations. You should attempt as many practice tests as possible before the final exam and analyze the weak areas to improve.

6. Join an Online Community

Online forums and study groups are critical in preparing for an exam and help you learn from the experts. Moreover, such online study groups are fruitful as they connect you with other candidates appearing for the same, provide valuable insights into the certification, and clarify your doubts.

Follow the preparation tips, and your success is guaranteed. You will surely clear this 1Z0-1069-22 exam on the first attempt with flying colors.

Friday, January 20, 2023

What is a Converged Database?


"We need to build a new mobile app so customers can submit and retrieve documents, so I will need a specialized database to store the documents, right?

Oh, wait, next week, this other project requires we provide a new payment system with user fraud protection built in to meet compliance, and I am going to store relational data as well. We’ll need a specialized Blockchain database and a relational database, right?"

These conversations can leave you concerned and frustrated, wondering how you will allocate your resources to these specialized data stores.

But perhaps the solution to your problem is not more resources but a Converged Database.

A Converged Database is a database that has native support for all modern data types, analytics, and the latest development paradigms built into one product.

Converged Database, Oracle Database, Oracle Database Exam, Oracle Database Career, Database Skill, Database Jobs, Database Certification, Database Prep, Database Preparation, Database Tutorial and Materials
Converged Databases support Spatial data for location awareness, JSON for flexibility, IoT for device integration, in-memory technologies for real-time analytics, and of course, traditional relational data. A Converged Database can run all sorts of workloads, from Geo-Distributed to Blockchain to Analytics and Machine Learning. It can also handle any development paradigm, including Microservices, Events, REST, SaaS, and CI/CD, to name a few.

Traditionally when new data management technologies first come out, they are implemented as separate products. For example, when Blockchain first came out, it was a separate stand-alone system that required you to use an entirely different, proprietary way to store and access data. 

By integrating new data types, workloads, and paradigms as features within a Converged Database, you can support mixed workloads and data types in a much simpler way. You don't need to manage and maintain multiple systems or worry about providing unified security across them.

You also get synergy across these capabilities. For example, by supporting Machine Learning algorithms and Spatial data in the same database, you can easily do predictive analytics on Spatial data. Making it dramatically easier and faster to develop data-driven apps.

Converged Database, Oracle Database, Oracle Database Exam, Oracle Database Career, Database Skill, Database Jobs, Database Certification, Database Prep, Database Preparation, Database Tutorial and Materials
A good analogy for a Converged Database is a smartphone. In the past, if you wanted to make phone calls, you would use a phone, and if you wanted to take a picture or video, you would use a camera. If you tried to navigate somewhere, you would need a map or a navigation system. If you wanted to listen to music, you needed an iPod or other similar device.

But with a smartphone, all these products have been converted or converged into one. Each of these original products is now a feature of the smartphone. Having all these features combined into a single product inherently makes your life easier, as you can stream music over the phone's data plan or upload pictures or videos directly to social media sites.

The same ease of use and convenience you get from a smartphone also hold for a Converged Database. 

The Oracle Database is an excellent example of a Converged Database, as it provides support for Machine Learning, Blockchain, Graph, Spatial, JSON, REST, Events, Editions, and IoT Streaming as part of the core database at no additional cost. It allows you to support many diverse projects using a single platform, significantly reducing complexity and management overhead while minimizing risk.

A converged database does not mean data must be in one monolithic database. A converged database enables you to choose your data architecture for each application. You decide when to consolidate data into fewer databases and when a fully distributed design is best.


Source: oracle.com

Wednesday, January 18, 2023

User Assistance Enhancements in 2022: Autonomous Database On Dedicated Exadata Infrastructure

Oracle Database, Oracle Database Certification, Oracle Database Career, Oracle Database Skills, Oracle Database Jobs, Oracle Database Tutorial and Materials

Happy New Year, 2023! Greetings from the User Assistance Desk.


We at User Assistance for Autonomous Database on Dedicated Exadata Infrastructure have been working continuously throughout 2022 to add more and more enhancements to our technical documentation. This blog presents those that made Autonomous Database documentation easier to locate, consume, and try. Even though, they are currently implemented in Autonomous Database on Dedicated Exadata Infrastructure, they will be expanded to all database documentation over time, as appropriate.

Let's get started!

Revised Folder Structure


Autonomous Database articles are now reorganized into groups that are more intuitive to the audience! 

An article is a single-page publication (with scrolling) that contains all the topics needed to cover a specific customer need. Look into Quick Start to get hold of the service quickly and try out our Livelabs or get inside Features to explore a specific feature you're interested in. If you are already using the service for some time and looking for detailed instructions on implementing something, jump straight into How-to Guides and get going! Tasks guide you in using the service for a specific job, such as migration, cloning, development, user management, and many more. Get a peek at the latest announcements and typical workflows from Overview and find many reference materials in the Reference section. Try it!

Oracle Database, Oracle Database Certification, Oracle Database Career, Oracle Database Skills, Oracle Database Jobs, Oracle Database Tutorial and Materials

Self-Contained Articles for Key Features


We now have articles that give you a holistic picture of the critical Autonomous Database features backed up with overview graphics, use cases, or lists wherever applicable.

Look into the Key Security Features for a bird's eye view of various security features supported by Autonomous Database and how each is related. Check out the Service Maintenance article for in-depth information about Autonomous Database's change management capabilities. Explore the Migrate and Load articles to provide a comprehensive list of migration options mapped to the applicable use cases.  Along with a big picture of a service feature, you will also find helpful pointers to the related how-to guides wherever appropriate. Isn't this valuable? 

More and more features to follow this route!

Badges


Badges? Yes, badges. As our documentation covers Autonomous Database on Oracle Public Cloud and Exadata Cloud@Customer (ExaCC) platforms, we devised badges to tag the content that only applies to either platform:

◉ APPLIES TO: Oracle Public Cloud only
◉ APPLIES TO: Exadata Cloud@Customer only

Even though both platforms support a standard set of features for Autonomous Databases, there are a few exceptions where only one of these platforms supports a feature. For example, Changing the License Type on an Autonomous VM Cluster is supported only on the Exadata Cloud@Customer platform where as Using Operations Insights on Autonomous Database is only allowed on Oracle Public Cloud.

Tip: For the complete list of features supported exclusively by Oracle Public Cloud or Exadata Cloud@Customer platforms, refer to Feature Parity Between Oracle Public Cloud and Exadata Cloud@Customer Deployments.

Revised Oracle Help Center (OHC) Landing Pages


You may be a developer interested in the content appropriate to developing applications with Autonomous Database or a fleet administrator trying to perform some administrative tasks for your service. It has gotten easier if you're looking for user role-specific tasks with Autonomous Database. You can now see user-role-specific tiles on the Autonomous Database landing pages in Oracle Help Center (OHC). Click the tile you're interested in, and the content that applies to that specific user role is loaded! I hope this is useful, and try it out the next time you need it.

Tip: See User Roles Associated with Autonomous Database to understand the different user roles.

Oracle Database, Oracle Database Certification, Oracle Database Career, Oracle Database Skills, Oracle Database Jobs, Oracle Database Tutorial and Materials

This is not an exhaustive list of enhancements implemented in 2022 but an attempt to capture what's happening in the User Assistance area for the Autonomous Database.

Source: oracle.com

Friday, January 13, 2023

Configure OCI DataFlow Interactive Notebook & Access Autonomous DataWarehouse & Object Storage

Oracle Cloud Infrastructure (OCI) Data Flow is a fully managed big data service that lets you run Apache Spark applications at any scale with almost no administration. Spark has become the leading big data processing framework and OCI Data Flow is the easiest way to run Spark in Oracle Cloud because there’s nothing for developers to install or manage.

Now perform your analytics on OCI DataFlow using Interactive Data Science Notebook:


OCI DataFlow is now coming with Interactive OCI Data Science Notebook. Now, users can seamlessly enable and start playing with their data using the Data Science Notebook. This Notebook experience leverages the power of Apache Spark. Here, We will see how easily an OCI DataFlow Environment can be created on OCI using Conda. We will be creating OCI Data Science session & Notebook and will access OCI Dataflow spark platform using Livy session. Submit fault-tolerant Spark jobs from the notebook using synchronous and asynchronous methods to retrieve the output.

OCI DataFlow with Interactive OCI Data Science have also introduced SparkMagic commands adding it's own flavours & upgrades. SparkMagic allows for interactive communication with Spark using Livy. Using the `%%spark` magic directive within a JupyterLab code cell.

The purpose of this document is to walk you through the setup required to access the OCI Data Flow Sessions through the Data Science Notebook Session. These Sessions allow you to run interactive Spark workloads on a long lasting Data Flow cluster through an Apache Livy integration. 

Also, Once OCI Data Flow Spark Session is created, will go through some Sample codes for performing Spark Operations on OCI Object Storage &  Autonomous DataWarehouse.

Features & Benefit:

◉ Use Interactive Jupyter Notebook with OCI Data Flow. 
◉ Data Flow Sessions supports auto-scaling Data Flow cluster capabilities. User can enable auto-scaling while creating Spark - Livy session as well as once the session is created from the Notebook.
◉ Data Flow Sessions supports the use of conda environments as customizable Spark runtime environments. 
◉ Import open source libraries & start using it after building Conda environments. 
◉ Spark Delta Lake in OCI Data Flow & perform ACID transactions. 

Use Interactive OCI Data Science Notebook with OCI Data Flow:


To use the OCI Data Science Notebook with OCI Data Flow, follow below steps:

◉ Create required buckets 
    ◉ Create a bucket named dataflow-logs in your tenancy. 
    ◉ Create a bucket named dataflow-warehouse in your tenancy. 
◉ Create a dynamic group in a specific compartment:

ALL {resource.type='dataflowrun', resource.compartment.id='<compartment_id>'}

ALL {resource.type='datasciencenotebooksession', resource.compartment.id='<compartment_id>'}

Any {resource.type = 'datacatalogmetastore'}

◉ Create a policy to manage OCI resources from OCI data flow, Data Science:

ALLOW DYNAMIC-GROUP <df-dynamic-group> TO MANAGE objects IN TENANCY WHERE ANY
{target.bucket.name='<bucket_name>',
target.bucket.name='dataflow-logs,
target.bucket.name='dataflow-warehouse'
}

ALLOW DYNAMIC-GROUP '<ds-dynamic-group>' TO MANAGE dataflow-family
in compartment '<your-compartment-name>'

ALLOW DYNAMIC-GROUP '<df-dynamic-group>' TO MANAGE data-catalog-metastores IN TENANCY

ALLOW DYNAMIC-GROUP '<dcat-hive-group>' TO READ buckets IN TENANCY

ALLOW DYNAMIC-GROUP '<dcat-hive-group>' TO MANAGE object-family IN TENANCY WHERE ANY
{ target.bucket.name = '<bucket_name>',
target.bucket.name = '<managed-table-location-bucket>',
target.bucket.name = '<external-table-location-bucket>'
}

ALLOW DYNAMIC-GROUP '<ds-dynamic-group>' TO MANAGE objects IN TENANCY
WHERE ALL {target.bucket.name='ds-conda-env'}

ALLOW DYNAMIC-GROUP '<df-dynamic-group>' TO MANAGE objects IN TENANCY
WHERE ALL {target.bucket.name='ds-conda-env'}

◉ Create OCI Data Science Project & Session.

Autonomous DataWarehouse & Object Storage, Oracle Database, Oracle Database Career, Oracle Database Skills, Oracle Database Jobs, Database Tutorial and Materials

◉ Open New OCI Data Science Session. From File option,  choose New Launcher and click on Terminal.

Autonomous DataWarehouse & Object Storage, Oracle Database, Oracle Database Career, Oracle Database Skills, Oracle Database Jobs, Database Tutorial and Materials

◉ Install and activate the pyspark32_p38_cpu_v1  conda environment from your terminal:

odsc conda install -s pyspark32_p38_cpu_v1
source activate /home/datascience/conda/pyspark32_p38_cpu_v1

◉ Once Conda is activated, Goto New Launcher Tab & click on Settings. Fill required information about object storage where Conda package will be uploaded & save it.

Autonomous DataWarehouse & Object Storage, Oracle Database, Oracle Database Career, Oracle Database Skills, Oracle Database Jobs, Database Tutorial and Materials

◉ Now, Publish Conda environment:

odsc conda publish -s pyspark3_2anddataflowv1_0

Note: Publishing will take some time. Once it is completed, you can observe Conda package is uploaded on the Object Storage bucket.

◉ Open Notebook using "PySpark and DataFlow" as kernel from new Launcher.
◉ Execute below commands to setup and create Data Flow Spark session using Livy Service:

1. Setup Authentication using ADS

import ads
ads.set_auth("resource_principal") # Supported values: resource_principal, api_key

2. Load Extension

%load_ext dataflow.magics

3. Create OCI DataFlow Spark Session using Livy:

#Create OCI Dataflow Session using LIVY service through OCI Data SCience Notebook.
import json
command = {
    "compartmentId": "ocid1.compartment.oc1..xxxxxxxxxxxxxx",
    "displayName": "Demo_DataFlow_Spark_v1",
    "sparkVersion": "3.2.1",
    "driverShape": "VM.Standard.E3.Flex",
    "executorShape": "VM.Standard.E3.Flex",
    "driverShapeConfig":{"ocpus":1,"memoryInGBs":16},
    "executorShapeConfig":{"ocpus":1,"memoryInGBs":16},
    "numExecutors": 1,
    "logsBucketUri": "<oci://bucket@namespace/>",
    "archiveUri": "<oci://bucket@namespace/archive.zip>"
    "configuration":{"spark.archives":"<oci://bucket@namespace/>#conda",
                     "spark.oracle.datasource.enabled":"true"}
}

command = f'\'{json.dumps(command)}\''
print("command",command)

#"configuration":{
#    "spark.dynamicAllocation.enabled":"true",
#    "spark.dynamicAllocation.shuffleTracking.enabled":"true",
#    "spark.dynamicAllocation.minExecutors":"1",
#    "spark.dynamicAllocation.maxExecutors":"4",
#    "spark.dynamicAllocation.executorIdleTimeout":"60",
#    "spark.dynamicAllocation.schedulerBacklogTimeout":"60",
#    "spark.dataflow.dynamicAllocation.quotaPolicy":"min" }}'

%create_session -l python -c $command

Autonomous DataWarehouse & Object Storage, Oracle Database, Oracle Database Career, Oracle Database Skills, Oracle Database Jobs, Database Tutorial and Materials

OCI Data Flow Spark Session is created. Moving ahead will go through some Sample codes for performing Spark Operations on:


1. OCI Object Storage
2. OCI Autonomous DataWarehouse

◉ Now, You can Import dependent libraries in Session:

%%spark
#Import required libraries.

import json
import os
import sys
import datetime
import oci
import pyspark.sql 
from pyspark.sql.functions import countDistinct

from delta.tables import *

◉ Perform Spark Read operation on Object Storage.  

Read Object Storage file using spark.read from Livy Session:

<strong>%%spark -o df_Bronze_Insurance_Data</strong>

#Read Claim Insurance files from OCI Object Storage in Spark Dataframe.

df_Bronze_Insurance_Data = spark.read.format("csv").option("header", "true") \
.option("multiLine", "true").load("oci://test-demo@OSNamespace/insur_claim/claim.csv*")

print("df_RawZone_Data",df_Bronze_Insurance_Data)
df_Bronze_Insurance_Data.show(5)

Autonomous DataWarehouse & Object Storage, Oracle Database, Oracle Database Career, Oracle Database Skills, Oracle Database Jobs, Database Tutorial and Materials

◉ Perform Spark Write operation on Object Storage.  

%%spark
df_Bronze_Insurance_Data.write.format("json").option("mode","overwrite").save("oci://test-demo@OSNamespace/insur_claim/claim_curated")

◉ Perform Read & Write Operation on Autonomous DataWarehouse:

    ◉ Load Data into ADW using Secret Vault for Wallet: 

Copy below code as it is. 

Reference: https://github.com/oracle-samples/oracle-dataflow-samples/tree/main/python/loadadw

%%spark

def get_authenticated_client(token_path, client, file_location=None, profile_name=None):
    """
    Get an an authenticated OCI client.
    Example: get_authenticated_client(token_path, oci.object_storage.ObjectStorageClient)
    """
    import oci

    if not in_dataflow():
        # We are running locally, use our API Key.
        if file_location is None:
            file_location = oci.config.DEFAULT_LOCATION
        if profile_name is None:
            profile_name = oci.config.DEFAULT_PROFILE
        config = oci.config.from_file(file_location=file_location, profile_name=profile_name)
        authenticated_client = client(config)
    else:
        # We are running in Data Flow, use our Delegation Token.
        with open(token_path) as fd:
            delegation_token = fd.read()
        signer = oci.auth.signers.InstancePrincipalsDelegationTokenSigner(
            delegation_token=delegation_token
        )
        authenticated_client = client(config={}, signer=signer)
    return authenticated_client

def get_password_from_secrets(token_path, password_ocid):
    """
    Get a password from the OCI Secrets Service.
    """
    import base64
    import oci

    secrets_client = get_authenticated_client(token_path, oci.secrets.SecretsClient)
    response = secrets_client.get_secret_bundle(password_ocid)
    base64_secret_content = response.data.secret_bundle_content.content
    base64_secret_bytes = base64_secret_content.encode("ascii")
    base64_message_bytes = base64.b64decode(base64_secret_bytes)
    secret_content = base64_message_bytes.decode("ascii")
    return secret_content

def get_delegation_token_path(spark):
    """
    Get the delegation token path when we're running in Data Flow.
    """
    if not in_dataflow():
        return None
    token_key = "spark.hadoop.fs.oci.client.auth.delegationTokenPath"
    token_path = spark.sparkContext.getConf().get(token_key)
    if not token_path:
        raise Exception(f"{token_key} is not set")
    return token_path    

def get_temporary_directory():
    if in_dataflow():
        return "/opt/spark/work-dir/"
    else:
        import tempfile
        return tempfile.gettempdir()

def in_dataflow():
    """
    Determine if we are running in OCI Data Flow by checking the environment.
    """
    if os.environ.get("HOME") == "/home/dataflow":
        return True
    return False

def download_wallet(spark, wallet_path):
    """
    Download an ADW/ATP wallet file and prepare it for use in a Data Flow
    application.
    """
    import oci
    import zipfile

    # Get an object store client.
    token_path = get_delegation_token_path(spark)
    object_store_client = get_authenticated_client(
        token_path, oci.object_storage.ObjectStorageClient
    )

    # Download the wallet file.
    from urllib.parse import urlparse
    parsed = urlparse(wallet_path)
    bucket_name, namespace = parsed.netloc.split("@")
    file_name = parsed.path[1:]
    response = object_store_client.get_object(namespace, bucket_name, file_name)
    temporary_directory = get_temporary_directory()
    zip_file_path = os.path.join(temporary_directory, "wallet.zip")
    with open(zip_file_path, "wb") as fd:
        for chunk in response.data.raw.stream(1024 * 1024, decode_content=False):
            fd.write(chunk)

    # Extract everything locally.
    with zipfile.ZipFile(zip_file_path, "r") as zip_ref:
        zip_ref.extractall(temporary_directory)

    # Distribute all wallet files.
    contents = "cwallet.sso ewallet.p12 keystore.jks ojdbc.properties sqlnet.ora tnsnames.ora truststore.jks".split()
    spark_context = spark.sparkContext
    for file in contents:
        spark_context.addFile(os.path.join(temporary_directory, file))

    return temporary_directory

◉ Set below Parameters related to ADW Instance & Wallet.

%%spark
PASSWORD_SECRET_OCID = "ocid1.vaultsecret.oc1.phx.xxxxxxx"
TARGET_TABLE = "ADMIN.TB_NAME"
TNSNAME = "demolakehouseadw_medium"
USER = "admin"
WALLET_PATH = "oci://bucketname@osnamespace/Wallet_DemoLakeHouseADW.zip"

# Download and distribute our wallet file.
wallet_path = download_wallet(spark, WALLET_PATH)
adw_url = "jdbc:oracle:thin:@{}?TNS_ADMIN={}".format(TNSNAME, wallet_path)

◉ Now, Get password using the secret service.

%%spark
# Get our password using the secret service.
print("Getting wallet password")
token_path = get_delegation_token_path(spark)
password = get_password_from_secrets(token_path, PASSWORD_SECRET_OCID)
print("Done getting wallet password")

# Save the results to the database.
print("Saving processed data to " + adw_url)
properties = {
    "driver": "oracle.jdbc.driver.OracleDriver",
    "oracle.net.tns_admin": TNSNAME,
    "password": password,
    "user": USER
}

◉ Read Sample Table from ADW. 

%%spark
SOURCE_TABLE = "ADMIN.RETAILPOS"
df_RetailPOS_15min = spark.read.jdbc(url=adw_url, table=SOURCE_TABLE, properties=properties)

◉ Load above Dataframe into ADW. 

%%spark

#Load into ADW:

TARGET_TABLE = "ADMIN.RETAILPOS_15MINUTES"
print("TARGET_TABLE : ",TARGET_TABLE)

# Write to ADW.
print("Write to ADW : ")
df_RetailPOS_15min.write.jdbc(url=adw_url, table=TARGET_TABLE, mode="Append", properties=properties)
print("Writing done to ADW : ")


Source: oracle.com