Skip to content

Commit

Permalink
doc/md: add sequence doc for SQL Server (#2616)
Browse files Browse the repository at this point in the history
  • Loading branch information
giautm authored Mar 14, 2024
1 parent 9fcce8e commit 6675363
Showing 1 changed file with 45 additions and 1 deletion.
46 changes: 45 additions & 1 deletion doc/md/atlas-schema/hcl.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -1327,7 +1327,10 @@ atlas login
```
:::

The `sequence` block allows defining sequence number generator. Supported by PostgreSQL.
The `sequence` block allows defining sequence number generator. Supported by PostgreSQL and SQL Server.

<Tabs>
<TabItem label="PostgreSQL" value="postgres">

Note, a `sequence` block is printed by Atlas on inspection, or it may be manually defined in the schema only if it
represents a PostgreSQL sequence that is not implicitly created by the database for identity or `serial` columns.
Expand Down Expand Up @@ -1388,6 +1391,47 @@ schema "public" {
comment = "standard public schema"
}
```
</TabItem>
<TabItem label="SQL Server" value="sqlserver">

Atlas support define sequence in SQL Server by using `sequence` block. See more about [SQL Server sequence](https://learn.microsoft.com/en-us/sql/relational-databases/sequence-numbers/sequence-numbers).

```hcl
#highlight-next-line
# Simple sequence with default values.
sequence "s1" {
schema = schema.dbo
}
#highlight-next-line
# Sequence with custom configuration.
sequence "s2" {
schema = schema.dbo
type = decimal(18, 0)
start = 100000000000000000
increment = 1
min_value = 100000000000000000
max_value = 999999999999999999
cycle = true
}
#highlight-next-line
# The sequences with alias-type.
sequence "s3" {
schema = schema.dbo
type = type_alias.ssn
start = 111111111
increment = 1
min_value = 111111111
}
type_alias "ssn" {
schema = schema.dbo
type = dec(9, 0)
null = false
}
```
</TabItem>
</Tabs>

## Enum

Expand Down

0 comments on commit 6675363

Please sign in to comment.