How do I modify the `sql_mode` in TiDB?

TiDB supports modifying the sql_mode system variables on a SESSION or GLOBAL basis.

  • Changes to GLOBAL scoped variables propagate to the rest servers of the cluster and persist across restarts. This means that you do not need to change the sql_mode value on each TiDB server.
  • Changes to SESSION scoped variables only affect the current client session. After restarting a server, the changes are lost.