Skip to content

Commit

Permalink
doc: add view to hcl schema (#1935)
Browse files Browse the repository at this point in the history
  • Loading branch information
a8m authored Aug 6, 2023
1 parent de3f0e7 commit 7d6df6d
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions doc/md/atlas-schema/hcl.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,43 @@ table "b" "users" {
}
```

## View

A `view` is a virtual table in the database, defined by a statement that queries rows from one or more existing
tables or views.

```hcl
view "clean_users" {
schema = schema.public
column "id" {
type = int
}
column "name" {
type = text
}
as = <<-SQL
SELECT u.id, u.name
FROM ${table.users.name} AS u
JOIN ${view.active_users.name} AS au USING (id)
SQL
depends_on = [table.users, view.t1]
comment = "A view to active users without sensitive data"
}
view "comedies" {
schema = schema.public
column "id" {
type = int
}
column "name" {
type = text
}
as = "SELECT id, name FROM films WHERE kind = 'Comedy'"
depends_on = [table.films]
check_option = CASCADED
}
```

## Column

A `column` is a child resource of a `table`.
Expand Down

0 comments on commit 7d6df6d

Please sign in to comment.