Skip to content

Commit ec1ecc1

Browse files
Merge pull request #920 from oracle-devrel/synuora-data-development-CICD
Updated sqlcl-liquibase readme. Added additional details on usage and how-to examples
2 parents 1a86de1 + e7aaafb commit ec1ecc1

File tree

1 file changed

+72
-2
lines changed
  • data-platform/data-development/devops-database/continuous-integration/sqlcl-liquibase

1 file changed

+72
-2
lines changed

data-platform/data-development/devops-database/continuous-integration/sqlcl-liquibase/README.md

Lines changed: 72 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
11
# SQLcl and Liquibase
2-
Reviewed: "05.01.2024"
2+
Reviewed: "27.03.2024"
33

44
[Oracle SQLcl (SQL Developer Command Line)](https://docs.oracle.com/en/database/oracle/sql-developer-command-line/index.html) is a Java-based command line interface for Oracle Database. Using SQLcl, you can execute SQL and PL/SQL statements in interactive or batch mode
55

66
[Liquibase](https://www.liquibase.org/) is an open-source database-independent library for tracking, managing and applying database schema changes. This feature, is included in the standalone SQLcl offering, which is different that the SQL Developer installation.
7+
8+
You may use the open-source or Pro version of Liquibase to track and manage your database changes. It has support for additonal technologies through the use of JDBC driver connections but is limited to standard database metadata. i.e. Data Dictionary. Liquibase also reads and writes all changesets to a single changelog.
9+
10+
The Liquibase feature is SQLcl extends the base utlity with additional metadata changesets, such as APEX and ORDS, and adds and automates the file splitting capabilities, generating changelog and changsets written using the DBMS_METADATA SXML data format.
11+
12+
You can add the functionality to read these specialized changelogs to the Liquibase client by follwing the instrunctions in the [Requirements for Using Liquibase](https://docs.oracle.com/en/database/oracle/sql-developer-command-line/23.4/sqcug/using-liquibase.html#GUID-673321E9-1C06-4B9A-A373-52C2CB5AB7B0) section of the documentation.
13+
714

815
## The Liquibase Feature in SQLcl
9-
The Liquibase feature in SQLcl enables you to execute commands to generate a changelog for a single object or for a full schema (changeset and changelogs). You can process these objects manually using SQLcl or through any of the traditional Liquibase interfaces.
16+
SQLcl Liquibase with Oracle Database provides extended functionality to the Liquibase experience compared to the open source Liquibase client. The Liquibase feature in SQLcl enables you to execute commands to generate a changelog for a single object or for a full schema in specialized changelogs and changesets.
17+
1018

1119
# Table of Contents
1220

@@ -24,6 +32,7 @@ The Liquibase feature in SQLcl enables you to execute commands to generate a cha
2432
- [Liquibase Community](https://www.liquibase.org/)
2533
- [Liquibase Documentation](https://docs.liquibase.com/home.html "What is Liquibase?")
2634
- [Liquibase Documentation](https://docs.liquibase.com/start/release-notes/home.html "Release Notes")
35+
- [Best Practices recommended by Liquibase](https://docs.liquibase.com/concepts/bestpractices.html "Maximize the effectiveness and efficiency of the Liquibase workflow")
2736

2837
## Scripts
2938
- [APEX Lifecycle Management Technical Paper Scripts](https://apex.oracle.com/go/lifecycle-technical-paper-files "Zip download")
@@ -32,6 +41,67 @@ The Liquibase feature in SQLcl enables you to execute commands to generate a cha
3241
- [Oracle LiveLabs - Capture Oracle Database Changes for CI/CD](https://apexapps.oracle.com/pls/apex/r/dbpm/livelabs/view-workshop?wid=3000)
3342
- [Oracle LiveLabs - Oracle Database Operator for Kubernetes + DevOps](https://apexapps.oracle.com/pls/apex/r/dbpm/livelabs/view-workshop?wid=3393)
3443

44+
## Using SQLcl to Capture and Apply Database Changes
45+
46+
### Setting the format of the DDL generated
47+
Using the SET command to set DDL variables, will modify the behaviour of the DDL transfrom option on DBMS_METADATA.
48+
49+
```
50+
SET DDL [[ PRETTY | SQLTERMINATOR | CONSTRAINTS | REF_CONSTRAINTS | CONSTRAINTS_AS_ALTER|OID | SIZE_BYTE_KEYWORD | PARTITIONING | SEGMENT_ATTRIBUTES | STORAGE | TABLESPACE | SPECIFICATION | BODY | FORCE | INSERT | |INHERIT | RESET] {on|off} ] | OFF ]
51+
```
52+
53+
For example to exclude table properties such as partitions, compression or tablespace details:
54+
55+
```
56+
set ddl partitioning off
57+
set ddl segment_attributes off
58+
set ddl tablespace off
59+
```
60+
61+
### Generating Change Log - Database Definitions
62+
Connect to the source database with sqlcl and use the liquibase feature to generate object, schema, APEX and ORDS change logs. The sqlcl generates change logs in the current directory only. Liquibase wirtes to a single file and the location can be specified.
63+
64+
The examples below will be shown using both full syntax and then again with short commands.
65+
66+
```
67+
-- After connection was made to the source system and changing to the output directory.
68+
-- Generate Liquibase Changelog
69+
liquibase generate-changelog -changelog-file lb-changelog.xml
70+
71+
lb gec -chf lb-changelog.xml
72+
73+
-- Generate Schema (change log file will be controller.xml)
74+
liquibase generate-schema
75+
76+
lb ges
77+
78+
-- Generate Schema split the output with SQL format
79+
liquibase generate-db-object -sql
80+
81+
lb geo -sp -sq
82+
83+
-- Generate Schema Object
84+
liquibase generate-schema
85+
86+
lb ges
87+
```
88+
89+
### Apply Change Log - Database Definitions
90+
Connect to the target database with sqlcl to apply object, schema, APEX and ORDS change logs.
91+
92+
```
93+
-- After connection was made to the target system and changing to the output directory.
94+
liquibase update -changelog-file lb-changelog.xml
95+
96+
lb up -chf lb-changelog.xml
97+
98+
-- Using the controller.xml
99+
liquibase update
100+
101+
lb -up
102+
```
103+
104+
Use the directory structure to manages schema versions by following the [Best Practices recommended by Liquibase](https://docs.liquibase.com/concepts/bestpractices.html)
35105

36106
# License
37107

0 commit comments

Comments
 (0)