Skip to content

Commit 2e0a48a

Browse files
committed
Add Sets With The Value Command as a postgres til
1 parent b88c731 commit 2e0a48a

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ variety of languages and technologies. These are things that don't really
77
warrant a full blog post. These are mostly things I learn by pairing with
88
smart people at [Hashrocket](http://hashrocket.com/).
99

10-
_332 TILs and counting..._
10+
_333 TILs and counting..._
1111

1212
---
1313

@@ -180,6 +180,7 @@ _332 TILs and counting..._
180180
- [Send A Command To psql](postgres/send-a-command-to-psql.md)
181181
- [Set Inclusion With hstore](postgres/set-inclusion-with-hstore.md)
182182
- [Set A Seed For The Random Number Generator](postgres/set-a-seed-for-the-random-number-generator.md)
183+
- [Sets With The Value Command](postgres/sets-with-the-value-command.md)
183184
- [Sleeping](postgres/sleeping.md)
184185
- [Special Math Operators](postgres/special-math-operators.md)
185186
- [String Contains Another String](postgres/string-contains-another-string.md)
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Sets With The Value Command
2+
3+
You can concisely create sets of values in PostgreSQL using the `values`
4+
command.
5+
6+
```sql
7+
> values (1), (2), (3);
8+
column1
9+
---------
10+
1
11+
2
12+
3
13+
```
14+
15+
You can even create multiple columns of values.
16+
17+
```sql
18+
> values (1, 'a', true), (2, 'b', false);
19+
column1 | column2 | column3
20+
---------+---------+---------
21+
1 | a | t
22+
2 | b | f
23+
```
24+
25+
This is most often used with an insert command, but can be used on its own,
26+
as a subquery, within a CTE, etc.
27+
28+
[source](http://www.postgresql.org/docs/current/static/sql-values.html)

0 commit comments

Comments
 (0)