Sybase ASE to PostgreSQL Migration

SQLines provides tools and services to help you transfer data, convert database schema (DDL), views, stored procedures, functions, triggers, queries and SQL scripts from Sybase Adaptive Server Enterprise (Sybase ASE) to PostgreSQL.

We also help convert embedded SQL statements in C/C++ (ODBC, ESQL/C, CTLIB), C#, Java, PowerBuilder, VB/VB.NET, ASP/ASP.NET and Perl/PHP applications.

  • Sybase Adaptive Server Enterprise 16, 15, 12.x and 11.x
  • PostgreSQL 9.x and 8.x

See also Sybase SQL Anywhere to PostgreSQL Migration.

Sybase ASE to PostgreSQL Migration Tools

SQLines SQL Converter Tool

SQLines SQL Converter tool allows you to convert database schema (DDL), queries and DML statements, views, stored procedures, functions and triggers from Sybase ASE to PostgreSQL.

SQLines tool converts SQL scripts and standalone SQL statements. To migrate data and database schema from a Sybase database use SQLines Data tool.

SQLines tool is available in Online and Desktop editions:

Online Edition Desktop Edition
Conversion Features
DDL - Tables and Indexes
Queries, Views and DML Statements
Stored Procedures, Functions and Triggers
Interfaces
GUI
Command Line n/a
API n/a
Platforms
Windows 32-bit Hosted
Linux x86 32-bit Hosted
Licensing and Support
Technical Support
Price Purchase

Try SQLines Online or download a Trial Version.

Migration Reference

Technical information on migration from Sybase ASE to PostgreSQL:

Last Update: Sybase Adaptive Server Enterprise 15.0 and PostgreSQL 9.4

SQL Language Elements

Converting SQL language elements:

Sybase ASE PostgreSQL
1 string1 + string2 String concatenation string1 || string2

Data Types

Converting data types:

Sybase ASE PostgreSQL
1 BIGDATETIME Date and time with fraction TIMESTAMP
2 BIGINT 64-bit integer BIGINT
3 BIGTIME Time (Hour, minute, second and fraction) TIME
4 BINARY(n) Fixed-length binary data, 1 ⇐ npagesize BYTEA
5 BIT 0 or 1; NULL is not allowed BOOLEAN
6 CHAR(n), CHARACTER(n) Fixed-length string CHAR(n), CHARACTER(n)
7 DATE Date (year, month and day) DATE
8 DATETIME Date and time with fraction TIMESTAMP
9 DECIMAL(p,s), DEC(p,s) Fixed-point number DECIMAL(p,s), DEC(p,s)
10 DOUBLE PRECISION Double-precision floating-point number DOUBLE PRECISION
11 FLOAT(p) Floating-point number DOUBLE PRECISION
12 IMAGE Variable-length binary data, ⇐ 2G BYTEA
13 INT, INTEGER 32-bit integer INT, INTEGER
14 MONEY 64-bit currency amount MONEY
15 NCHAR(n) Fixed-length national character string CHAR(n)
16 NUMERIC(p,s) Fixed-point number NUMERIC(p,s)
17 NVARCHAR(n) Variable-length national character string VARCHAR(n)
18 REAL Single-precision floating-point number REAL
19 SMALLDATETIME Date and time TIMESTAMP(0)
20 SMALLINT 16-bit integer SMALLINT
21 SMALLMONEY 32-bit currency amount MONEY
22 TEXT Variable-length character data, ⇐ 2G TEXT
23 TIME Time (Hour, minute, second and fraction) TIME
24 TINYINT 8-bit unsigned integer, 0 to 255 SMALLINT
25 UNICHAR(n) Fixed-length Unicode string CHAR(n)
26 UNITEXT Variable-length Unicode data, ⇐ 1G TEXT
27 UNIVARCHAR(n) Variable-length Unicode string VARCHAR(n)
28 UNSIGNED BIGINT 64-bit unsigned integer NUMERIC(20)
29 UNSIGNED INT 32-bit unsigned integer NUMERIC(10)
30 UNSIGNED SMALLINT 16-bit unsigned integer NUMERIC(5)
31 VARBINARY(n) Variable-length binary string BYTEA
32 VARCHAR(n) Variable-length string VARCHAR(n)

Built-in SQL Functions

Converting built-in SQL functions from Sybase ASE to PostgreSQL:

Sybase ASE PostgreSQL
1 CHAR_LENGTH(string) Number of characters in string CHAR_LENGTH(string)
2 CHARINDEX(substring, string) Get substring position in string POSITION(substring IN string)
3 CONVERT(CHAR | VARCHAR, exp) Convert to string TO_CHAR(exp)
4 DATEADD(dd, int, datetime) Add days to datetime datetime + INTERVAL 'int DAY'
DATEADD(dd, exp, datetime) datetime + exp * INTERVAL '1 DAY'
5 GETDATE() Get the current date and time NOW()
6 SUBSTRING(string, start, length) Return substring SUBSTRING(string, start, length)

CREATE PROCEDURE Statement

Converting stored procedures from Sybase ASE to PostgreSQL:

Sybase ASE PostgreSQL
1 CREATE PROCEDURE name CREATE OR REPLACE FUNCTION name
2 If RETURN is not specified RETURNS VOID is added
3 AS Changed AS $$
4 Declarations inside BEGIN block DECLARE block is between AS and BEGIN clauses
5 END End of procedure block END; $$ LANGUAGE plpgsql;

Transact-SQL Statements

Converting procedural Transact-SQL statements used in stored procedures, functions and triggers from Sybase ASE to PostgreSQL:

Variable declaration and assignment:

Sybase ASE PostgreSQL
1 DECLARE @var [AS] datatype(len) [= default] Variable declaration var datatype(len) [:= default];

Flow-of-control statements:

Sybase ASE PostgreSQL
1 IF condition BEGIN … END IF statement IF condition THEN … END IF;
2 WHILE condition BEGIN … END WHILE loop WHILE condition LOOP … END LOOP;

Cursors operations and attributes:

Sybase ASE PostgreSQL
1 CLOSE cur
DEALLOCATE [CURSOR] cur
Close a cursor CLOSE cur;
2 @@SQLSTATUS = 0 Fetch was successful FOUND

System Procedures

Converting system stored procedures from Sybase ASE to PostgreSQL:

Sybase ASE PostgreSQL
1 sp_addtype name, "basetype(len)",
"not null"
Create a user-defined type CREATE DOMAIN name AS basetype(len)
NOT NULL
2 sp_bindrule name, "table.column" Assign a rule to a table column ALTER TABLE table ADD CHECK rule_condition

SQL Statements

Converting SQL statements from Sybase ASE to PostgreSQL:

Sybase ASE PostgreSQL
1 CREATE RULE name AS condition Create a domain of acceptable values Converted to a CHECK constraint