1
0
mirror of https://github.com/jbranchaud/til synced 2026-01-07 09:08:01 +00:00

Add Sets With The Value Command as a postgres til

This commit is contained in:
jbranchaud
2016-02-13 13:50:42 -06:00
parent b88c731fa6
commit 2e0a48a82a
2 changed files with 30 additions and 1 deletions

View File

@@ -0,0 +1,28 @@
# Sets With The Value Command
You can concisely create sets of values in PostgreSQL using the `values`
command.
```sql
> values (1), (2), (3);
column1
---------
1
2
3
```
You can even create multiple columns of values.
```sql
> values (1, 'a', true), (2, 'b', false);
column1 | column2 | column3
---------+---------+---------
1 | a | t
2 | b | f
```
This is most often used with an insert command, but can be used on its own,
as a subquery, within a CTE, etc.
[source](http://www.postgresql.org/docs/current/static/sql-values.html)