CREATE_OPERATOR_FAMILY(7pg18)
โจ CREATE_OPERATOR_FAMILY(7) โจ
okay bestie, welcome to the glow-up guide for CREATE OPERATOR FAMILY ๐ this is straight outta the PostgreSQL 18.6 Documentation, and we're gonna make it make sense. no cap.
๐ธ NAME ๐ธ
CREATE_OPERATOR_FAMILY โ define a new operator family โจ
๐ SYNOPSIS ๐
CREATE OPERATOR FAMILY name USING index_method
like, that's it. that's the whole thing. iconic.
๐ DESCRIPTION ๐
so CREATE OPERATOR FAMILY literally just creates a new operator family. and what IS an operator family, you ask? ๐
an operator family is a collection of related operator classes, plus maybe some extra operators and support functions that vibe with those operator classes but aren't actually essential for any individual index to function. ๐ซถ
โ ๏ธ important tea: operators and functions that ARE essential to indexes should be grouped up inside the relevant operator class โ not left "loose" in the operator family. don't do it. ๐
typically, single-data-type operators get bound to operator classes, while cross-data-type operators can be loose in an operator family that contains operator classes for both data types. that's the whole point of the family structure, iykyk.
when you make it, the new operator family starts out completely empty โ like a brand new group chat with nobody in it ๐ญ. you gotta populate it by:
- running subsequent
CREATE OPERATOR CLASScommands to add the contained operator classes, and - optionally running
ALTER OPERATOR FAMILYcommands to add "loose" operators and their corresponding support functions.
if you give a schema name, the operator family gets created in that schema. if you don't, it lands in the current schema. and here's the rule: two operator families in the same schema can have the same name only if they're for different index methods. periodt. โ
whoever defines an operator family becomes its owner. ๐ but rn, the creating user must be a superuser. why? because a busted operator family definition could confuse โ or even crash โ the server. ๐ฑ yeah. that's not a vibe. that's a whole emergency.
for further info, go read Section 36.16. ๐
๐ฆ PARAMETERS ๐ฆ
nameโ the name of the operator family you're creating. it can be schema-qualified. ๐index_methodโ the name of the index method this operator family is for. ๐ฏ
๐ COMPATIBILITY ๐
CREATE OPERATOR FAMILY is a PostgreSQL extension. there is no CREATE OPERATOR FAMILY statement in the SQL standard. so if you're out here expecting standard SQL to have your backโฆ it does not. ๐
๐ SEE ALSO ๐
ALTER OPERATOR FAMILY(ALTER_OPERATOR_FAMILY(7))DROP OPERATOR FAMILY(DROP_OPERATOR_FAMILY(7))CREATE OPERATOR CLASS(CREATE_OPERATOR_CLASS(7))ALTER OPERATOR CLASS(ALTER_OPERATOR_CLASS(7))DROP OPERATOR CLASS(DROP_OPERATOR_CLASS(7))
and that's the whole page, bestie!! ๐ go forth and build operator families responsibly (as a superuser, apparently ๐).
this has been brought to you by PostgreSQL 18.6, dated 2026. mwah. ๐โจ๐ฆ
๐ฆ where this page comes from
- opensuse-leap 16.0: postgresql18 18.6-160000.1.1 ยท PostgreSQL
- opensuse-leap 16.0: postgresql18 18.6-160000.1.1 ยท PostgreSQL
- opensuse-leap 16.0: postgresql18 18.6-160000.1.1 ยท PostgreSQL
- opensuse-leap 16.0: postgresql18 18.6-160000.1.1 ยท PostgreSQL
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms