Manage and Store Files in a Cloud
Code Repository with Autonomous Database
Autonomous Database provides routines to manage and store
files in Cloud Code (Git) Repositories. The supported Cloud Code Repositories are:
GitHub, AWS CodeCommit, and Azure Repos.
Initialize a Cloud Code Repository The DBMS_CLOUD_REPO initialization routines initialize a Cloud Code Repository. After you obtain a Cloud Code Repository handle, you use the handle to access the Cloud Code Repository.
Create and Manage a Cloud Code Repository The DBMS_CLOUD_REPO management routines allow you to manage a Cloud Code Repository by creating, listing, updating, or deleting a repository.
Create and Manage Branches in a Cloud Code Repository The DBMS_CLOUD_REPO management routines allow you to manage Cloud Code Repository branches by creating, listing, merging, or deleting branches in a repository.
Export Schema Objects to the Cloud Code Repository Branch The DBMS_CLOUD_REPO management routine allows you to export metadata of the objects in a schema to the Cloud Code Repository branch. You can filter your list based on the object names or object types.
About Cloud Code Repositories with
Autonomous Database 🔗
The DBMS_CLOUD_REPO
package provides a single interface for accessing a Cloud Code Repository from Autonomous Database.
The supported Cloud Code Repositories provide the following features:
Git Version Control System: Git is software for tracking changes in any set of
files, usually used for coordinating work among programmers collaboratively
developing source code during software development. Its goals include speed,
data integrity, and support for distributed, non-linear workflows.
Git Repository: A Git repository is a virtual storage of your
project. It allows you to save versions of your code, which you can access
when needed.
The DBMS_CLOUD_REPO APIs
use a repository handle (REPO object). The repository handle is an
opaque JSON object that represents a Cloud Code Repository of
a specific cloud provider. A REPO object can be passed to different
DBMS_CLOUD_REPO APIs. This opaque
object ensures that DBMS_CLOUD_REPO
procedures and functions are multicloud compatible; you do not have to change your
code when you migrate from one Cloud Code Repository provider to another Cloud Code Repository.
Autonomous Database provides
the following to help you work with Cloud Code Repositories:
Repository initialization operations to allow you to
initialize a repository.
SQL install operations that let you export database object
metadata DDL to a repository and install SQL statements into the
database from a Cloud Code Repository.
The DBMS_CLOUD_REPO
initialization routines initialize a Cloud Code Repository. After you
obtain a Cloud Code Repository handle, you use the handle to access
the Cloud Code Repository.
To initialize a Cloud Code Repository:
Create a credential to access the Cloud Code Repository.
Depending on the repository, GitHub, Azure Repos, or AWS CodeCommit, call DBMS_CLOUD_REPO.INIT_REPO with
the parameters for the particular repository to obtain a repository
handle.
The following examples provide samples for each supported Cloud Code Repository.
GitHub Initialization:
DEFINE repo_name='test_repo';
DEFINE cred_name='GITHUB_CRED';
VAR repo clob
BEGIN
:repo := DBMS_CLOUD_REPO.INIT_REPO(
params => JSON_OBJECT('provider' value 'github',
'repo_name' value '&repo_name',
'credential_name' value '&cred_name',
'owner' value '<myuser>')
);
END;
/
Azure Repos Initialization:
DEFINE repo_name='test_repo';
DEFINE cred_name='AZURE_REPO_CRED';
VAR repo clob
BEGIN
:repo := DBMS_CLOUD_REPO.INIT_REPO(
params => JSON_OBJECT('provider' value 'azure',
'repo_name' value '&repo_name',
'credential_name' value '&cred_name',
'organization' value '<myorg>',
'project' value '<myproject>')
);
END;
/
AWS CodeCommit Initialization:
DEFINE repo_name='test_repo';
DEFINE cred_name='AWS_REPO_CRED';
VAR repo clob
BEGIN
:repo := DBMS_CLOUD_REPO.INIT_REPO(
params => JSON_OBJECT('provider' value 'aws',
'repo_name' value '&repo_name',
'credential_name' value '&cred_name',
'region' value 'us-east-1')
);
END;
/
VAR repo clob
BEGIN
DBMS_CLOUD_REPO.CREATE_REPOSITORY(
repo => :repo,
description => 'test repo'
);
END;
/
To update a repository:
VAR repo clob
DEFINE repo_name='test_repo';
BEGIN
DBMS_CLOUD_REPO.UPDATE_REPOSITORY(
repo => :repo,
new_name => '&repo_name' || '_new'
);
END;
/
To list repositories:
col id format a30
col name format a10
col description format a15
select id, name, bytes, private, description from
DBMS_CLOUD_REPO.LIST_REPOSITORIES(:repo);
To delete a repository:
VAR repo clob
BEGIN
DBMS_CLOUD_REPO.DELETE_REPOSITORY(
repo => :repo
);
END;
/
Create and Manage Branches in a Cloud Code Repository 🔗
The DBMS_CLOUD_REPO management routines allow you to manage Cloud Code Repository branches by creating, listing, merging, or deleting branches in a repository.
To perform Cloud Code Repository branch management operations you must first:
Export Schema Objects to the Cloud Code Repository Branch 🔗
The DBMS_CLOUD_REPO management routine allows you to export metadata of the objects in a schema to the Cloud Code Repository branch. You can filter your list based on the object names or object types.
This example exports the metadata of the USER1 schema into the l_repo repository. The export includes the metadata of the tables EMPLOYEE_SALARY and EMPLOYEE_ADDRESS, and any table name that contains OFFICE. It also exports the EMPLOYEE_RECORD_SEQ sequence and excludes the views in the schema.