{
    "mode": "man",
    "parameter": "SET",
    "section": "7",
    "url": "https://www.chedong.com/phpMan.php/man/SET/7/json",
    "generated": "2026-05-30T07:07:31Z",
    "synopsis": "SET [ SESSION | LOCAL ] configurationparameter { TO | = } { value | 'value' | DEFAULT }\nSET [ SESSION | LOCAL ] TIME ZONE { value | 'value' | LOCAL | DEFAULT }",
    "sections": {
        "NAME": {
            "content": "SET - change a run-time parameter\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "SET [ SESSION | LOCAL ] configurationparameter { TO | = } { value | 'value' | DEFAULT }\nSET [ SESSION | LOCAL ] TIME ZONE { value | 'value' | LOCAL | DEFAULT }\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "The SET command changes run-time configuration parameters. Many of the run-time parameters\nlisted in Chapter 20 can be changed on-the-fly with SET. (But some require superuser\nprivileges to change, and others cannot be changed after server or session start.)  SET only\naffects the value used by the current session.\n\nIf SET (or equivalently SET SESSION) is issued within a transaction that is later aborted,\nthe effects of the SET command disappear when the transaction is rolled back. Once the\nsurrounding transaction is committed, the effects will persist until the end of the session,\nunless overridden by another SET.\n\nThe effects of SET LOCAL last only till the end of the current transaction, whether committed\nor not. A special case is SET followed by SET LOCAL within a single transaction: the SET\nLOCAL value will be seen until the end of the transaction, but afterwards (if the transaction\nis committed) the SET value will take effect.\n\nThe effects of SET or SET LOCAL are also canceled by rolling back to a savepoint that is\nearlier than the command.\n\nIf SET LOCAL is used within a function that has a SET option for the same variable (see\nCREATE FUNCTION (CREATEFUNCTION(7))), the effects of the SET LOCAL command disappear at\nfunction exit; that is, the value in effect when the function was called is restored anyway.\nThis allows SET LOCAL to be used for dynamic or repeated changes of a parameter within a\nfunction, while still having the convenience of using the SET option to save and restore the\ncaller's value. However, a regular SET command overrides any surrounding function's SET\noption; its effects will persist unless rolled back.\n\nNote\nIn PostgreSQL versions 8.0 through 8.2, the effects of a SET LOCAL would be canceled by\nreleasing an earlier savepoint, or by successful exit from a PL/pgSQL exception block.\nThis behavior has been changed because it was deemed unintuitive.\n",
            "subsections": []
        },
        "PARAMETERS": {
            "content": "SESSION\nSpecifies that the command takes effect for the current session. (This is the default if\nneither SESSION nor LOCAL appears.)\n\nLOCAL\nSpecifies that the command takes effect for only the current transaction. After COMMIT or\nROLLBACK, the session-level setting takes effect again. Issuing this outside of a\ntransaction block emits a warning and otherwise has no effect.\n\nconfigurationparameter\nName of a settable run-time parameter. Available parameters are documented in Chapter 20\nand below.\n\nvalue\nNew value of parameter. Values can be specified as string constants, identifiers,\nnumbers, or comma-separated lists of these, as appropriate for the particular parameter.\nDEFAULT can be written to specify resetting the parameter to its default value (that is,\nwhatever value it would have had if no SET had been executed in the current session).\n\nBesides the configuration parameters documented in Chapter 20, there are a few that can only\nbe adjusted using the SET command or that have a special syntax:\n\nSCHEMA\nSET SCHEMA 'value' is an alias for SET searchpath TO value. Only one schema can be\nspecified using this syntax.\n\nNAMES\nSET NAMES value is an alias for SET clientencoding TO value.\n\nSEED\nSets the internal seed for the random number generator (the function random). Allowed\nvalues are floating-point numbers between -1 and 1 inclusive.\n\nThe seed can also be set by invoking the function setseed:\n\nSELECT setseed(value);\n\nTIME ZONE\nSET TIME ZONE 'value' is an alias for SET timezone TO 'value'. The syntax SET TIME ZONE\nallows special syntax for the time zone specification. Here are examples of valid values:\n\n'America/LosAngeles'\nThe time zone for Berkeley, California.\n\n'Europe/Rome'\nThe time zone for Italy.\n\n-7\nThe time zone 7 hours west from UTC (equivalent to PDT). Positive values are east\nfrom UTC.\n\nINTERVAL '-08:00' HOUR TO MINUTE\nThe time zone 8 hours west from UTC (equivalent to PST).\n\nLOCAL\nDEFAULT\nSet the time zone to your local time zone (that is, the server's default value of\ntimezone).\n\nTimezone settings given as numbers or intervals are internally translated to POSIX\ntimezone syntax. For example, after SET TIME ZONE -7, SHOW TIME ZONE would report\n<-07>+07.\n\nTime zone abbreviations are not supported by SET; see Section 8.5.3 for more information\nabout time zones.\n",
            "subsections": []
        },
        "NOTES": {
            "content": "The function setconfig provides equivalent functionality; see Section 9.27.1. Also, it is\npossible to UPDATE the pgsettings system view to perform the equivalent of SET.\n",
            "subsections": []
        },
        "EXAMPLES": {
            "content": "Set the schema search path:\n\nSET searchpath TO myschema, public;\n\nSet the style of date to traditional POSTGRES with “day before month” input convention:\n\nSET datestyle TO postgres, dmy;\n\nSet the time zone for Berkeley, California:\n\nSET TIME ZONE 'America/LosAngeles';\n\nSet the time zone for Italy:\n\nSET TIME ZONE 'Europe/Rome';\n",
            "subsections": []
        },
        "COMPATIBILITY": {
            "content": "SET TIME ZONE extends syntax defined in the SQL standard. The standard allows only numeric\ntime zone offsets while PostgreSQL allows more flexible time-zone specifications. All other\nSET features are PostgreSQL extensions.\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "RESET(7), SHOW(7)\n\n\n\nPostgreSQL 14.23                                2026                                          SET(7)",
            "subsections": []
        }
    },
    "summary": "SET - change a run-time parameter",
    "flags": [],
    "examples": [
        "Set the schema search path:",
        "SET searchpath TO myschema, public;",
        "Set the style of date to traditional POSTGRES with “day before month” input convention:",
        "SET datestyle TO postgres, dmy;",
        "Set the time zone for Berkeley, California:",
        "SET TIME ZONE 'America/LosAngeles';",
        "Set the time zone for Italy:",
        "SET TIME ZONE 'Europe/Rome';"
    ],
    "see_also": [
        {
            "name": "RESET",
            "section": "7",
            "url": "https://www.chedong.com/phpMan.php/man/RESET/7/json"
        },
        {
            "name": "SHOW",
            "section": "7",
            "url": "https://www.chedong.com/phpMan.php/man/SHOW/7/json"
        }
    ]
}