CREATE_OPERATOR_FAMILY(7)

โœจ 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 CLASS commands to add the contained operator classes, and
  • optionally running ALTER OPERATOR FAMILY commands 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 ๐Ÿ’œ


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. ๐Ÿ’–โœจ๐Ÿฆ‹