diff --git a/README.md b/README.md index 78272e3..82e48b6 100644 --- a/README.md +++ b/README.md @@ -142,6 +142,7 @@ smart people at [Hashrocket](http://hashrocket.com/). - [Max Identifier Length Is 63 Bytes](postgres/max-identifier-length-is-63-bytes.md) - [Restart A Sequence](postgres/restart-a-sequence.md) - [Send A Command To psql](postgres/send-a-command-to-psql.md) +- [Set Inclusion With hstore](postgres/set-inclusion-with-hstore.md) - [Special Math Operators](postgres/special-math-operators.md) - [String Contains Another String](postgres/string-contains-another-string.md) - [Temporarily Disable Triggers](postgres/temporarily-disable-triggers.md) diff --git a/postgres/set-inclusion-with-hstore.md b/postgres/set-inclusion-with-hstore.md new file mode 100644 index 0000000..0a7b5a3 --- /dev/null +++ b/postgres/set-inclusion-with-hstore.md @@ -0,0 +1,22 @@ +# Set Inclusion With hstore + +In PostgreSQL, `hstore` records can be compared via set inclusion. The `@>` +and `<@` operators can be used for this. The `@>` operator checks if the +right operand is a subset of the left operand. The `<@` operator checks if +the left operand is a subset of the right operand. + +```sql +> select '"one"=>"1", "two"=>"2", "three"=>"3"'::hstore @> '"two"=>"2"'::hstore; + ?column? + ---------- + t + +> select '"one"=>"1", "two"=>"2", "three"=>"3"'::hstore <@ '"two"=>"2"'::hstore; + ?column? +---------- + f +``` + +See the [`hstore` PostgreSQL +docs](http://www.postgresql.org/docs/current/static/hstore.html) for more +details.