{
    "mode": "man",
    "parameter": "ALTER_OPERATOR_FAMILY",
    "section": "7",
    "url": "https://www.chedong.com/phpMan.php/man/ALTER_OPERATOR_FAMILY/7/json",
    "generated": "2026-10-07T21:05:49Z",
    "synopsis": "ALTER OPERATOR FAMILY name USING indexmethod ADD\n{  OPERATOR strategynumber operatorname ( optype, optype )\n[ FOR SEARCH | FOR ORDER BY sortfamilyname ]\n| FUNCTION supportnumber [ ( optype [ , optype ] ) ]\nfunctionname [ ( argumenttype [, ...] ) ]\n} [, ... ]\nALTER OPERATOR FAMILY name USING indexmethod DROP\n{  OPERATOR strategynumber ( optype [ , optype ] )\n| FUNCTION supportnumber ( optype [ , optype ] )\n} [, ... ]\nALTER OPERATOR FAMILY name USING indexmethod\nRENAME TO newname\nALTER OPERATOR FAMILY name USING indexmethod\nOWNER TO { newowner | CURRENTROLE | CURRENTUSER | SESSIONUSER }\nALTER OPERATOR FAMILY name USING indexmethod\nSET SCHEMA newschema",
    "sections": {
        "NAME": {
            "content": "ALTEROPERATORFAMILY - change the definition of an operator family\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "ALTER OPERATOR FAMILY name USING indexmethod ADD\n{  OPERATOR strategynumber operatorname ( optype, optype )\n[ FOR SEARCH | FOR ORDER BY sortfamilyname ]\n| FUNCTION supportnumber [ ( optype [ , optype ] ) ]\nfunctionname [ ( argumenttype [, ...] ) ]\n} [, ... ]\n\nALTER OPERATOR FAMILY name USING indexmethod DROP\n{  OPERATOR strategynumber ( optype [ , optype ] )\n| FUNCTION supportnumber ( optype [ , optype ] )\n} [, ... ]\n\nALTER OPERATOR FAMILY name USING indexmethod\nRENAME TO newname\n\nALTER OPERATOR FAMILY name USING indexmethod\nOWNER TO { newowner | CURRENTROLE | CURRENTUSER | SESSIONUSER }\n\nALTER OPERATOR FAMILY name USING indexmethod\nSET SCHEMA newschema\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "ALTER OPERATOR FAMILY changes the definition of an operator family. You can add operators and\nsupport functions to the family, remove them from the family, or change the family's name or\nowner.\n\nWhen operators and support functions are added to a family with ALTER OPERATOR FAMILY, they\nare not part of any specific operator class within the family, but are just “loose” within\nthe family. This indicates that these operators and functions are compatible with the\nfamily's semantics, but are not required for correct functioning of any specific index.\n(Operators and functions that are so required should be declared as part of an operator\nclass, instead; see CREATE OPERATOR CLASS (CREATEOPERATORCLASS(7)).)  PostgreSQL will allow\nloose members of a family to be dropped from the family at any time, but members of an\noperator class cannot be dropped without dropping the whole class and any indexes that depend\non it. Typically, single-data-type operators and functions are part of operator classes\nbecause they are needed to support an index on that specific data type, while cross-data-type\noperators and functions are made loose members of the family.\n\nYou must be a superuser to use ALTER OPERATOR FAMILY. (This restriction is made because an\nerroneous operator family definition could confuse or even crash the server.)\n\nALTER OPERATOR FAMILY does not presently check whether the operator family definition\nincludes all the operators and functions required by the index method, nor whether the\noperators and functions form a self-consistent set. It is the user's responsibility to define\na valid operator family.\n\nRefer to Section 38.16 for further information.\n",
            "subsections": []
        },
        "PARAMETERS": {
            "content": "name\nThe name (optionally schema-qualified) of an existing operator family.\n\nindexmethod\nThe name of the index method this operator family is for.\n\nstrategynumber\nThe index method's strategy number for an operator associated with the operator family.\n\noperatorname\nThe name (optionally schema-qualified) of an operator associated with the operator\nfamily.\n\noptype\nIn an OPERATOR clause, the operand data type(s) of the operator, or NONE to signify a\nprefix operator. Unlike the comparable syntax in CREATE OPERATOR CLASS, the operand data\ntypes must always be specified.\n\nIn an ADD FUNCTION clause, the operand data type(s) the function is intended to support,\nif different from the input data type(s) of the function. For B-tree comparison functions\nand hash functions it is not necessary to specify optype since the function's input data\ntype(s) are always the correct ones to use. For B-tree sort support functions, B-Tree\nequal image functions, and all functions in GiST, SP-GiST and GIN operator classes, it is\nnecessary to specify the operand data type(s) the function is to be used with.\n\nIn a DROP FUNCTION clause, the operand data type(s) the function is intended to support\nmust be specified.\n\nsortfamilyname\nThe name (optionally schema-qualified) of an existing btree operator family that\ndescribes the sort ordering associated with an ordering operator.\n\nIf neither FOR SEARCH nor FOR ORDER BY is specified, FOR SEARCH is the default.\n\nsupportnumber\nThe index method's support function number for a function associated with the operator\nfamily.\n\nfunctionname\nThe name (optionally schema-qualified) of a function that is an index method support\nfunction for the operator family. If no argument list is specified, the name must be\nunique in its schema.\n\nargumenttype\nThe parameter data type(s) of the function.\n\nnewname\nThe new name of the operator family.\n\nnewowner\nThe new owner of the operator family.\n\nnewschema\nThe new schema for the operator family.\n\nThe OPERATOR and FUNCTION clauses can appear in any order.\n",
            "subsections": []
        },
        "NOTES": {
            "content": "Notice that the DROP syntax only specifies the “slot” in the operator family, by strategy or\nsupport number and input data type(s). The name of the operator or function occupying the\nslot is not mentioned. Also, for DROP FUNCTION the type(s) to specify are the input data\ntype(s) the function is intended to support; for GiST, SP-GiST and GIN indexes this might\nhave nothing to do with the actual input argument types of the function.\n\nBecause the index machinery does not check access permissions on functions before using them,\nincluding a function or operator in an operator family is tantamount to granting public\nexecute permission on it. This is usually not an issue for the sorts of functions that are\nuseful in an operator family.\n\nThe operators should not be defined by SQL functions. An SQL function is likely to be inlined\ninto the calling query, which will prevent the optimizer from recognizing that the query\nmatches an index.\n\nBefore PostgreSQL 8.4, the OPERATOR clause could include a RECHECK option. This is no longer\nsupported because whether an index operator is “lossy” is now determined on-the-fly at run\ntime. This allows efficient handling of cases where an operator might or might not be lossy.\n",
            "subsections": []
        },
        "EXAMPLES": {
            "content": "The following example command adds cross-data-type operators and support functions to an\noperator family that already contains B-tree operator classes for data types int4 and int2.\n\nALTER OPERATOR FAMILY integerops USING btree ADD\n\n-- int4 vs int2\nOPERATOR 1 < (int4, int2) ,\nOPERATOR 2 <= (int4, int2) ,\nOPERATOR 3 = (int4, int2) ,\nOPERATOR 4 >= (int4, int2) ,\nOPERATOR 5 > (int4, int2) ,\nFUNCTION 1 btint42cmp(int4, int2) ,\n\n-- int2 vs int4\nOPERATOR 1 < (int2, int4) ,\nOPERATOR 2 <= (int2, int4) ,\nOPERATOR 3 = (int2, int4) ,\nOPERATOR 4 >= (int2, int4) ,\nOPERATOR 5 > (int2, int4) ,\nFUNCTION 1 btint24cmp(int2, int4) ;\n\nTo remove these entries again:\n\nALTER OPERATOR FAMILY integerops USING btree DROP\n\n-- int4 vs int2\nOPERATOR 1 (int4, int2) ,\nOPERATOR 2 (int4, int2) ,\nOPERATOR 3 (int4, int2) ,\nOPERATOR 4 (int4, int2) ,\nOPERATOR 5 (int4, int2) ,\nFUNCTION 1 (int4, int2) ,\n\n-- int2 vs int4\nOPERATOR 1 (int2, int4) ,\nOPERATOR 2 (int2, int4) ,\nOPERATOR 3 (int2, int4) ,\nOPERATOR 4 (int2, int4) ,\nOPERATOR 5 (int2, int4) ,\nFUNCTION 1 (int2, int4) ;\n",
            "subsections": []
        },
        "COMPATIBILITY": {
            "content": "There is no ALTER OPERATOR FAMILY statement in the SQL standard.\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "CREATE OPERATOR FAMILY (CREATEOPERATORFAMILY(7)), DROP OPERATOR FAMILY\n(DROPOPERATORFAMILY(7)), CREATE OPERATOR CLASS (CREATEOPERATORCLASS(7)), ALTER OPERATOR\nCLASS (ALTEROPERATORCLASS(7)), DROP OPERATOR CLASS (DROPOPERATORCLASS(7))\n\nPostgreSQL 16.14                                2026                        ALTER OPERATOR FAMILY(7)",
            "subsections": []
        }
    },
    "summary": "ALTEROPERATORFAMILY - change the definition of an operator family",
    "flags": [],
    "examples": [
        "The following example command adds cross-data-type operators and support functions to an",
        "operator family that already contains B-tree operator classes for data types int4 and int2.",
        "ALTER OPERATOR FAMILY integerops USING btree ADD",
        "-- int4 vs int2",
        "OPERATOR 1 < (int4, int2) ,",
        "OPERATOR 2 <= (int4, int2) ,",
        "OPERATOR 3 = (int4, int2) ,",
        "OPERATOR 4 >= (int4, int2) ,",
        "OPERATOR 5 > (int4, int2) ,",
        "FUNCTION 1 btint42cmp(int4, int2) ,",
        "-- int2 vs int4",
        "OPERATOR 1 < (int2, int4) ,",
        "OPERATOR 2 <= (int2, int4) ,",
        "OPERATOR 3 = (int2, int4) ,",
        "OPERATOR 4 >= (int2, int4) ,",
        "OPERATOR 5 > (int2, int4) ,",
        "FUNCTION 1 btint24cmp(int2, int4) ;",
        "To remove these entries again:",
        "ALTER OPERATOR FAMILY integerops USING btree DROP",
        "-- int4 vs int2",
        "OPERATOR 1 (int4, int2) ,",
        "OPERATOR 2 (int4, int2) ,",
        "OPERATOR 3 (int4, int2) ,",
        "OPERATOR 4 (int4, int2) ,",
        "OPERATOR 5 (int4, int2) ,",
        "FUNCTION 1 (int4, int2) ,",
        "-- int2 vs int4",
        "OPERATOR 1 (int2, int4) ,",
        "OPERATOR 2 (int2, int4) ,",
        "OPERATOR 3 (int2, int4) ,",
        "OPERATOR 4 (int2, int4) ,",
        "OPERATOR 5 (int2, int4) ,",
        "FUNCTION 1 (int2, int4) ;"
    ],
    "see_also": [
        {
            "name": "CREATEOPERATORFAMILY",
            "section": "7",
            "url": "https://www.chedong.com/phpMan.php/man/CREATEOPERATORFAMILY/7/json"
        },
        {
            "name": "DROPOPERATORFAMILY",
            "section": "7",
            "url": "https://www.chedong.com/phpMan.php/man/DROPOPERATORFAMILY/7/json"
        },
        {
            "name": "CREATEOPERATORCLASS",
            "section": "7",
            "url": "https://www.chedong.com/phpMan.php/man/CREATEOPERATORCLASS/7/json"
        },
        {
            "name": "ALTEROPERATORCLASS",
            "section": "7",
            "url": "https://www.chedong.com/phpMan.php/man/ALTEROPERATORCLASS/7/json"
        },
        {
            "name": "DROPOPERATORCLASS",
            "section": "7",
            "url": "https://www.chedong.com/phpMan.php/man/DROPOPERATORCLASS/7/json"
        },
        {
            "name": "FAMILY",
            "section": "7",
            "url": "https://www.chedong.com/phpMan.php/man/FAMILY/7/json"
        }
    ]
}