monotonically_increasing_id function

Applies to: check marked yes Databricks SQL check marked yes Databricks Runtime

Returns monotonically increasing 64-bit integers.

Syntax

monotonically_increasing_id()

Arguments

This function takes no arguments.

Returns

A BIGINT.

The generated ID is guaranteed to be monotonically increasing and unique, but not consecutive.

Examples

> SELECT monotonically_increasing_id();
 0