cockroachdb / cockroachdb/cockroach

Support IDENTITY column creation using existing sequence

Open
#97,851 0 comments 0 reactions 0 assignees View on GitHub
C-enhancement
Dominant language
Go
Stars
32.5k
Forks
4.1k
PR merge metrics
PR metrics pending

Description

In postgres, you can name the sequence which will be created or use an existing schema when using `IDENTITY` syntax with the `SEQUENCE NAME` sequence option. Cockroach does not currently support this option.

For example:

```
CREATE SEQUENCE foo;
CREATE TABLE t (i INT GENERATED BY DEFAULT AS IDENTITY (SEQUENCE NAME foo));
```

It would be great to support this syntax in CockroachDB

#### Additional Context

You can get the same behavior in cockroach and postgres with this syntax:
```
CREATE TABLE t (i INT DEFAULT (nextval('foo')));
```

What cockroach doesn't support is controlling the name of a newly generated sequence.

Jira issue: CRDB-24921

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.