---
title: "GZIP"
description: "The GZIP SQL function compresses a BLOB using the GZIP-algorithm."
language: en
source_language: en
translation_state: complete
canonical: https://documentation.invantive.eu/en/docs/invantive-universalsql/grammar/sql-functions/gzip
original: https://documentation.invantive.eu/en/docs/invantive-universalsql/grammar/sql-functions/gzip
updated: 2026-08-09T00:00:00Z
license: https://documentation.invantive.eu/en/
---

## Syntax
```mermaid
%%{init: {
  'theme': 'base',
  'flowchart': { 'padding': '7', 'nodeSpacing': '20', 'rankSpacing': '20' },
  'themeVariables': {
    'fontSize': '11px',
    'fontFamily': 'Arial'
  }
}}%%
flowchart LR
    Start((START)) --> GZIP[GZIP]:::quoted
    GZIP --> End((END))
```

## Purpose
The `GZIP` SQL function compresses a BLOB using the GZIP-algorithm.

See also [[UNGZIP]].

Parameters:
- Input (`blob`): The BLOB to compress. BASE64 decoding is applied automatically when a `varchar2` text is provided.

Returns: a GZIP-compressed version of the input as `blob`.

## Examples
The following example retrieves compressed and decompressed representation of the nine ASCII characters `invantive`:
```sql
select base64_encode(ungzip(gzip('aW52YW50aXZl')))

-------------------
aW52YW50aXZl
```
The following example retrieves the length of a GZIP-compressed variant of the single byte ASCII character `x`:
```sql
select length(gzip('eA=='))

-------------------
21
```
The following example retrieves the length of a GZIP-compressed variant of the 1200 characters representing 100 times the BASE64 encoding of the nine ASCII characters `invantive`:
```sql
select length(gzip(rpad('aW52YW50aXZl', 1200, 'aW52YW50aXZl')))

-------------------
37
```