Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 11.0.1 (Français) » SQL Anywhere Server - SQL Reference » Using SQL » SQL functions » SQL functions (A-D)


DECOMPRESS function [String]

Decompresses the string and returns a LONG BINARY value.

DECOMPRESS( string-expression [, compression-algorithm-alias] )
  • string-expression   The string to decompress. Binary values can also be passed to this function. This parameter is case sensitive, even in case-insensitive databases.

  • compression-algorithm-alias   Alias (string) for the algorithm to use for decompression. The supported values are zip and gzip (both are based on the same algorithm, but use different headers and trailers).

    Zip is a widely supported compression algorithm. Gzip is compatible with the gzip utility on Unix, whereas the zip algorithm is not.

    If no algorithm is specified, the function attempts to detect which algorithm was used to compress the string. If the incorrect algorithm is specified, or the correct algorithm cannot be detected, the string is not decompressed.

    For more information about compression, see COMPRESS function [String].




This function can be used to decompress a value that was compressed using the COMPRESS function.

You do not need to use the DECOMPRESS function on values that are stored in a compressed column. Compression and decompression of values in a compressed column are handled automatically by the database server. See Choosing whether to compress columns.

See also
Standards and compatibility
  • SQL/2003   Vendor extension.


The following example uses the DECOMPRESS function to decompress values from the Attachment column of a fictitious table, TableA:

SELECT DECOMPRESS ( Attachment, 'gzip' )
FROM TableA;

Since DECOMPRESS returns binary values, if the original values were of a character type, such as LONG VARCHAR, a CAST can be applied to return human-readable values:

SELECT CAST ( DECOMPRESS ( Attachment, 'gzip' )