You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: data-platform/data-development/devops-database/continuous-integration/sqlcl-liquibase/README.md
+72-2Lines changed: 72 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,12 +1,20 @@
1
1
# SQLcl and Liquibase
2
-
Reviewed: "05.01.2024"
2
+
Reviewed: "27.03.2024"
3
3
4
4
[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
5
5
6
6
[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
+
7
14
8
15
## 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
+
10
18
11
19
# Table of Contents
12
20
@@ -24,6 +32,7 @@ The Liquibase feature in SQLcl enables you to execute commands to generate a cha
-[Best Practices recommended by Liquibase](https://docs.liquibase.com/concepts/bestpractices.html"Maximize the effectiveness and efficiency of the Liquibase workflow")
27
36
28
37
## Scripts
29
38
-[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
32
41
-[Oracle LiveLabs - Capture Oracle Database Changes for CI/CD](https://apexapps.oracle.com/pls/apex/r/dbpm/livelabs/view-workshop?wid=3000)
33
42
-[Oracle LiveLabs - Oracle Database Operator for Kubernetes + DevOps](https://apexapps.oracle.com/pls/apex/r/dbpm/livelabs/view-workshop?wid=3393)
34
43
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.
-- 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)
0 commit comments