Daniel Doboș
Daniel Doboș

Reputation: 81

Auto incrementing delta table id with START INCREMENT by

When I try to generate a default increment it works just fine, but adding START WITH, INCREMENT BY throws an error. I'm using DB 11.3 so it should be supported, pic with error attachedenter image description here

Upvotes: 0

Views: 1253

Answers (1)

rainingdistros
rainingdistros

Reputation: 645

The square brackets are used to identify optional values - took me a few tries to get the syntax right...

%sql CREATE
OR REPLACE TABLE products (
  product_id BIGINT GENERATED BY DEFAULT AS IDENTITY (START WITH 100 INCREMENT BY 1),
  product_type STRING,
  sales BIGINT
);

INSERT INTO products (product_type, sales)
VALUES ("Batteries", 150000);
INSERT INTO products (product_type, sales)
VALUES ("lAPTOP", 100000);

Sample Output

Hope it helps...

Upvotes: 1

Related Questions