Using Liquibase with Sybase Enterprise
SAP ASE (formerly Sybase Enterprise) is a relational model database server. See SAP Adaptive Server Enterprise Documentation for more information.
Supported versions
- 16.0.04.X
- 16.0.03.X
- 16.0.02.X
Verification level
Unverified: Liquibase does not have enough information to know how well this extension or integration works.
Note: A database's verification level indicates how well it works with different features in Liquibase and across different products, such as Liquibase Community and Liquibase Pro. For more information, see Liquibase Database Tutorials.
Prerequisites
- Install Liquibase.
- Create a Liquibase project folder to store all Liquibase files. You can do this manually or with the init project command.
- Create a new Liquibase properties file or use the
liquibase.properties
file included in the installation package. For more information, see Specifying Properties in a Connection Profile.
Install drivers
To use Liquibase and SAP ASE, you need the JDBC driver JAR file.
For more information, see Adding and Updating Liquibase Drivers.
If you use Maven, you also need to download the driver JAR file and configure your Maven pom.xml
file to use the local copy of the driver. For example:
<dependency>
<groupId>net.sourceforge.jtds</groupId>
<artifactId>jtds</artifactId>
<version>1.3.1</version>
</dependency>
Test your connection
- Ensure your SAP ASE database is configured. See SAP ASE Installation for more information.
- Select the ASE 12.0+ version.
- Set the
select into
database option.
- Specify the database URL in the Liquibase properties file. Liquibase does not parse the URL. You can either specify the full database connection string or specify the URL using your database's standard JDBC format:
url: jdbc:jtds:sybase://localhost:5432/MYDATABASE
Tip: To apply a Liquibase Pro key to your project, add the following property to the Liquibase properties file: liquibaseProLicenseKey: <paste code here>
- Create a text file called changelog (
.xml
,.sql
,.json
, or.yaml
) in your project directory and add a changeset. - Navigate to your project folder in the CLI and run the Liquibase status command to see whether the connection is successful:
- Inspect the SQL with the update-sql command. Then make changes to your database with the update command.
- From a database UI tool, ensure that your database contains the
test_table
you added along with the DATABASECHANGELOG table and DATABASECHANGELOGLOCK table.
<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
xmlns:pro="http://www.liquibase.org/xml/ns/pro"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-latest.xsd
http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd
http://www.liquibase.org/xml/ns/pro http://www.liquibase.org/xml/ns/pro/liquibase-pro-latest.xsd">
<changeSet id="1" author="Liquibase">
<createTable tableName="test_table">
<column name="test_id" type="int">
<constraints primaryKey="true"/>
</column>
<column name="test_column" type="varchar"/>
</createTable>
</changeSet>
</databaseChangeLog>
-- liquibase formatted sql
-- changeset liquibase:1
CREATE TABLE test_table (test_id INT, test_column VARCHAR(256), PRIMARY KEY (test_id))
Tip: Formatted SQL changelogs generated from Liquibase versions before 4.2 might cause issues because of the lack of space after a double dash ( -- ). To fix this, add a space after the double dash. For example: -- liquibase formatted sql
instead of --liquibase formatted sql
and -- changeset myname:create-table
instead of --changeset myname:create-table
databaseChangeLog:
- changeSet:
id: 1
author: Liquibase
changes:
- createTable:
columns:
- column:
name: test_column
type: INT
constraints:
primaryKey: true
nullable: false
tableName: test_table
{
"databaseChangeLog": [
{
"changeSet": {
"id": "1",
"author": "Liquibase",
"changes": [
{
"createTable": {
"columns": [
{
"column":
{
"name": "test_column",
"type": "INT",
"constraints":
{
"primaryKey": true,
"nullable": false
}
}
}]
,
"tableName": "test_table"
}
}]
}
}]
}
liquibase --username=test --password=test --changelog-file=<changelog.xml> status
Note: You can pass arguments in the CLI or keep them in the Liquibase properties file.
liquibase --changelog-file=<changelog.xml> update-sql
liquibase --changelog-file=<changelog.xml> update
Note: Rollbacks do not work on failures as Sybase does not support transactions for DDL. Additionally, foreign keys cannot be dropped, which can break the rollback
or drop-all
commands.