diff --git a/CREDITS b/CREDITS index 9363b3d685897..94959290de2fa 100644 --- a/CREDITS +++ b/CREDITS @@ -66,7 +66,7 @@ following services to the MariaDB community: - Bug fixing in MariaDB (for bugs that affects a large part of the community) - Building the official MariaDB binaries - Maintaining https://mariadb.org -- Documenting MariaDB in the MariaDB Documentation https://mariadb.com/kb +- Documenting MariaDB in the MariaDB Documentation https://mariadb.com/docs To be able to do the above we need help from corporations and individuals! diff --git a/Docs/INSTALL-BINARY b/Docs/INSTALL-BINARY index 081f4dc969161..1df48e490fefa 100644 --- a/Docs/INSTALL-BINARY +++ b/Docs/INSTALL-BINARY @@ -2,7 +2,7 @@ MariaDB and MySQL have identical install methods. In this document we describe how to install MariaDB. The full documentation for installing MariaDB can be found at -https://mariadb.com/kb/en/library/binary-packages/ +https://mariadb.com/docs/server/server-management/install-and-upgrade-mariadb/installing-mariadb/binary-packages However most documentation at www.mysql.com also applies. 2.2. Installing MariaDB from Generic Binaries on Unix/Linux @@ -36,7 +36,7 @@ However most documentation at www.mysql.com also applies. please report them to: https://mariadb.org/jira See the instructions at - https://mariadb.com/kb/en/mariadb-community-bug-reporting + https://mariadb.com/docs/general-resources/community/community/bug-tracking/reporting-bugs The basic commands that you must execute to install and use a MariaDB binary distribution are: @@ -83,7 +83,7 @@ shell> useradd -g mysql mysql shell> cd /usr/local 3. Obtain a distribution file using the instructions at - https://mariadb.com/kb/en/library/where-to-download-mariadb/ + https://mariadb.com/docs/server/clients-and-utilities/server-client-software/download/where-to-download-mariadb The description below describes how to install a MariaDB tar file. 4. Unpack the distribution, which creates the installation @@ -152,7 +152,7 @@ shell> chown -R mysql data location where your system has its startup files. More information can be found in the support-files/mysql.server script itself and at - https://mariadb.com/kb/en/starting-and-stopping-mariadb-automatically. + https://mariadb.com/docs/server/server-management/starting-and-stopping-mariadb/starting-and-stopping-mariadb-automatically 10. You can set up new accounts using the bin/mysql_setpermission script if you install the DBI and DBD::MariaDB Perl modules. See Section 4.6.14, "mysql_setpermission --- Interactively Set @@ -184,7 +184,7 @@ shell> bin/mysqld_safe --user=mysql & directory. More information about mysqld_safe can be found at - https://mariadb.com/kb/en/mysqld_safe + https://mariadb.com/docs/server/clients-and-utilities/legacy-clients-and-utilities/mariadbd_safe Note diff --git a/INSTALL-SOURCE b/INSTALL-SOURCE index 93c985f2c1dd8..647e7c9414409 100644 --- a/INSTALL-SOURCE +++ b/INSTALL-SOURCE @@ -1,3 +1,3 @@ Instructions for building MariaDB can be found at: -https://mariadb.com/kb/en/compiling-mariadb-from-source +https://mariadb.com/docs/server/server-management/install-and-upgrade-mariadb/compiling-mariadb-from-source diff --git a/INSTALL-WIN-SOURCE b/INSTALL-WIN-SOURCE index f10d13aa93b92..f74ea98e78346 100644 --- a/INSTALL-WIN-SOURCE +++ b/INSTALL-WIN-SOURCE @@ -1,3 +1,3 @@ Up-to-date instructions about building MariaDB on Windows can be found -at: https://mariadb.com/kb/en/Building_MariaDB_on_Windows +at: https://mariadb.com/docs/server/server-management/install-and-upgrade-mariadb/compiling-mariadb-from-source/building_mariadb_on_windows diff --git a/KNOWN_BUGS.txt b/KNOWN_BUGS.txt index af65c98590d41..1b6ddba45689f 100644 --- a/KNOWN_BUGS.txt +++ b/KNOWN_BUGS.txt @@ -12,4 +12,4 @@ that we are can try to fix it for the next release. You can also add feature request to the JIRA. The latest documentation for the MariaDB server can be found at: -https://mariadb.com/kb +https://mariadb.com/docs diff --git a/README.md b/README.md index a8fbc119f0fd1..123f90bad0372 100644 --- a/README.md +++ b/README.md @@ -24,13 +24,13 @@ A description of the MariaDB project and a manual can be found at: https://mariadb.org -https://mariadb.com/kb/en/ +https://mariadb.com/docs/ -https://mariadb.com/kb/en/mariadb-vs-mysql-features/ +https://mariadb.com/docs/release-notes/community-server/about/compatibility-and-differences/mariadb-vs-mysql-features -https://mariadb.com/kb/en/mariadb-versus-mysql-compatibility/ +https://mariadb.com/docs/release-notes/community-server/about/compatibility-and-differences/mariadb-vs-mysql-compatibility -https://mariadb.com/kb/en/new-and-old-releases/ +https://mariadb.com/docs/release-notes # Getting the code, building it and testing it diff --git a/client/mysqlcheck.c b/client/mysqlcheck.c index a5704ef526d47..9f3fe468e8fcb 100644 --- a/client/mysqlcheck.c +++ b/client/mysqlcheck.c @@ -274,8 +274,8 @@ static void usage(void) printf("Usage: %s [OPTIONS] database [tables]\n", my_progname); printf("OR %s [OPTIONS] --databases DB1 [DB2 DB3...]\n", my_progname); - puts("Please consult the MariaDB Knowledge Base at"); - puts("https://mariadb.com/kb/en/mysqlcheck for latest information about"); + puts("Please consult the MariaDB Documentation at"); + puts("https://mariadb.com/docs/server/clients-and-utilities/legacy-clients-and-utilities/mysqlcheck for latest information about"); puts("this program."); print_defaults("my", load_default_groups); puts(""); diff --git a/client/mysqltest.cc b/client/mysqltest.cc index 33f50f25e099b..6677e23152d78 100644 --- a/client/mysqltest.cc +++ b/client/mysqltest.cc @@ -20,7 +20,7 @@ Tool used for executing a .test file See the "MySQL Test framework manual" for more information - https://mariadb.com/kb/en/library/mysqltest/ + https://mariadb.com/docs/server/clients-and-utilities/testing-tools/mariadb-test Please keep the test framework tools identical in all versions! diff --git a/cmake/cpack_rpm.cmake b/cmake/cpack_rpm.cmake index 816ce8490652a..706a8156095c3 100644 --- a/cmake/cpack_rpm.cmake +++ b/cmake/cpack_rpm.cmake @@ -76,7 +76,7 @@ SET(CPACK_RPM_PACKAGE_DESCRIPTION "MariaDB: a very fast and robust SQL database It is GPL v2 licensed, which means you can use the it free of charge under the conditions of the GNU General Public License Version 2 (http://www.gnu.org/licenses/). -MariaDB documentation can be found at https://mariadb.com/kb +MariaDB documentation can be found at https://mariadb.com/docs MariaDB bug reports should be submitted through https://jira.mariadb.org") # mariabackup diff --git a/cmake/mysql_version.cmake b/cmake/mysql_version.cmake index 9f1534a72e480..aa0aa60591b51 100644 --- a/cmake/mysql_version.cmake +++ b/cmake/mysql_version.cmake @@ -97,7 +97,7 @@ SET_IF_UNSET(CPACK_PACKAGE_DESCRIPTION "${CPACK_PACKAGE_DESCRIPTION_SUMMARY} It is GPL v2 licensed, which means you can use the it free of charge under the conditions of the GNU General Public License Version 2 (http://www.gnu.org/licenses/). -MariaDB documentation can be found at https://mariadb.com/kb +MariaDB documentation can be found at https://mariadb.com/docs MariaDB bug reports should be submitted through https://jira.mariadb.org ") diff --git a/debian/additions/mariadb.cnf b/debian/additions/mariadb.cnf index 62b4ea8f11ea8..95038f0496f16 100644 --- a/debian/additions/mariadb.cnf +++ b/debian/additions/mariadb.cnf @@ -13,7 +13,7 @@ # Run program with --help to get a list of available options and with # --print-defaults to see which it would actually understand and use. # -# If you are new to MariaDB, check out https://mariadb.com/kb/en/basic-mariadb-articles/ +# If you are new to MariaDB, check out https://mariadb.com/docs/server/server-usage/basics # # This group is read both by the client and the server diff --git a/debian/additions/mariadb.conf.d/50-mysqld_safe.cnf b/debian/additions/mariadb.conf.d/50-mysqld_safe.cnf index e24f96a9e65b5..66c5e00e777be 100644 --- a/debian/additions/mariadb.conf.d/50-mysqld_safe.cnf +++ b/debian/additions/mariadb.conf.d/50-mysqld_safe.cnf @@ -16,7 +16,7 @@ # SyslogLevel = err # SyslogIdentifier = mysqld # -# For more information, please read https://mariadb.com/kb/en/mariadb/systemd/ +# For more information, please read https://mariadb.com/docs/server/server-management/starting-and-stopping-mariadb/systemd [mysqld_safe] # This will be passed to all mysql clients diff --git a/debian/additions/mariadb.conf.d/50-server.cnf b/debian/additions/mariadb.conf.d/50-server.cnf index f9fb4e6a1f195..5f01eb0885481 100644 --- a/debian/additions/mariadb.conf.d/50-server.cnf +++ b/debian/additions/mariadb.conf.d/50-server.cnf @@ -82,7 +82,7 @@ expire_logs_days = 10 # # For documentation, please read -# https://mariadb.com/kb/en/securing-connections-for-client-and-server/ +# https://mariadb.com/docs/server/security/encryption/data-in-transit-encryption/securing-connections-for-client-and-server #ssl-ca = /etc/mysql/cacert.pem #ssl-cert = /etc/mysql/server-cert.pem #ssl-key = /etc/mysql/server-key.pem @@ -104,7 +104,7 @@ collation-server = utf8mb4_general_ci # InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/. # Read the manual for more InnoDB related options. There are many! # Most important is to give InnoDB 80 % of the system RAM for buffer use: -# https://mariadb.com/kb/en/innodb-system-variables/#innodb_buffer_pool_size +# https://mariadb.com/docs/server/server-usage/storage-engines/innodb/innodb-system-variables#innodb_buffer_pool_size #innodb_buffer_pool_size = 8G # this is only for embedded server diff --git a/debian/additions/mariadb.conf.d/60-galera.cnf b/debian/additions/mariadb.conf.d/60-galera.cnf index 274891b131361..5ceb44b9e53a3 100644 --- a/debian/additions/mariadb.conf.d/60-galera.cnf +++ b/debian/additions/mariadb.conf.d/60-galera.cnf @@ -2,7 +2,7 @@ # * Galera-related settings # # See the examples of server wsrep.cnf files in /usr/share/mysql -# and read more at https://mariadb.com/kb/en/galera-cluster/ +# and read more at https://mariadb.com/docs/galera-cluster [galera] # Mandatory settings diff --git a/debian/control b/debian/control index a53354c16a982..5810bb1e4c08e 100644 --- a/debian/control +++ b/debian/control @@ -796,7 +796,7 @@ Description: Backup tool for MariaDB server Based on Xtrabackup, but improved to work with MariaDB server. This backup tool is guaranteed to be compatible with MariaDB server. . - Please refer to the MariaDB Knowledge Base on more information on + Please refer to the MariaDB Documentation on more information on how to use this tool. Package: mariadb-plugin-connect diff --git a/debian/mariadb-server.README.Debian b/debian/mariadb-server.README.Debian index 6042249a70623..acf9ece677044 100644 --- a/debian/mariadb-server.README.Debian +++ b/debian/mariadb-server.README.Debian @@ -34,7 +34,7 @@ name has been kept as a symbolic link to the new name for backwards compatibilit From MariaDB 10.1 onward the upstream mariadb.service and mariadb@.service are used to provide the full systemd experience. Some features available in traditional /etc/init.d/mysql have been changed. For details see -https://mariadb.com/kb/en/mariadb/systemd/ +https://mariadb.com/docs/server/server-management/starting-and-stopping-mariadb/systemd * MIXING PACKAGES FROM MARIADB.ORG AND OFFICIAL DEBIAN REPOSITORIES @@ -99,7 +99,7 @@ that script will try to do things that are already prevented, and might fail. =========================== The privilege tables are automatically updated so all there is left is read -the release notes on https://mariadb.com/kb/en/release-notes/ to see if any +the release notes on https://mariadb.com/docs/release-notes to see if any changes affect custom apps. There should not be any need to run 'mysql_upgrade' manually, as the upgrade @@ -132,7 +132,7 @@ immediately check your firewall rules or network routes. * WHERE IS THE DOCUMENTATION? ============================= -https://mariadb.com/kb +https://mariadb.com/docs * PASSWORDS @@ -169,7 +169,7 @@ be chmod 0600 (-rw------- username usergroup .my.cnf) to ensure that nobody else can read it. Every other configuration parameter can be stored there, too. For more information in the MariaDB manual in/usr/share/doc/mariadb-doc or -https://mariadb.com/kb/en/configuring-mariadb-with-mycnf/. +https://mariadb.com/docs/server/server-management/install-and-upgrade-mariadb/configuring-mariadb/configuring-mariadb-with-option-files * FURTHER NOTES ON REPLICATION diff --git a/debian/mariadb-server.mysql.default b/debian/mariadb-server.mysql.default index 36079edecb2fe..a4d24fe9a4169 100644 --- a/debian/mariadb-server.mysql.default +++ b/debian/mariadb-server.mysql.default @@ -8,7 +8,7 @@ # # See also: # https://wiki.debian.org/Teams/pkg-systemd/Packaging#overriding_options_and_.2Fetc.2Fdefault_handling -# https://mariadb.com/kb/en/mariadb/systemd/ +# https://mariadb.com/docs/server/server-management/starting-and-stopping-mariadb/systemd # # Note also that MariaDB systemd does _not_ utilize mysqld_safe. diff --git a/extra/innochecksum.cc b/extra/innochecksum.cc index 4f049f86328a7..8264df1ff1cd0 100644 --- a/extra/innochecksum.cc +++ b/extra/innochecksum.cc @@ -1194,7 +1194,7 @@ static struct my_option innochecksum_options[] = { {"verbose", 'v', "Verbose (prints progress every 5 seconds).", &verbose, &verbose, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, #ifndef DBUG_OFF - {"debug", '#', "Output debug log. See https://mariadb.com/kb/en/library/creating-a-trace-file/", + {"debug", '#', "Output debug log. See https://mariadb.com/docs/server/reference/product-development/mariadb-fault-finding", &dbug_setting, &dbug_setting, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, #endif /* !DBUG_OFF */ {"count", 'c', "Print the count of pages in the file and exits.", @@ -1263,7 +1263,7 @@ static void usage(void) "[-p ] [-i] [-v] [-a ] [-n] " "[-S] [-D ] " "[-l ] [-l] [-m ] \n", my_progname); - printf("See https://mariadb.com/kb/en/library/innochecksum/" + printf("See https://mariadb.com/docs/server/clients-and-utilities/administrative-tools/innochecksum" " for usage hints.\n"); my_print_help(innochecksum_options); my_print_variables(innochecksum_options); diff --git a/include/mysql/service_progress_report.h b/include/mysql/service_progress_report.h index 11fc24dc3b8b7..3f99f78e7dc2b 100644 --- a/include/mysql/service_progress_report.h +++ b/include/mysql/service_progress_report.h @@ -22,7 +22,7 @@ if requested. The functions are documented at - https://mariadb.com/kb/en/progress-reporting/#how-to-add-support-for-progress-reporting-to-a-storage-engine + https://mariadb.com/docs/server/reference/product-development/mariadb-internals/using-mariadb-with-your-programs-api */ #ifdef __cplusplus diff --git a/man/galera_new_cluster.1 b/man/galera_new_cluster.1 index 4e03abf1d3cae..22616fb187fe6 100644 --- a/man/galera_new_cluster.1 +++ b/man/galera_new_cluster.1 @@ -33,4 +33,4 @@ Display a help message and exit\&. .sp .SH "SEE ALSO" For more information on configuration and usage see -https://mariadb.com/kb/en/mariadb/getting-started-with-mariadb-galera-cluster/ +https://mariadb.com/docs/galera-cluster/galera-cluster-quickstart-guides/mariadb-galera-cluster-guide diff --git a/man/myrocks_hotbackup.1 b/man/myrocks_hotbackup.1 index 99dcbefabb0de..968fb02c6c490 100644 --- a/man/myrocks_hotbackup.1 +++ b/man/myrocks_hotbackup.1 @@ -77,6 +77,6 @@ starting backup. debugging purpose: waiting until the specified file is created .SH "SEE ALSO" -For more information, please refer to the MariaDB Knowledge Base, available online at https://mariadb.com/kb/ +For more information, please refer to the MariaDB Documentation, available online at https://mariadb.com/docs .SH AUTHOR MariaDB Foundation (http://www.mariadb.org/). diff --git a/man/mysql_ldb.1 b/man/mysql_ldb.1 index 5d58bd0b8865d..b27fe0ebe0598 100644 --- a/man/mysql_ldb.1 +++ b/man/mysql_ldb.1 @@ -13,4 +13,4 @@ mariadb-ldb \- RocksDB tool (mysql_ldb is now a symlink to mariadb-ldb) .SH DESCRIPTION Use \fBmysql_ldb \-\-help\fR for details on usage\. .PP -For more information, please refer to the MariaDB Knowledge Base, available online at https://mariadb.com/kb/ +For more information, please refer to the MariaDB Documentation, available online at https://mariadb.com/docs diff --git a/man/mysqlcheck.1 b/man/mysqlcheck.1 index eb4a18a3e53ac..dd200a094b3d2 100644 --- a/man/mysqlcheck.1 +++ b/man/mysqlcheck.1 @@ -86,13 +86,8 @@ note : The storage engine for the table doesn't support check .\} .PP If -<<<<<<< HEAD:man/mysqlcheck.1 -\fBmysqlcheck\fR -is unable to repair a table, see the MariaDB Knowledge Base -======= \fBmariadb-check\fR is unable to repair a table, see the MariaDB Documentation ->>>>>>> 894af99358b (edit KB to documentation):man/mariadb-check.1 for manual table repair strategies\&. This will be the case, for example, for InnoDB tables, which can be checked with diff --git a/mysql-test/README b/mysql-test/README index ef9e07fa0dabb..b64a074b7bb13 100644 --- a/mysql-test/README +++ b/mysql-test/README @@ -28,7 +28,7 @@ To clean up afterwards, remove the created "var" subdirectory, e.g. If tests fail on your system, please read the following manual section for instructions on how to report the problem: -https://mariadb.com/kb/en/reporting-bugs +https://mariadb.com/docs/general-resources/community/community/bug-tracking/reporting-bugs If you want to use an already running MySQL server for specific tests, use the --extern option to mysql-test-run. Please note that in this mode, @@ -94,7 +94,7 @@ ftp://ftp.mariadb.org/private and submit a report to https://mariadb.org/jira about it. The latest information about mysql-test-run can be found at: -https://mariadb.com/kb/en/mariadb/mysqltest/ +https://mariadb.com/docs/server/clients-and-utilities/testing-tools/mariadb-test If you want to create .rdiff files, check -https://mariadb.com/kb/en/mariadb/mysql-test-auxiliary-files/ +https://mariadb.com/docs/server/clients-and-utilities/testing-tools/mariadb-test/mariadb-test-auxiliary-files diff --git a/mysql-test/main/ps_missed_cmds.result b/mysql-test/main/ps_missed_cmds.result index bde750434b3fe..e56c1763e2fde 100644 --- a/mysql-test/main/ps_missed_cmds.result +++ b/mysql-test/main/ps_missed_cmds.result @@ -242,7 +242,8 @@ DEALLOCATE PREPARE stmt_4; DROP TABLE t1; # Test case 10: Check that the HELP statement # is supported by prepared statements -INSERT INTO mysql.help_topic VALUES (0, 'Tamagotchi', 0, 'This digital pet is not a KB article', 'no example', 'https://tamagotchi.com/'); +INSERT INTO mysql.help_topic (help_topic_id, help_category_id, name, description, example, url) +VALUES (4294967295, 0, 'Tamagotchi', 'This digital pet is not a KB article', 'no example', 'https://tamagotchi.com/'); PREPARE stmt_1 FROM "HELP `Tamagotchi`"; EXECUTE stmt_1; name description example @@ -253,7 +254,7 @@ Tamagotchi This digital pet is not a KB article no example EXECUTE stmt_1; name description example Tamagotchi This digital pet is not a KB article no example -DELETE FROM mysql.help_topic WHERE help_topic_id = 0; +DELETE FROM mysql.help_topic WHERE help_topic_id = 4294967295; # Test case 11: Check that the 'CREATE PROCEDURE' statement # is supported by prepared statements PREPARE stmt_1 FROM 'CREATE PROCEDURE p1() SET @a=1'; diff --git a/mysql-test/main/ps_missed_cmds.test b/mysql-test/main/ps_missed_cmds.test index 0bf12a2e47772..4d211d02f9aa1 100644 --- a/mysql-test/main/ps_missed_cmds.test +++ b/mysql-test/main/ps_missed_cmds.test @@ -270,7 +270,8 @@ DROP TABLE t1; --echo # Test case 10: Check that the HELP statement --echo # is supported by prepared statements # avoid existing articles that may get updated. -INSERT INTO mysql.help_topic VALUES (0, 'Tamagotchi', 0, 'This digital pet is not a KB article', 'no example', 'https://tamagotchi.com/'); +INSERT INTO mysql.help_topic (help_topic_id, help_category_id, name, description, example, url) +VALUES (4294967295, 0, 'Tamagotchi', 'This digital pet is not a KB article', 'no example', 'https://tamagotchi.com/'); PREPARE stmt_1 FROM "HELP `Tamagotchi`"; EXECUTE stmt_1; --echo # Execute the same prepared statement the second time to check that @@ -278,7 +279,7 @@ EXECUTE stmt_1; --echo # were damaged. EXECUTE stmt_1; -DELETE FROM mysql.help_topic WHERE help_topic_id = 0; +DELETE FROM mysql.help_topic WHERE help_topic_id = 4294967295; --echo # Test case 11: Check that the 'CREATE PROCEDURE' statement --echo # is supported by prepared statements diff --git a/mysql-test/main/ps_missed_cmds_bin_prot.result b/mysql-test/main/ps_missed_cmds_bin_prot.result index adb6eda2c56af..d9ca53215a8da 100644 --- a/mysql-test/main/ps_missed_cmds_bin_prot.result +++ b/mysql-test/main/ps_missed_cmds_bin_prot.result @@ -104,11 +104,12 @@ HANDLER t1 CLOSE; DROP TABLE t1; # Test case 10: Check that the statements 'HELP' # is supported by prepared statements -INSERT INTO mysql.help_topic VALUES (0, 'Tamagotchi', 0, 'This digital pet is not a KB article', 'no example', 'https://tamagotchi.com/'); +INSERT INTO mysql.help_topic (help_topic_id, help_category_id, name, description, example, url) +VALUES (4294967295, 0, 'Tamagotchi','This digital pet is not a KB article', 'no example', 'https://tamagotchi.com/'); HELP `Tamagotchi`; name description example Tamagotchi This digital pet is not a KB article no example -DELETE FROM mysql.help_topic WHERE help_topic_id = 0; +DELETE FROM mysql.help_topic WHERE help_topic_id = 4294967295; # Test case 11: Check that the statements CREATE/ALTER/DROP PROCEDURE # are supported by prepared statements CREATE PROCEDURE p1() SET @a=1; diff --git a/mysql-test/main/ps_missed_cmds_bin_prot.test b/mysql-test/main/ps_missed_cmds_bin_prot.test index a2be550741444..1b00cf7dc0f39 100644 --- a/mysql-test/main/ps_missed_cmds_bin_prot.test +++ b/mysql-test/main/ps_missed_cmds_bin_prot.test @@ -133,9 +133,10 @@ DROP TABLE t1; --echo # Test case 10: Check that the statements 'HELP' --echo # is supported by prepared statements # avoid existing articles that may get updated. -INSERT INTO mysql.help_topic VALUES (0, 'Tamagotchi', 0, 'This digital pet is not a KB article', 'no example', 'https://tamagotchi.com/'); +INSERT INTO mysql.help_topic (help_topic_id, help_category_id, name, description, example, url) +VALUES (4294967295, 0, 'Tamagotchi','This digital pet is not a KB article', 'no example', 'https://tamagotchi.com/'); HELP `Tamagotchi`; -DELETE FROM mysql.help_topic WHERE help_topic_id = 0; +DELETE FROM mysql.help_topic WHERE help_topic_id = 4294967295; --echo # Test case 11: Check that the statements CREATE/ALTER/DROP PROCEDURE --echo # are supported by prepared statements diff --git a/mysql-test/main/range_notembedded.result b/mysql-test/main/range_notembedded.result index 1babba7548e7e..6a5e5d208d97b 100644 --- a/mysql-test/main/range_notembedded.result +++ b/mysql-test/main/range_notembedded.result @@ -206,14 +206,13 @@ drop table t1; # # MDEV-24739: Assertion `root->weight >= ...' failed in SEL_ARG::tree_delete # -SELECT * -FROM mysql.help_relation -WHERE NOT (help_topic_id != 8 AND help_keyword_id != 0 OR help_keyword_id = 2 OR help_topic_id < 1900); -help_topic_id help_keyword_id -SELECT * -FROM mysql.help_relation ignore index (help_topic_id) -WHERE (help_topic_id = 8 OR help_keyword_id = 0) AND help_keyword_id != 2 AND help_topic_id >= 1900; -help_topic_id help_keyword_id +CREATE TABLE r (t INT, k INT, PRIMARY KEY(k,t), KEY(t)); +INSERT INTO r VALUES (5,1), (5,2), (10,2), (16,2), (100,2), (400, 5), (300, 10), (600, 42) ; +SELECT * FROM r WHERE NOT (t != 8 AND k != 0 OR k = 2 OR t < 1900); +t k +SELECT * FROM r ignore index (t) WHERE (t = 8 OR k = 0) AND k != 2 AND t >= 1900; +t k +DROP TABLE r; # # MDEV-24953: 10.5.9 crashes with large IN() list # @@ -232,12 +231,11 @@ drop table t1; # # MDEV-25069: Assertion `root->weight >= ...' failed in SEL_ARG::tree_delete #2 # -SELECT * -FROM mysql.help_relation -WHERE -(help_topic_id < '2' OR help_topic_id != 8 OR help_topic_id < 1) AND -help_keyword_id = help_topic_id; -help_topic_id help_keyword_id +CREATE TABLE r (t INT, k INT, PRIMARY KEY(k,t), KEY(t)); +INSERT INTO r VALUES (5,1), (5,2), (10,2), (16,2), (100,2), (400, 5), (300, 10), (600, 42) ; +SELECT * FROM r WHERE (t < '2' OR t != 8 OR t < 1) AND k = t; +t k +DROP TABLE r; # # MDEV-29242: Assertion `computed_weight == weight' failed SEL_ARG::verify_weight # diff --git a/mysql-test/main/range_notembedded.test b/mysql-test/main/range_notembedded.test index 2088be9bf2068..a41ecddc5cb84 100644 --- a/mysql-test/main/range_notembedded.test +++ b/mysql-test/main/range_notembedded.test @@ -104,13 +104,15 @@ drop table t1; --echo # --echo # MDEV-24739: Assertion `root->weight >= ...' failed in SEL_ARG::tree_delete --echo # -SELECT * -FROM mysql.help_relation -WHERE NOT (help_topic_id != 8 AND help_keyword_id != 0 OR help_keyword_id = 2 OR help_topic_id < 1900); -SELECT * -FROM mysql.help_relation ignore index (help_topic_id) -WHERE (help_topic_id = 8 OR help_keyword_id = 0) AND help_keyword_id != 2 AND help_topic_id >= 1900; +CREATE TABLE r (t INT, k INT, PRIMARY KEY(k,t), KEY(t)); +INSERT INTO r VALUES (5,1), (5,2), (10,2), (16,2), (100,2), (400, 5), (300, 10), (600, 42) ; + +SELECT * FROM r WHERE NOT (t != 8 AND k != 0 OR k = 2 OR t < 1900); + +SELECT * FROM r ignore index (t) WHERE (t = 8 OR k = 0) AND k != 2 AND t >= 1900; + +DROP TABLE r; --echo # --echo # MDEV-24953: 10.5.9 crashes with large IN() list @@ -148,11 +150,10 @@ drop table t1; --echo # MDEV-25069: Assertion `root->weight >= ...' failed in SEL_ARG::tree_delete #2 --echo # -SELECT * -FROM mysql.help_relation -WHERE - (help_topic_id < '2' OR help_topic_id != 8 OR help_topic_id < 1) AND - help_keyword_id = help_topic_id; +CREATE TABLE r (t INT, k INT, PRIMARY KEY(k,t), KEY(t)); +INSERT INTO r VALUES (5,1), (5,2), (10,2), (16,2), (100,2), (400, 5), (300, 10), (600, 42) ; +SELECT * FROM r WHERE (t < '2' OR t != 8 OR t < 1) AND k = t; +DROP TABLE r; --echo # --echo # MDEV-29242: Assertion `computed_weight == weight' failed SEL_ARG::verify_weight diff --git a/mysql-test/mariadb-test-run.pl b/mysql-test/mariadb-test-run.pl index 279168c4172cb..41249a8f29149 100755 --- a/mysql-test/mariadb-test-run.pl +++ b/mysql-test/mariadb-test-run.pl @@ -25,7 +25,7 @@ # Tool used for executing a suite of .test files # # See the "MySQL Test framework manual" for more information -# https://mariadb.com/kb/en/library/mysqltest/ +# https://mariadb.com/docs/server/clients-and-utilities/testing-tools/mariadb-test # # ############################################################################## diff --git a/mysql-test/suite/binlog/t/innodb_rc_insert_before_delete.test b/mysql-test/suite/binlog/t/innodb_rc_insert_before_delete.test index 228d9778f5667..bfd4c73149a56 100644 --- a/mysql-test/suite/binlog/t/innodb_rc_insert_before_delete.test +++ b/mysql-test/suite/binlog/t/innodb_rc_insert_before_delete.test @@ -9,7 +9,7 @@ RESET MASTER; # MDEV-30010 merely adds is a Read-Committed version MDEV-30225 test # solely to prove the RC isolation yields ROW binlog format as it is # supposed to: -# https://mariadb.com/kb/en/unsafe-statements-for-statement-based-replication/#isolation-levels. +# https://mariadb.com/docs/server/ha-and-performance/standard-replication/unsafe-statements-for-statement-based-replication # The original MDEV-30225 test is adapted to the RC to create # a similar safisticated scenario which does not lead to any deadlock though. diff --git a/mysql-test/suite/innodb_zip/r/innochecksum_2.result b/mysql-test/suite/innodb_zip/r/innochecksum_2.result index 0477abda54868..fc36803741dfe 100644 --- a/mysql-test/suite/innodb_zip/r/innochecksum_2.result +++ b/mysql-test/suite/innodb_zip/r/innochecksum_2.result @@ -50,12 +50,12 @@ Copyright (c) YEAR, YEAR , Oracle, MariaDB Corporation Ab and others. InnoDB offline file checksum utility. Usage: innochecksum [-c] [-r] [-s ] [-e ] [-p ] [-i] [-v] [-a ] [-n] [-S] [-D ] [-l ] [-l] [-m ] -See https://mariadb.com/kb/en/library/innochecksum/ for usage hints. +See https://mariadb.com/docs/server/clients-and-utilities/administrative-tools/innochecksum for usage hints. -?, --help Displays this help and exits. -I, --info Synonym for --help. -V, --version Displays version information and exits. -v, --verbose Verbose (prints progress every 5 seconds). - https://mariadb.com/kb/en/library/creating-a-trace-file/ + https://mariadb.com/docs/server/reference/product-development/mariadb-fault-finding -c, --count Print the count of pages in the file and exits. -s, --start-page=# Start on this page number (0 based). -e, --end-page=# End at this page number (0 based). diff --git a/mysys/my_largepage.c b/mysys/my_largepage.c index 5d8ae89ca60a4..66f45b8425d38 100644 --- a/mysys/my_largepage.c +++ b/mysys/my_largepage.c @@ -193,8 +193,9 @@ int my_init_large_pages(void) { my_printf_error(EE_PERM_LOCK_MEMORY, "Lock Pages in memory access rights required for use with" - " large-pages, see https://mariadb.com/kb/en/library/" - "mariadb-memory-allocation/#huge-pages", MYF(MY_WME)); + " large-pages, see " + "https://mariadb.com/docs/server/ha-and-performance/mariadb-memory-allocation#huge-pages" + , MYF(MY_WME)); my_use_large_pages= 0; } my_large_page_size= GetLargePageMinimum(); diff --git a/mysys/my_setuser.c b/mysys/my_setuser.c index e35d6602aca06..0133f5ddee1d8 100644 --- a/mysys/my_setuser.c +++ b/mysys/my_setuser.c @@ -37,8 +37,8 @@ struct passwd *my_check_user(const char *user, myf MyFlags) if (MyFlags & MY_FAE) { my_errno= EINVAL; - my_printf_error(my_errno, "Please consult the Knowledge Base to find " - "out how to run mysqld as root!", MYF(ME_ERROR_LOG)); + my_printf_error(my_errno, "Please consult the MariaDB Documentation to find " + "out how to run mariadbd as root!", MYF(ME_ERROR_LOG)); } DBUG_RETURN(NULL); } diff --git a/scripts/fill_help_tables.sql b/scripts/fill_help_tables.sql index 7deccd17a1e72..2e570b030d0b9 100644 --- a/scripts/fill_help_tables.sql +++ b/scripts/fill_help_tables.sql @@ -1,4 +1,3 @@ - -- Copyright (c) 2003, 2008-2012, Oracle and/or its affiliates. All rights reserved. -- -- This program is free software; you can redistribute it and/or modify @@ -32,1223 +31,3714 @@ delete from help_category; delete from help_keyword; delete from help_relation; -lock tables help_topic write, help_category write, help_keyword write, help_relation write; -insert into help_category (help_category_id,name,parent_category_id,url) values (1,'Contents',0,''); -insert into help_category (help_category_id,name,parent_category_id,url) values (2,'Polygon Properties',34,''); +insert into help_category (help_category_id,name,parent_category_id,url) values (1,'Geographic',0,''); +insert into help_category (help_category_id,name,parent_category_id,url) values (2,'Polygon properties',34,''); insert into help_category (help_category_id,name,parent_category_id,url) values (3,'WKT',34,''); -insert into help_category (help_category_id,name,parent_category_id,url) values (4,'Numeric Functions',37,''); -insert into help_category (help_category_id,name,parent_category_id,url) values (5,'Plugins',1,''); +insert into help_category (help_category_id,name,parent_category_id,url) values (4,'Numeric Functions',38,''); +insert into help_category (help_category_id,name,parent_category_id,url) values (5,'Plugins',35,''); insert into help_category (help_category_id,name,parent_category_id,url) values (6,'MBR',34,''); -insert into help_category (help_category_id,name,parent_category_id,url) values (7,'Control Flow Functions',37,''); -insert into help_category (help_category_id,name,parent_category_id,url) values (8,'Transactions',1,''); -insert into help_category (help_category_id,name,parent_category_id,url) values (9,'Help Metadata',1,''); -insert into help_category (help_category_id,name,parent_category_id,url) values (10,'Account Management',1,''); -insert into help_category (help_category_id,name,parent_category_id,url) values (11,'Point Properties',34,''); -insert into help_category (help_category_id,name,parent_category_id,url) values (12,'Encryption Functions',37,''); -insert into help_category (help_category_id,name,parent_category_id,url) values (13,'LineString Properties',34,''); -insert into help_category (help_category_id,name,parent_category_id,url) values (14,'Miscellaneous Functions',37,''); -insert into help_category (help_category_id,name,parent_category_id,url) values (15,'Logical Operators',47,''); -insert into help_category (help_category_id,name,parent_category_id,url) values (16,'Functions and Modifiers for Use with GROUP BY',1,''); -insert into help_category (help_category_id,name,parent_category_id,url) values (17,'Information Functions',37,''); -insert into help_category (help_category_id,name,parent_category_id,url) values (18,'Assignment Operators',47,''); -insert into help_category (help_category_id,name,parent_category_id,url) values (19,'Comparison Operators',47,''); -insert into help_category (help_category_id,name,parent_category_id,url) values (20,'Bit Functions',37,''); -insert into help_category (help_category_id,name,parent_category_id,url) values (21,'Table Maintenance',1,''); -insert into help_category (help_category_id,name,parent_category_id,url) values (22,'User-Defined Functions',1,''); -insert into help_category (help_category_id,name,parent_category_id,url) values (23,'Data Types',1,''); -insert into help_category (help_category_id,name,parent_category_id,url) values (24,'Compound Statements',1,''); -insert into help_category (help_category_id,name,parent_category_id,url) values (25,'Geometry Constructors',34,''); -insert into help_category (help_category_id,name,parent_category_id,url) values (26,'Administration',1,''); -insert into help_category (help_category_id,name,parent_category_id,url) values (27,'Data Manipulation',1,''); -insert into help_category (help_category_id,name,parent_category_id,url) values (28,'Utility',1,''); -insert into help_category (help_category_id,name,parent_category_id,url) values (29,'Language Structure',1,''); -insert into help_category (help_category_id,name,parent_category_id,url) values (30,'Geometry Relations',34,''); -insert into help_category (help_category_id,name,parent_category_id,url) values (31,'Date and Time Functions',37,''); +insert into help_category (help_category_id,name,parent_category_id,url) values (7,'Control flow functions',38,''); +insert into help_category (help_category_id,name,parent_category_id,url) values (8,'Transactions',35,''); +insert into help_category (help_category_id,name,parent_category_id,url) values (9,'Help Metadata',35,''); +insert into help_category (help_category_id,name,parent_category_id,url) values (10,'Account Management',35,''); +insert into help_category (help_category_id,name,parent_category_id,url) values (11,'Point properties',34,''); +insert into help_category (help_category_id,name,parent_category_id,url) values (12,'Encryption Functions',38,''); +insert into help_category (help_category_id,name,parent_category_id,url) values (13,'LineString properties',34,''); +insert into help_category (help_category_id,name,parent_category_id,url) values (14,'Miscellaneous Functions',38,''); +insert into help_category (help_category_id,name,parent_category_id,url) values (15,'Logical operators',38,''); +insert into help_category (help_category_id,name,parent_category_id,url) values (16,'Functions and Modifiers for Use with GROUP BY',35,''); +insert into help_category (help_category_id,name,parent_category_id,url) values (17,'Information Functions',38,''); +insert into help_category (help_category_id,name,parent_category_id,url) values (18,'Comparison operators',38,''); +insert into help_category (help_category_id,name,parent_category_id,url) values (19,'Bit Functions',38,''); +insert into help_category (help_category_id,name,parent_category_id,url) values (20,'Table Maintenance',35,''); +insert into help_category (help_category_id,name,parent_category_id,url) values (21,'User-Defined Functions',35,''); +insert into help_category (help_category_id,name,parent_category_id,url) values (22,'Data Types',35,''); +insert into help_category (help_category_id,name,parent_category_id,url) values (23,'Compound Statements',35,''); +insert into help_category (help_category_id,name,parent_category_id,url) values (24,'Geometry constructors',34,''); +insert into help_category (help_category_id,name,parent_category_id,url) values (25,'GeometryCollection properties',1,''); +insert into help_category (help_category_id,name,parent_category_id,url) values (26,'Administration',35,''); +insert into help_category (help_category_id,name,parent_category_id,url) values (27,'Data Manipulation',35,''); +insert into help_category (help_category_id,name,parent_category_id,url) values (28,'Utility',35,''); +insert into help_category (help_category_id,name,parent_category_id,url) values (29,'Language Structure',35,''); +insert into help_category (help_category_id,name,parent_category_id,url) values (30,'Geometry relations',34,''); +insert into help_category (help_category_id,name,parent_category_id,url) values (31,'Date and Time Functions',38,''); insert into help_category (help_category_id,name,parent_category_id,url) values (32,'WKB',34,''); -insert into help_category (help_category_id,name,parent_category_id,url) values (33,'Procedures',1,''); -insert into help_category (help_category_id,name,parent_category_id,url) values (34,'Geographic Features',1,''); -insert into help_category (help_category_id,name,parent_category_id,url) values (35,'Geometry Properties',34,''); -insert into help_category (help_category_id,name,parent_category_id,url) values (36,'String Functions',37,''); -insert into help_category (help_category_id,name,parent_category_id,url) values (37,'Functions',1,''); -insert into help_category (help_category_id,name,parent_category_id,url) values (38,'Data Definition',1,''); -insert into help_category (help_category_id,name,parent_category_id,url) values (39,'Sequences',1,''); -insert into help_category (help_category_id,name,parent_category_id,url) values (40,'JSON Functions',37,''); -insert into help_category (help_category_id,name,parent_category_id,url) values (41,'Window Functions',37,''); -insert into help_category (help_category_id,name,parent_category_id,url) values (42,'Spider Functions',37,''); -insert into help_category (help_category_id,name,parent_category_id,url) values (43,'Dynamic Column Functions',37,''); -insert into help_category (help_category_id,name,parent_category_id,url) values (44,'Galera Functions',37,''); -insert into help_category (help_category_id,name,parent_category_id,url) values (45,'Temporal Tables',1,''); -insert into help_category (help_category_id,name,parent_category_id,url) values (46,'GeoJSON',34,''); -insert into help_category (help_category_id,name,parent_category_id,url) values (47,'Operators',1,''); -insert into help_category (help_category_id,name,parent_category_id,url) values (48,'Arithmetic Operators',47,''); -insert into help_category (help_category_id,name,parent_category_id,url) values (49,'Replication',1,''); -insert into help_category (help_category_id,name,parent_category_id,url) values (50,'Prepared Statements',1,''); +insert into help_category (help_category_id,name,parent_category_id,url) values (33,'Procedures',35,''); +insert into help_category (help_category_id,name,parent_category_id,url) values (34,'Geographic Features',35,''); +insert into help_category (help_category_id,name,parent_category_id,url) values (35,'Contents',0,''); +insert into help_category (help_category_id,name,parent_category_id,url) values (36,'Geometry properties',34,''); +insert into help_category (help_category_id,name,parent_category_id,url) values (37,'String Functions',38,''); +insert into help_category (help_category_id,name,parent_category_id,url) values (38,'Functions',35,''); +insert into help_category (help_category_id,name,parent_category_id,url) values (39,'Data Definition',35,''); + +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (0, 22, 'AUTO\\_INCREMENT FAQ', 'Description\n-----------\n\nHow do I get the last inserted auto_increment value?\n\nUse the LAST_INSERT_ID() function:\n\n``sql\nSELECT LAST_INSERT_ID();\n`\n\nWhat if someone else inserts before I select my id?\n\nLAST_INSERT_ID() is connection specific, so there is no problem from race conditions.\n\nHow do I get the next value to be inserted?\n\nYou don''t. Insert, then find out what you did with LAST_INSERT_ID().\n\nHow do I change what number auto_increment starts with?\n\nRun a query, ALTER TABLE yourTable AUTO_INCREMENT = x; . The next insert will contain x or MAX(autoField) + 1, whichever is higher.\n\nAs an alternative, run INSERT INTO yourTable (autoField) VALUES (x); . The next insert will contain x+1 or MAX(autoField) + 1, whichever is higher.\n\nIssuing TRUNCATE TABLE will delete all the rows in the table, and will reset the auto_increment value to 0 in most cases.\n\nHow do I renumber rows once I deleted some in the middle?\n\nTypically, you don''t want to. Gaps are hardly ever a problem; if your application can''t handle gaps in the sequence, you probably should rethink your application.\n\nCan I do group-wise auto_increment?\n\nYes, if you use the MyISAM engine.\n\nHow do I get the AUTO_INCREMENT value in a BEFORE INSERT trigger?\n\nThis isn''t possible. It''s only available after insert.\n\nHow do I assign two fields the same auto_increment value in one query?\n\nYou can''t, not even with an AFTER INSERT trigger. Insert, then go back and update using LAST_INSERT_ID(). Those two statements could be wrapped into one stored procedure if you wish.\n\nHowever, you can mimic this behavior with a BEFORE INSERT trigger and a second table to store the sequence position:\n\n`sql\nCREATE TABLE sequence (table_name VARCHAR(255), position INT UNSIGNED);\nINSERT INTO sequence VALUES (''testTable'', 0);\nCREATE TABLE testTable (firstAuto INT UNSIGNED, secondAuto INT UNSIGNED);\nDELIMITER //\nCREATE TRIGGER testTable_BI BEFORE INSERT ON testTable FOR EACH ROW BEGIN\n UPDATE sequence SET position = LAST_INSERT_ID(position + 1) WHERE table_name = ''testTable'';\n SET NEW.firstAuto = LAST_INSERT_ID();\n SET NEW.secondAuto = LAST_INSERT_ID();\nEND//\nDELIMITER ;\nINSERT INTO testTable VALUES (NULL, NULL), (NULL, NULL);\nSELECT FROM testTable;\n\n+-----------+------------+\n| firstAuto | secondAuto |\n+-----------+------------+\n| 1 | 1 |\n| 2 | 2 |\n+-----------+------------+\n`\n\nThe same sequence table can maintain separate sequences for multiple tables (or separate sequences for different fields in the same table) by adding extra rows.\n\nDoes the auto_increment field have to be primary key?\n\nNo, it only has to be indexed. It doesn''t even have to be unique.\n\nHow does InnoDB handle AUTO_INCREMENT?\n\nSee AUTO_INCREMENT handling in InnoDB.\n\nGeneral Information To Read\n\nAUTO_INCREMENT\n\nManual Notes\n\nThere can be only one AUTO_INCREMENT column per table, it must be indexed, and it cannot have a DEFAULT value. An AUTO_INCREMENT column works properly only if it contains only positive values. Inserting a negative number is regarded as inserting a very large positive number. This is done to avoid precision problems when numbers wrap over from positive to negative and also to ensure that you do not accidentally get an AUTO_INCREMENT column that contains 0.\n\nHow to start a table with a set AUTO_INCREMENT value?\n\n`sql\nCREATE TABLE autoinc_test (\n h INT UNSIGNED PRIMARY KEY AUTO_INCREMENT, \n m INT UNSIGNED \n) AUTO_INCREMENT = 100;\n\nINSERT INTO autoinc_test ( m ) VALUES ( 1 );\n\nSELECT FROM autoinc_test;\n+-----+------+\n| h | m |\n+-----+------+\n| 100 | 1 |\n+-----+------+\n``\n\nURL: https://mariadb.com/docs/server/reference/data-types/auto_increment-faq', '', 'https://mariadb.com/docs/server/reference/data-types/auto_increment-faq'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (1, 22, 'AUTO\\_INCREMENT', 'Description\n-----------\n\nThe AUTO_INCREMENT attribute can be used to generate a unique identity for new rows. When you insert a new record into the table (or upon adding an AUTO_INCREMENT attribute with the ALTER TABLE statement), and the AUTO_INCREMENT field is NULL or DEFAULT (in the case of an INSERT), automatically be incremented. This also applies to 0, unless the NO_AUTO_VALUE_ON_ZERO SQL_MODE is enabled.\n\nAUTO_INCREMENT columns start from 1 by default. The automatically generated value can never be lower than 0.\n\nEach table can have only one AUTO_INCREMENT column. It must defined as a key (not necessarily the PRIMARY KEY or UNIQUE key). In some storage engines (including the default InnoDB), if the key consists of multiple columns, the AUTO_INCREMENT column must be the first column. Storage engines that permit the column to be placed elsewhere are Aria, MyISAM, MERGE, Spider, TokuDB, BLACKHOLE, FederatedX and Federated.\n\n``sql\nCREATE TABLE animals (\n id MEDIUMINT NOT NULL AUTO_INCREMENT,\n name CHAR(30) NOT NULL,\n PRIMARY KEY (id)\n );\n\nINSERT INTO animals (name) VALUES\n (''dog''),(''cat''),(''penguin''),\n (''fox''),(''whale''),(''ostrich'');\n`\n\n`sql\nSELECT FROM animals;\n+----+---------+\n| id | name |\n+----+---------+\n| 1 | dog |\n| 2 | cat |\n| 3 | penguin |\n| 4 | fox |\n| 5 | whale |\n| 6 | ostrich |\n+----+---------+\n`\n\nSERIAL is an alias for BIGINT UNSIGNED NOT NULL AUTO_INCREMENT UNIQUE.\n\n`sql\nCREATE TABLE t (id SERIAL, c CHAR(1)) ENGINE=InnoDB;\n\nSHOW CREATE TABLE t \\G\n*********************** 1. row ***********************\n Table: t\nCreate Table: CREATE TABLE t (\n id bigint(20) unsigned NOT NULL AUTO_INCREMENT,\n c char(1) DEFAULT NULL,\n UNIQUE KEY id (id)\n) ENGINE=InnoDB DEFAULT CHARSET=latin1\n`\n\nSetting or Changing the Auto_Increment Value\n\nYou can use an ALTER TABLE statement to assign a new value to the auto_increment table option, or set the insert_id server system variable to change the next AUTO_INCREMENT value inserted by the current session.\n\nLAST_INSERT_ID() can be used to see the last AUTO_INCREMENT value inserted by the current session.\n\n`sql\nALTER TABLE animals AUTO_INCREMENT=8;\n\nINSERT INTO animals (name) VALUES (''aardvark'');\n\nSELECT FROM animals;\n+----+-----------+\n| id | name |\n+----+-----------+\n| 1 | dog |\n| 2 | cat |\n| 3 | penguin |\n| 4 | fox |\n| 5 | whale |\n| 6 | ostrich |\n| 8 | aardvark |\n+----+-----------+\n\nSET insert_id=12;\n\nINSERT INTO animals (name) VALUES (''gorilla'');\n\nSELECT FROM animals;\n+----+-----------+\n| id | name |\n+----+-----------+\n| 1 | dog |\n| 2 | cat |\n| 3 | penguin |\n| 4 | fox |\n| 5 | whale |\n| 6 | ostrich |\n| 8 | aardvark |\n| 12 | gorilla |\n+----+-----------+\n`\n\nInnoDB\n\nAUTO_INCREMENT is persistent in InnoDB.\n\nSee also AUTO_INCREMENT Handling in InnoDB.\n\nSetting Explicit Values\n\nIt is possible to specify a value for an AUTO_INCREMENT column. If the key is primary or unique, the value must not already exist in the key.\n\nIf the new value is higher than the current maximum value, the AUTO_INCREMENT value is updated, so the next value will be higher. If the new value is lower than the current maximum value, the AUTO_INCREMENT value remains unchanged.\n\nThe following example demonstrates these behaviors:\n\n`sql\nCREATE TABLE t (id INTEGER UNSIGNED AUTO_INCREMENT PRIMARY KEY) ENGINE = InnoDB;\n\nINSERT INTO t VALUES (NULL);\nSELECT id FROM t;\n+----+\n| id |\n+----+\n| 1 |\n+----+\n\nINSERT INTO t VALUES (10); -- higher value\nSELECT id FROM t;\n+----+\n| id |\n+----+\n| 1 |\n| 10 |\n+----+\n\nINSERT INTO t VALUES (2); -- lower value\nINSERT INTO t VALUES (NULL); -- auto value\nSELECT id FROM t;\n+----+\n| id |\n+----+\n| 1 |\n| 2 |\n| 10 |\n| 11 |\n+----+\n`\n\nThe ARCHIVE storage engine does not allow to insert a value that is lower than the current maximum.\n\nMissing Values\n\nAn AUTO_INCREMENT column normally has missing values. This happens because if a row is deleted, or an AUTO_INCREMENT value is explicitly updated, old values are never re-used. The REPLACE statement also deletes a row, and its value is wasted. With InnoDB, values can be reserved by a transaction; but if the transaction fails (for example, because of a ROLLBACK) the reserved value will be lost.\n\nThus AUTO_INCREMENT values can be used to sort results in a chronological order, but not to create a numeric sequence.\n\nReplication\n\nTo make master-master or Galera safe to use AUTO_INCREMENT , you should use the system variables auto_increment_increment and auto_increment_offset to generate unique values for each server.\n\n`sql\nSET @@auto_increment_increment=3;\n\nSHOW VARIABLES LIKE ''auto_inc%'';\n+--------------------------+-------+\n| Variable_name | Value |\n+--------------------------+-------+\n| auto_increment_increment | 3 |\n| auto_increment_offset | 1 |\n+--------------------------+-------+\n\nCREATE TABLE t (c INT NOT NULL AUTO_INCREMENT PRIMARY KEY);\n\nINSERT INTO t VALUES (NULL), (NULL), (NULL);\n\nSELECT FROM t;\n+---+\n| c |\n+---+\n| 1 |\n| 4 |\n| 7 |\n+---+\n\nCREATE TABLE t2 (c INT NOT NULL AUTO_INCREMENT PRIMARY KEY);\n\nSET @@auto_increment_offset=2;\n\nSHOW VARIABLES LIKE ''auto_inc%'';\n+--------------------------+-------+\n| Variable_name | Value |\n+--------------------------+-------+\n| auto_increment_increment | 3 |\n| auto_increment_offset | 2 |\n+--------------------------+-------+\n\nINSERT INTO t2 VALUES (NULL), (NULL), (NULL);\n\nSELECT FROM t2;\n+---+\n| c |\n+---+\n| 2 |\n| 5 |\n| 8 |\n+---+\n`\n\nIf auto_increment_offset is larger than auto_increment_increment, the value of auto_increment_offset is ignored, and the offset reverts to the default of 1 instead:\n\n`sql\nSET @@auto_increment_offset=5;\n\nSHOW VARIABLES LIKE ''auto_inc%'';\n+--------------------------+-------+\n| Variable_name | Value |\n+--------------------------+-------+\n| auto_increment_increment | 3 |\n| auto_increment_offset | 5 |\n+--------------------------+-------+\n\nCREATE TABLE t3 (c INT NOT NULL AUTO_INCREMENT PRIMARY KEY);\n\nINSERT INTO t3 VALUES (NULL), (NULL), (NULL);\n\nSELECT FROM t3;\n+---+\n| c |\n+---+\n| 1 |\n| 4 |\n| 5 |\n+---+\n\n+--------------------------+-------+\n| Variable_name | Value |\n+--------------------------+-------+\n| auto_increment_increment | 3 |\n| auto_increment_offset | 3 |\n+--------------------------+-------+\n\nINSERT INTO t4 VALUES (NULL), (NULL), (NULL);\n\nSELECT FROM t4;\n+---+\n| c |\n+---+\n| 3 |\n| 6 |\n| 9 |\n+---+\n`\n\nChanging auto_increment_increment and auto_incremenet_offset when adding a new master to a multi-master setup\n\nThe purpose of auto_increment_increment and auto_increment_offset is to ensure that in a multi-master or multi-source setup, all masters generate unique values for auto_increment fields or for sequences with INCREMENT=0.\n\nIf auto_increment_increment is larger than the current number of masters, then one can configure the new master with the not used auto_increment_offset. The easiest way to add a new master is to stop all MariaDB servers, update auto_increment_increment and auto_increment_offset in the configuration files, and restart.\\\\\n\nThis has to be done if auto_increment_increment is 1. If one has more than one master (auto_increment_increment > 1), there is a way to add more masters with only having to restart one of the masters. The ''trick'' is to configure one of the masters to not use all the values in its current sequence.\n\nThe following example illustrates how to do it. Assume you have two masters, A and B.\n\nIn this case you will have auto_increment_increment=2 for both masters and A would have auto_increment_offset=1 and B would have auto_increment_offset=2. For A, all auto_increment and generated sequence values will be odd.\n\n`sql\n1\n3\n5\n7\n`\n\nFor B, all values will be even:\n\n`sql\n2\n4\n6\n8\n`\n\nSee the Replication section above.\n\nIf we change auto_increment_increment from 2 to 4 in A, it will now generate values from this sequence:\n\n`sql\n1\n5\n9\n13\n`\n\nAs you can see, values 3, 7, 11 are not going to be used.We can get C to use values from this sequence by configuring auto_increment_increment=4 and auto_increment_offset=3.\n\n`sql\n3\n7\n11\n`\n\nIf we would like to add a 4''th master (D), we can do that by changing ''B'' to use auto_increment_increment=4 and then configure D to have auto_increment_increment=4 and auto_increment_offset=4.\n\nNote that when changing the auto_increment_increment or auto_increment_offset on a server, you have to either restart the server or ensure that all current connections are killed. This is needed to force all connections to use the new values.\n\nAlso ensure that, if you want to use the above trick, you always double the value of auto_increment_increment. This is needed to ensure that the sequence used will not conflict with numbers generated by any other master.\n\nCHECK Constraints, DEFAULT Values and Virtual Columns\n\nAUTO_INCREMENT columns are not permitted in CHECK constraints, DEFAULT value expressions and virtual columns.\n\nGenerating Auto_Increment Values When Adding the Attribute\n\n`sql\nCREATE OR REPLACE TABLE t1 (a INT);\nINSERT t1 VALUES (0),(0),(0);\nALTER TABLE t1 MODIFY a INT NOT NULL AUTO_INCREMENT PRIMARY KEY;\nSELECT FROM t1;\n+---+\n| a |\n+---+\n| 1 |\n| 2 |\n| 3 |\n+---+\n`\n\n`sql\nCREATE OR REPLACE TABLE t1 (a INT);\nINSERT t1 VALUES (5),(0),(8),(0);\nALTER TABLE t1 MODIFY a INT NOT NULL AUTO_INCREMENT PRIMARY KEY;\nSELECT FROM t1;\n+---+\n| a |\n+---+\n| 5 |\n| 6 |\n| 8 |\n| 9 |\n+---+\n`\n\nIf the NO_AUTO_VALUE_ON_ZERO SQL_MODE is set, zero values will not be automatically incremented:\n\n`sql\nSET SQL_MODE=''no_auto_value_on_zero'';\nCREATE OR REPLACE TABLE t1 (a INT);\nINSERT t1 VALUES (3), (0);\nALTER TABLE t1 MODIFY a INT NOT NULL AUTO_INCREMENT PRIMARY KEY;\nSELECT FROM t1;\n+---+\n| a |\n+---+\n| 0 |\n| 3 |\n+---+\n``\n\nURL: https://mariadb.com/docs/server/reference/data-types/auto_increment', '', 'https://mariadb.com/docs/server/reference/data-types/auto_increment'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (2, 22, 'Data Type Storage Requirements', 'Description\n-----------\n\nThe following tables indicate the approximate data storage requirements for each data type.\n\nNumeric Data Types\n\n| Data Type | Storage Requirement |\n| -------------------------------------------- | ------------------------------------- |\n| TINYINT | 1 byte |\n| SMALLINT | 2 bytes |\n| MEDIUMINT | 3 bytes |\n| INT | 4 bytes |\n| BIGINT | 8 bytes |\n| FLOAT(p) | 4 bytes if p <= 24, otherwise 8 bytes |\n| DOUBLE | 8 bytes |\n| DECIMAL | See table below |\n| BIT(M) | (M+7)/8 bytes |\n\nNote that MEDIUMINT columns will require 4 bytes in memory (for example, in InnoDB buffer pool).\n\nDecimal\n\nDecimals are stored using a binary format, with the integer and the fraction stored separately. Each nine-digit multiple requires 4 bytes, followed by a number of bytes for whatever remains, as follows:\n\n| Remaining digits | Storage Requirement |\n| ---------------- | ------------------- |\n| 0 | 0 bytes |\n| 1 | 1 byte |\n| 2 | 1 byte |\n| 3 | 2 bytes |\n| 4 | 2 bytes |\n| 5 | 3 bytes |\n| 6 | 3 bytes |\n| 7 | 4 bytes |\n| 8 | 4 bytes |\n\nString Data Types\n\nIn the descriptions below, M is the declared column length (in characters or in bytes), while len is the actual length in bytes of the value.\n\n| Data Type | Storage Requirement |\n| -------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------- |\n| ENUM | 1 byte for up to 255 enum values, 2 bytes for 256 to 65,535 enum values |\n| CHAR(M) | M × w bytes, where w is the number of bytes required for the maximum-length character in the character set |\n| BINARY(M) | M bytes |\n| VARCHAR(M), VARBINARY(M) | len + 1 bytes if column is 0 – 255 bytes, len + 2 bytes if column may require more than 255 bytes |\n| TINYBLOB, TINYTEXT | len + 1 bytes |\n| BLOB, TEXT | len + 2 bytes |\n| MEDIUMBLOB, MEDIUMTEXT | len + 3 bytes |\n| LONGBLOB, LONGTEXT | len + 4 bytes |\n| XMLTYPE | len + 4 bytes (same as LONGBLOB) |\n| SET | Given M members of the set, (M+7)/8 bytes, rounded up to 1, 2, 3, 4, or 8 bytes |\n| INET6 | 16 bytes |\n| UUID | 16 bytes |\n\nNote: Introduced in MariaDB 12.3, the XMLTYPE data type has a maximum storage capacity of 4GB, similar to LONGBLOB_._\n\nIn some character sets, not all characters use the same number of bytes. utf8 encodes characters with one to three bytes per character, while utf8mb4 requires one to four bytes per character.\n\nWhen using field the COMPRESSED attribute, 1 byte is reserved for metadata. For example, VARCHAR(255) will use +2 bytes instead of +1.\n\nURL: https://mariadb.com/docs/server/reference/data-types/data-type-storage-requirements', '', 'https://mariadb.com/docs/server/reference/data-types/data-type-storage-requirements'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (3, 22, 'DATE', 'Syntax\n------\n\nDATE\n\nDescription\n-----------\n\nA date. The supported range is ''1000-01-01'' to ''9999-12-31''. MariaDB displays DATE values in ''YYYY-MM-DD'' format, but can be assigned dates in looser formats, including strings or numbers, as long as they make sense. These include a short year, YY-MM-DD, no delimiters, YYMMDD, or any other acceptable delimiter, for example YYYY/MM/DD. For details, see date and time literals.\n\n''0000-00-00'' is a permitted special value (zero-date), unless the NO_ZERO_DATE SQL_MODE is used. Also, individual components of a date can be set to 0 (for example: ''2015-00-12''), unless the NO_ZERO_IN_DATE SQL_MODE is used. In many cases, the result of en expression involving a zero-date, or a date with zero-parts, is NULL. If the ALLOW_INVALID_DATES SQL_MODE is enabled, if the day part is in the range between 1 and 31, the date does not produce any error, even for months that have less than 31 days.\n\nOracle Mode\n\nIn Oracle mode, DATE with a time portion is a synonym for DATETIME. See also mariadb_schema.\n\nExamples\n--------\n\nCREATE TABLE t1 (d DATE);\n\nINSERT INTO t1 VALUES ("2010-01-12"), ("2011-2-28"), (''120314''),(''130421'');\n\nSELECT * FROM t1;\n+------------+\n| d |\n+------------+\n| 2010-01-12 |\n| 2011-02-28 |\n| 2012-03-14 |\n| 2013-04-21 |\n+------------+\n\nURL: https://mariadb.com/docs/server/reference/data-types/date-and-time-data-types/date', '', 'https://mariadb.com/docs/server/reference/data-types/date-and-time-data-types/date'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (4, 22, 'DATETIME', 'Syntax\n------\n\nDATETIME [(microsecond precision)]\n\nDescription\n-----------\n\nA date and time combination.\n\nMariaDB displays DATETIME values in ''YYYY-MM-DD HH:MM:SS.ffffff'' format, but allows assignment of values to DATETIME columns using either strings or numbers. For details, see date and time literals.\n\nDATETIME columns also accept CURRENT_TIMESTAMP as the default value.\n\nThe --mysql56-temporal-format option, on by default, allows MariaDB to store DATETME values using the same low-level format MySQL 5.6 uses. For more information, see Internal Format, below.\n\nFor storage requirements, see Data Type Storage Requirements.\n\nSupported Values\n\nMariaDB stores values that use the DATETIME data type in a format that supports values between 1000-01-01 00:00:00.000000 and 9999-12-31 23:59:59.999999.\n\nMariaDB can also store microseconds with a precision between 0 and 6. If no microsecond precision is specified, then 0 is used by default.\n\nMariaDB also supports ''0000-00-00'' as a special _zero-date_ value, unless NO_ZERO_DATE is specified in the SQL_MODE. Similarly, individual components of a date can be set to 0 (for example: ''2015-00-12''), unless NO_ZERO_IN_DATE is specified in the SQL_MODE. In many cases, the result of en expression involving a zero-date, or a date with zero-parts, is NULL. If the ALLOW_INVALID_DATES SQL_MODE is enabled, if the day part is in the range between 1 and 31, the date does not produce any error, even for months that have less than 31 days.\n\nOracle Mode\n\nIn Oracle mode, DATE with a time portion is a synonym for DATETIME. See also mariadb_schema.\n\nInternal Format\n\nA new temporal format was introduced from MySQL 5.6 that alters how the TIME, DATETIME and TIMESTAMP columns operate at lower levels. These changes allow these temporal data types to have fractional parts and negative values. You can disable this feature using the mysql56_temporal_format system variable.\n\nTables that include TIMESTAMP values that were created on an older version of MariaDB or that were created while the mysql56_temporal_format system variable was disabled continue to store data using the older data type format.\n\nIn order to update table columns from the older format to the newer format, execute an ALTER TABLE... MODIFY COLUMN statement that changes the column to the _same_ data type. This change may be needed if you want to export the table''s tablespace and import it onto a server that has mysql56_temporal_format=ON set (see MDEV-15225).\n\nFor instance, if you have a DATETIME column in your table:\n\n``sql\nSHOW VARIABLES LIKE ''mysql56_temporal_format'';\n\n+-------------------------+-------+\n| Variable_name | Value |\n+-------------------------+-------+\n| mysql56_temporal_format | ON |\n+-------------------------+-------+\n\nALTER TABLE example_table MODIFY ts_col DATETIME;\n`\n\nWhen MariaDB executes the ALTER TABLE statement, it converts the data from the older temporal format to the newer one.\n\nIn the event that you have several tables and columns using temporal data types that you want to switch over to the new format, make sure the system variable is enabled, then perform a dump and restore using mysqldump. The columns using relevant temporal data types are restored using the new temporal format.\n\nColumns with old temporal formats are marked with a / mariadb-5.3 / comment in the output of SHOW CREATE TABLE, SHOW COLUMNS, DESCRIBE statements, as well as in the COLUMN_TYPE column of the INFORMATION_SCHEMA.COLUMNS Table.\n\n`sql\nSHOW CREATE TABLE mariadb5312_datetime\\G\n************************ 1. row ***********************\n Table: mariadb5312_datetime\nCreate Table: CREATE TABLE mariadb5312_datetime (\n dt0 datetime / mariadb-5.3 / DEFAULT NULL,\n dt6 datetime(6) / mariadb-5.3 / DEFAULT NULL\n) ENGINE=MyISAM DEFAULT CHARSET=latin1\n``\n\nExamples\n--------\n\nCREATE TABLE t1 (d DATETIME);\n\nINSERT INTO t1 VALUES ("2011-03-11"), ("2012-04-19 13:08:22"),\n ("2013-07-18 13:44:22.123456");\n\nSELECT FROM t1;\n+---------------------+\n| d |\n+---------------------+\n| 2011-03-11 00:00:00 |\n| 2012-04-19 13:08:22 |\n| 2013-07-18 13:44:22 |\n+---------------------+\n\nURL: https://mariadb.com/docs/server/reference/data-types/date-and-time-data-types/datetime', '', 'https://mariadb.com/docs/server/reference/data-types/date-and-time-data-types/datetime'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (5, 22, 'SQL\\_TSI\\_YEAR', 'Description\n-----------\n\nSee YEAR.\n\nExamples\n--------\n\nCREATE TABLE sql_tsi_year_example (\n example SQL_TSI_YEAR\n);\n\nURL: https://mariadb.com/docs/server/reference/data-types/date-and-time-data-types/sql_tsi_year', '', 'https://mariadb.com/docs/server/reference/data-types/date-and-time-data-types/sql_tsi_year'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (6, 22, 'TIME', 'Syntax\n------\n\nTIME [()]\n\nDescription\n-----------\n\nA time. The range is ''-838:59:59.999999'' to ''838:59:59.999999''. Microsecond precision can be from 0-6; if not specified 0 is used.\n\nMariaDB displays TIME values in ''HH:MM:SS.ssssss'' format, but allows assignment of times in looser formats, including ''D HH:MM:SS'', ''HH:MM:SS'', ''HH:MM'', ''D HH:MM'', ''D HH'', ''SS'', or ''HHMMSS'', as well as permitting dropping of any leading zeros when a delimiter is provided, for example ''3:9:10''. For details, see date and time literals.\n\nThe --mysql56-temporal-format option, on by default, allows MariaDB to store TIME values using the same low-level format MySQL 5.6 uses.\n\nInternal Format\n\nA new temporal format was introduced from MySQL 5.6 that alters how the TIME, DATETIME and TIMESTAMP columns operate at lower levels. These changes allow these temporal data types to have fractional parts and negative values. You can disable this feature using the mysql56_temporal_format system variable.\n\nTables that include TIMESTAMP values that were created on an older version of MariaDB or that were created while the mysql56_temporal_format system variable was disabled continue to store data using the older data type format.\n\nIn order to update table columns from the older format to the newer format, execute an ALTER TABLE... MODIFY COLUMN statement that changes the column to the _same_ data type. This change may be needed if you want to export the table''s tablespace and import it onto a server that has mysql56_temporal_format=ON set (see MDEV-15225).\n\nFor instance, if you have a TIME column in your table:\n\n``sql\nSHOW VARIABLES LIKE ''mysql56_temporal_format'';\n\n+-------------------------+-------+\n| Variable_name | Value |\n+-------------------------+-------+\n| mysql56_temporal_format | ON |\n+-------------------------+-------+\n\nALTER TABLE example_table MODIFY ts_col TIME;\n`\n\nWhen MariaDB executes the ALTER TABLE statement, it converts the data from the older temporal format to the newer one.\n\nIn the event that you have several tables and columns using temporal data types that you want to switch over to the new format, make sure the system variable is enabled, then perform a dump and restore using mariadb-dump. The columns using relevant temporal data types are restored using the new temporal format.\n\nColumns with old temporal formats are marked with a / mariadb-5.3 / comment in the output of SHOW CREATE TABLE, SHOW COLUMNS, DESCRIBE statements, as well as in the COLUMN_TYPE column of the INFORMATION_SCHEMA.COLUMNS Table.\n\n`sql\nSHOW CREATE TABLE mariadb5312_time\\G\n************************ 1. row ***********************\n Table: mariadb5312_time\nCreate Table: CREATE TABLE mariadb5312_time (\n t0 time / mariadb-5.3 / DEFAULT NULL,\n t6 time(6) / mariadb-5.3 / DEFAULT NULL\n) ENGINE=MyISAM DEFAULT CHARSET=latin1\n``\n\nColumns with the current format are not marked with a comment.\n\nExamples\n--------\n\nINSERT INTO time VALUES (''90:00:00''), (''800:00:00''), (800), (22), (151413), (''9:6:3''), (''12 09'');\n\nSELECT FROM time;\n+-----------+\n| t |\n+-----------+\n| 90:00:00 |\n| 800:00:00 |\n| 00:08:00 |\n| 00:00:22 |\n| 15:14:13 |\n| 09:06:03 |\n| 297:00:00 |\n+-----------+\n\nURL: https://mariadb.com/docs/server/reference/data-types/date-and-time-data-types/time', '', 'https://mariadb.com/docs/server/reference/data-types/date-and-time-data-types/time'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (7, 22, 'TIMESTAMP', 'Syntax\n------\n\nTIMESTAMP [(, >=, <=, <, or != cannot be used, as any comparison with a NULL always returns a NULL value, never true (1) or false (0).\n\n`sql\nSELECT NULL = NULL;\n+-------------+\n| NULL = NULL |\n+-------------+\n| NULL |\n+-------------+\n\nSELECT 99 = NULL;\n+-----------+\n| 99 = NULL |\n+-----------+\n| NULL |\n+-----------+\n`\n\nTo overcome this, certain operators are specifically designed for use with NULL values. To cater for testing equality between two values that may contain NULL values, there''s <=>, NULL-safe equal.\n\n`sql\nSELECT 99 <=> NULL, NULL <=> NULL;\n+-------------+---------------+\n| 99 <=> NULL | NULL <=> NULL |\n+-------------+---------------+\n| 0 | 1 |\n+-------------+---------------+\n`\n\nOther operators for working with NULL values include IS NULL and IS NOT NULL, ISNULL (for testing an expression) and COALESCE (for returning the first non-NULL parameter).\n\nOrdering\n\nWhen you order by a field that may contain NULL values, any NULL values are considered to have the lowest value. So ordering in DESC order will see the NULL values appearing last. To force NULL values to be regarded as highest values, one can add another column which has a higher value when the main field is NULL. Example:\n\n`sql\nSELECT col1 FROM tab ORDER BY ISNULL(col1), col1;\n`\n\nDescending order, with NULL values first:\n\n`sql\nSELECT col1 FROM tab ORDER BY IF(col1 IS NULL, 0, 1), col1 DESC;\n`\n\nAll NULL values are also regarded as equivalent for the purposes of the DISTINCT and GROUP BY clauses.\n\nFunctions\n\nIn most cases, functions will return NULL if any of the parameters are NULL. There are also functions specifically for handling NULL values. These include IFNULL(), NULLIF() and COALESCE().\n\n`sql\nSELECT IFNULL(1,0); \n+-------------+\n| IFNULL(1,0) |\n+-------------+\n| 1 |\n+-------------+\n\nSELECT IFNULL(NULL,10);\n+-----------------+\n| IFNULL(NULL,10) |\n+-----------------+\n| 10 |\n+-----------------+\n\nSELECT COALESCE(NULL,NULL,1);\n+-----------------------+\n| COALESCE(NULL,NULL,1) |\n+-----------------------+\n| 1 |\n+-----------------------+\n`\n\nAggregate functions, such as SUM and AVG ignore NULL values.\n\n`sql\nCREATE TABLE t(x INT);\n\nINSERT INTO t VALUES (1),(9),(NULL);\n\nSELECT SUM(x) FROM t;\n+--------+\n| SUM(x) |\n+--------+\n| 10 |\n+--------+\n\nSELECT AVG(x) FROM t;\n+--------+\n| AVG(x) |\n+--------+\n| 5.0000 |\n+--------+\n`\n\nThe one exception is COUNT(\\), which counts rows, and doesn''t look at whether a value is NULL or not. Compare for example, COUNT(x), which ignores the NULL, and COUNT(), which counts it:\n\n`sql\nSELECT COUNT(x) FROM t;\n+----------+\n| COUNT(x) |\n+----------+\n| 2 |\n+----------+\n\nSELECT COUNT() FROM t;\n+----------+\n| COUNT() |\n+----------+\n| 3 |\n+----------+\n`\n\nAUTO_INCREMENT, TIMESTAMP and Virtual Columns\n\nMariaDB handles NULL values in a special way if the field is an AUTO_INCREMENT, a TIMESTAMP or a virtual column. Inserting a NULL value into a numeric AUTO_INCREMENT column will result in the next number in the auto increment sequence being inserted instead. This technique is frequently used with AUTO_INCREMENT fields, which are left to take care of themselves.\n\n`sql\nCREATE TABLE t2(id INT PRIMARY KEY AUTO_INCREMENT, letter CHAR(1));\n\nINSERT INTO t2(letter) VALUES (''a''),(''b'');\n\nSELECT FROM t2;\n+----+--------+\n| id | letter |\n+----+--------+\n| 1 | a |\n| 2 | b |\n+----+--------+\n`\n\nSimilarly, if a NULL value is assigned to a TIMESTAMP field, the current date and time is assigned instead.\n\n`sql\nCREATE TABLE t3 (x INT, ts TIMESTAMP);\n\nINSERT INTO t3(x) VALUES (1),(2);\n`\n\nAfter a pause:\n\n`sql\nINSERT INTO t3(x) VALUES (3);\n\nSELECT FROM t3;\n+------+---------------------+\n| x | ts |\n+------+---------------------+\n| 1 | 2013-09-05 10:14:18 |\n| 2 | 2013-09-05 10:14:18 |\n| 3 | 2013-09-05 10:14:29 |\n+------+---------------------+\n`\n\nIf a NULL is assigned to a VIRTUAL or PERSISTENT column, the default value is assigned instead.\n\n`sql\nCREATE TABLE virt (c INT, v INT AS (c+10) PERSISTENT) ENGINE=InnoDB;\n\nINSERT INTO virt VALUES (1, NULL);\n\nSELECT c, v FROM virt;\n+------+------+\n| c | v |\n+------+------+\n| 1 | 11 |\n+------+------+\n`\n\nIn all these special cases, NULL is equivalent to the DEFAULT keyword.\n\nInserting\n\nIf a NULL value is single-row inserted into a column declared as NOT NULL, an error will be returned. However, if the SQL mode is not strict (strict is the default), if a NULL value is multi-row inserted into a column declared as NOT NULL, the implicit default for the column type will be inserted (and NOT` the default value in the table definition). The implicit defaults are an empty string for string types, and the zero value for numeric, date and time types.\n\nBy default, both cases will result in an error.\n\nExamples\n--------\n\nCREATE TABLE nulltest (\n a INT(11), \n x VARCHAR(10) NOT NULL DEFAULT ''a'', \n y INT(11) NOT NULL DEFAULT 23\n);\n\nURL: https://mariadb.com/docs/server/reference/data-types/null-values', '', 'https://mariadb.com/docs/server/reference/data-types/null-values'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (10, 22, 'BIGINT', 'Syntax\n------\n\nBIGINT[(M)] [SIGNED | UNSIGNED | ZEROFILL]\n\nDescription\n-----------\n\nA large integer. The signed range is -9223372036854775808 to9223372036854775807. The unsigned range is 0 to18446744073709551615.\n\nIf a column has been set to ZEROFILL, all values will be prepended by zeros so that the BIGINT value contains a number of M digits.\n\nNote: If the ZEROFILL attribute has been specified, the column will automatically become UNSIGNED.\n\nFor more details on the attributes, see Numeric Data Type Overview.\n\nSERIAL is an alias for:\n\n``sql\nBIGINT UNSIGNED NOT NULL AUTO_INCREMENT UNIQUE\n`\n\nINT8 is a synonym for BIGINT`.\n\nExamples\n--------\n\nCREATE TABLE bigints (a BIGINT,b BIGINT UNSIGNED,c BIGINT ZEROFILL);\n\nINSERT INTO bigints VALUES (-10,-10,-10);\nERROR 1264 (22003): Out of range value for column ''b'' at row 1\n\nINSERT INTO bigints VALUES (-10,10,-10);\nERROR 1264 (22003): Out of range value for column ''c'' at row 1\n\nINSERT INTO bigints VALUES (-10,10,10);\n\nINSERT INTO bigints VALUES (9223372036854775808,9223372036854775808,9223372036854775808);\nERROR 1264 (22003): Out of range value for column ''a'' at row 1\n\nINSERT INTO bigints VALUES (9223372036854775807,9223372036854775808,9223372036854775808);\n\nSELECT * FROM bigints;\n+---------------------+---------------------+----------------------+\n| a | b | c |\n+---------------------+---------------------+----------------------+\n| -10 | 10 | 00000000000000000010 |\n| 9223372036854775807 | 9223372036854775808 | 09223372036854775808 |\n+---------------------+---------------------+----------------------+\n\nURL: https://mariadb.com/docs/server/reference/data-types/numeric-data-types/bigint', '', 'https://mariadb.com/docs/server/reference/data-types/numeric-data-types/bigint'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (11, 22, 'BIT', 'Syntax\n------\n\nBIT[(M)]\n\nDescription\n-----------\n\nA bit-field type. M indicates the number of bits per value, from 1 to64. The default is 1 if M is omitted.\n\nBit values can be inserted with b''value'' notation, where value is the bit value in 0''s and 1''s.\n\nBit fields are automatically zero-padded from the left to the full length of the bit, so for example in a BIT(4) field, ''10'' is equivalent to ''0010''.\n\nBits are returned as binary, so to display them, either add 0, or use a function such as HEX, OCT or BIN to convert them.\n\nExamples\n--------\n\nCREATE TABLE bit_example (\n description VARCHAR(20),\n b1 BIT,\n b4 BIT(4),\n b16 BIT(16)\n);\n\nURL: https://mariadb.com/docs/server/reference/data-types/numeric-data-types/bit', '', 'https://mariadb.com/docs/server/reference/data-types/numeric-data-types/bit'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (12, 22, 'BOOL', 'Description\n-----------\n\nSee TINYINT.\n\nExamples\n--------\n\nCREATE TABLE bool_example (\n example BOOL\n) DEFAULT CHARSET=latin1;\n\nURL: https://mariadb.com/docs/server/reference/data-types/numeric-data-types/bool', '', 'https://mariadb.com/docs/server/reference/data-types/numeric-data-types/bool'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (13, 22, 'BOOLEAN', 'Syntax\n------\n\nBOOL, BOOLEAN\n\nDescription\n-----------\n\nThese types are synonyms for TINYINT(1). A value of zero is considered false. Non-zero values are considered true.\n\nHowever, the values TRUE and FALSE are merely aliases for 1 and 0. See Boolean Literals, as well as the IS operator for testing values against a boolean.\n\nExamples\n--------\n\nCREATE TABLE boolean_example (\n example BOOLEAN\n);\n\nURL: https://mariadb.com/docs/server/reference/data-types/numeric-data-types/boolean', '', 'https://mariadb.com/docs/server/reference/data-types/numeric-data-types/boolean'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (14, 22, 'DEC, NUMERIC, FIXED', 'Syntax\n------\n\nDEC[(M[,D])] [SIGNED | UNSIGNED | ZEROFILL]\n\nNUMERIC[(M[,D])] [SIGNED | UNSIGNED | ZEROFILL]\n\nFIXED[(M[,D])] [SIGNED | UNSIGNED | ZEROFILL]\n\nDescription\n-----------\n\nThese types are synonyms for DECIMAL. The FIXED synonym is available for compatibility with other database systems.\n\nURL: https://mariadb.com/docs/server/reference/data-types/numeric-data-types/dec-numeric-fixed', '', 'https://mariadb.com/docs/server/reference/data-types/numeric-data-types/dec-numeric-fixed'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (15, 22, 'DECIMAL', 'Syntax\n------\n\nDECIMAL[(M[,D])] [SIGNED | UNSIGNED | ZEROFILL]\n\nDescription\n-----------\n\nA packed "exact" fixed-point number. M is the total number of digits (the precision), and D is the number of digits after the decimal point (the scale).\n\n The decimal point and (for negative numbers) the "-" sign are not counted in M.\n If D is 0, values have no decimal point or fractional part, and on INSERT, the value will be rounded to the nearest DECIMAL.\n The maximum number of digits (M) for DECIMAL is 65.\n The maximum number of supported decimals (D) is 30 before MariadB 10.2.1 and 38 afterwards.\n If D is omitted, the default is 0. If M is omitted, the default is 10.\n\nUNSIGNED, if specified, disallows negative values.\n\nZEROFILL, if specified, pads the number with zeros, up to the total number of digits specified by M.\n\nAll basic calculations (+, -, \\, /) with DECIMAL columns are done with a precision of 65 digits.\n\nFor more details on the attributes, see Numeric Data Type Overview.\n\nDEC, NUMERIC, and FIXED are synonyms, as well as NUMBER in Oracle mode.\n\nExamples\n--------\n\nCREATE TABLE t1 (d DECIMAL UNSIGNED ZEROFILL);\n\nINSERT INTO t1 VALUES (1),(2),(3),(4.0),(5.2),(5.7);\nQuery OK, 6 rows affected, 2 warnings (0.16 sec)\nRecords: 6 Duplicates: 0 Warnings: 2\n\nNote (sql 1265): Data truncated for column ''d'' at row 5\nNote (sql 1265): Data truncated for column ''d'' at row 6\n\nSELECT * FROM t1;\n+------------+\n| d |\n+------------+\n| 0000000001 |\n| 0000000002 |\n| 0000000003 |\n| 0000000004 |\n| 0000000005 |\n| 0000000006 |\n+------------+\n\nURL: https://mariadb.com/docs/server/reference/data-types/numeric-data-types/decimal', '', 'https://mariadb.com/docs/server/reference/data-types/numeric-data-types/decimal'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (16, 22, 'DOUBLE PRECISION', 'Syntax\n------\n\nDOUBLE PRECISION[(M,D)] [SIGNED | UNSIGNED | ZEROFILL]\nREAL[(M,D)] [SIGNED | UNSIGNED | ZEROFILL]\n\nDescription\n-----------\n\nREAL and DOUBLE PRECISION are synonyms for DOUBLE.\n\nException: If the REAL_AS_FLOAT SQL mode is enabled, REAL is a synonym for FLOAT rather than DOUBLE.\n\nExamples\n--------\n\nCREATE TABLE double_precision_example (\n example DOUBLE PRECISION\n);\n\nURL: https://mariadb.com/docs/server/reference/data-types/numeric-data-types/double-precision', '', 'https://mariadb.com/docs/server/reference/data-types/numeric-data-types/double-precision'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (17, 22, 'DOUBLE', 'Syntax\n------\n\nDOUBLE[(M,D)] [SIGNED | UNSIGNED | ZEROFILL]\nDOUBLE PRECISION[(M,D)] [SIGNED | UNSIGNED | ZEROFILL]\nREAL[(M,D)] [SIGNED | UNSIGNED | ZEROFILL]\n\nDescription\n-----------\n\nA normal-size (double-precision) floating-point number (see FLOAT for a single-precision floating-point number). Allowable values are:\n\n -1.7976931348623157E+308 to -2.2250738585072014E-308\n 0\n 2.2250738585072014E-308 to 1.7976931348623157E+308\n\nThese are the theoretical limits, based on the IEEE standard. The actual range might be slightly smaller depending on your hardware or operating system.\n\nM is the total number of digits and D is the number of digits following the decimal point. If M and D are omitted, values are stored to the limits allowed by the hardware. A double-precision floating-point number is accurate to approximately 15 decimal places.\n\nUNSIGNED, if specified, disallows negative values.\n\nZEROFILL, if specified, pads the number with zeros, up to the total number of digits specified by M.\n\nREAL and DOUBLE PRECISION are synonyms, unless the REAL_AS_FLOAT SQL mode is enabled, in which case REAL is a synonym for FLOAT rather than DOUBLE.\n\nSee Floating Point Accuracy for issues when using floating-point numbers.\n\nFor more details on the attributes, see Numeric Data Type Overview.\n\nExamples\n--------\n\nCREATE TABLE t1 (d DOUBLE(5,0) zerofill);\n\nINSERT INTO t1 VALUES (1),(2),(3),(4);\n\nSELECT FROM t1;\n+-------+\n| d |\n+-------+\n| 00001 |\n| 00002 |\n| 00003 |\n| 00004 |\n+-------+\n\nURL: https://mariadb.com/docs/server/reference/data-types/numeric-data-types/double', '', 'https://mariadb.com/docs/server/reference/data-types/numeric-data-types/double'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (18, 22, 'FIXED', 'Description\n-----------\n\nSee DECIMAL.\n\nExamples\n--------\n\nCREATE TABLE fixed_example (\n example FIXED\n);\n\nURL: https://mariadb.com/docs/server/reference/data-types/numeric-data-types/fixed', '', 'https://mariadb.com/docs/server/reference/data-types/numeric-data-types/fixed'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (19, 22, 'FLOAT', 'Syntax\n------\n\nFLOAT[(M,D)] [SIGNED | UNSIGNED | ZEROFILL]\n\nDescription\n-----------\n\nA small (single-precision) floating-point number (see DOUBLE for a regular-size floating point number). Allowable values are:\n\n -3.402823466E+38 to -1.175494351E-38\n 0\n* 1.175494351E-38 to 3.402823466E+38.\n\nThese are the theoretical limits, based on the IEEE standard. The actual range might be slightly smaller depending on your hardware or operating system.\n\nM is the total number of digits and D is the number of digits following the decimal point. If M and D are omitted, values are stored to the limits allowed by the hardware. A single-precision floating-point number is accurate to approximately 7 decimal places.\n\nUNSIGNED, if specified, disallows negative values.\n\nUsing FLOAT might give you some unexpected problems because all calculations in MariaDB are done with double precision. See Floating Point Accuracy.\n\nFor more details on the attributes, see Numeric Data Type Overview.\n\nExamples\n--------\n\nCREATE TABLE float_signed_example (\n description VARCHAR(20),\n example FLOAT,\n sz6_2 FLOAT(6,2),\n sz20_19 FLOAT(20,19) SIGNED\n);\n\nURL: https://mariadb.com/docs/server/reference/data-types/numeric-data-types/float', '', 'https://mariadb.com/docs/server/reference/data-types/numeric-data-types/float'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (20, 22, 'FLOAT4', 'Description\n-----------\n\nSee FLOAT.\n\nExamples\n--------\n\nCREATE TABLE float4_example (\n example FLOAT4\n);\n\nURL: https://mariadb.com/docs/server/reference/data-types/numeric-data-types/float4', '', 'https://mariadb.com/docs/server/reference/data-types/numeric-data-types/float4'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (21, 22, 'FLOAT8', 'Description\n-----------\n\nSee DOUBLE.\n\nExamples\n--------\n\nCREATE TABLE float8_example (\n example FLOAT8\n);\n\nURL: https://mariadb.com/docs/server/reference/data-types/numeric-data-types/float8', '', 'https://mariadb.com/docs/server/reference/data-types/numeric-data-types/float8'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (22, 22, 'Floating-point Accuracy', 'Description\n-----------\n\nDue to their nature, not all floating-point numbers can be stored with exact precision. Hardware architecture, the CPU or even the compiler version and optimization level may affect the precision.\n\nIf you are comparing DOUBLEs or FLOATs with numeric decimals, it is not safe to use the equality operator.\n\nSometimes, changing a floating-point number from single-precision (FLOAT) to double-precision (DOUBLE) will fix the problem.\n\nExamples\n--------\n\nCREATE TABLE fpn (id INT, f1 FLOAT, f2 DOUBLE, f3 DECIMAL (10,3));\nINSERT INTO fpn VALUES (1,2,2,2),(2,0.1,0.1,0.1);\n\nSELECT FROM fpn WHERE f1f1 = f2*f2;\n+------+------+------+-------+\n| id | f1 | f2 | f3 |\n+------+------+------+-------+\n| 1 | 2 | 2 | 2.000 |\n+------+------+------+-------+\n\nURL: https://mariadb.com/docs/server/reference/data-types/numeric-data-types/floating-point-accuracy', '', 'https://mariadb.com/docs/server/reference/data-types/numeric-data-types/floating-point-accuracy'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (23, 22, 'INT', 'Syntax\n------\n\nINT[(M)] [SIGNED | UNSIGNED | ZEROFILL]\nINTEGER[(M)] [SIGNED | UNSIGNED | ZEROFILL]\n\nDescription\n-----------\n\nA normal-size integer. When marked UNSIGNED, it ranges from 0 to 4294967295, otherwise its range is -2147483648 to 2147483647 (SIGNED is the default). If a column has been set to ZEROFILL, all values will be prepended by zeros so that the INT value contains a number of M digits. INTEGER is a synonym for INT.\n\nNote: If the ZEROFILL attribute has been specified, the column will automatically become UNSIGNED.\n\nINT4 is a synonym for INT.\n\nFor details on the attributes, see Numeric Data Type Overview.\n\nExamples\n--------\n\nCREATE TABLE ints (a INT,b INT UNSIGNED,c INT ZEROFILL);\n\nURL: https://mariadb.com/docs/server/reference/data-types/numeric-data-types/int', '', 'https://mariadb.com/docs/server/reference/data-types/numeric-data-types/int'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (24, 22, 'INT1', 'Description\n-----------\n\nINT1 is a synonym for TINYINT.\n\n``sql\nCREATE TABLE t1 (x INT1);\n\nDESC t1;\n+-------+------------+------+-----+---------+-------+\n| Field | Type | Null | Key | Default | Extra |\n+-------+------------+------+-----+---------+-------+\n| x | tinyint(4) | YES | | NULL | |\n+-------+------------+------+-----+---------+-------+\n``\n\nExamples\n--------\n\nCREATE TABLE int1_example (\n example INT1\n);\n\nURL: https://mariadb.com/docs/server/reference/data-types/numeric-data-types/int1', '', 'https://mariadb.com/docs/server/reference/data-types/numeric-data-types/int1'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (25, 22, 'INT2', 'Description\n-----------\n\nINT2 is a synonym for SMALLINT.\n\n``sql\nCREATE TABLE t1 (x INT2);\n\nDESC t1;\n+-------+-------------+------+-----+---------+-------+\n| Field | Type | Null | Key | Default | Extra |\n+-------+-------------+------+-----+---------+-------+\n| x | smallint(6) | YES | | NULL | |\n+-------+-------------+------+-----+---------+-------+\n``\n\nExamples\n--------\n\nCREATE TABLE int2_example (\n example INT2\n);\n\nURL: https://mariadb.com/docs/server/reference/data-types/numeric-data-types/int2', '', 'https://mariadb.com/docs/server/reference/data-types/numeric-data-types/int2'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (26, 22, 'INT3', 'Description\n-----------\n\nINT3 is a synonym for MEDIUMINT.\n\n``sql\nCREATE TABLE t1 (x INT3);\n\nDESC t1;\n+-------+--------------+------+-----+---------+-------+\n| Field | Type | Null | Key | Default | Extra |\n+-------+--------------+------+-----+---------+-------+\n| x | mediumint(9) | YES | | NULL | |\n+-------+--------------+------+-----+---------+-------+\n``\n\nExamples\n--------\n\nCREATE TABLE int3_example (\n example INT3\n);\n\nURL: https://mariadb.com/docs/server/reference/data-types/numeric-data-types/int3', '', 'https://mariadb.com/docs/server/reference/data-types/numeric-data-types/int3'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (27, 22, 'INT4', 'Description\n-----------\n\nINT4 is a synonym for INT.\n\n``sql\nCREATE TABLE t1 (x INT4);\n\nDESC t1;\n+-------+---------+------+-----+---------+-------+\n| Field | Type | Null | Key | Default | Extra |\n+-------+---------+------+-----+---------+-------+\n| x | int(11) | YES | | NULL | |\n+-------+---------+------+-----+---------+-------+\n``\n\nExamples\n--------\n\nCREATE TABLE int4_example (\n example INT4\n);\n\nURL: https://mariadb.com/docs/server/reference/data-types/numeric-data-types/int4', '', 'https://mariadb.com/docs/server/reference/data-types/numeric-data-types/int4'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (28, 22, 'INT8', 'Description\n-----------\n\nINT8 is a synonym for BIGINT.\n\n``sql\nCREATE TABLE t1 (x INT8);\n\nDESC t1;\n+-------+------------+------+-----+---------+-------+\n| Field | Type | Null | Key | Default | Extra |\n+-------+------------+------+-----+---------+-------+\n| x | bigint(20) | YES | | NULL | |\n+-------+------------+------+-----+---------+-------+\n``\n\nExamples\n--------\n\nCREATE TABLE int8_example (\n example INT8\n);\n\nURL: https://mariadb.com/docs/server/reference/data-types/numeric-data-types/int8', '', 'https://mariadb.com/docs/server/reference/data-types/numeric-data-types/int8'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (29, 22, 'INTEGER', 'Syntax\n------\n\nINTEGER[(M)] [SIGNED | UNSIGNED | ZEROFILL]\n\nDescription\n-----------\n\nThis type is a synonym for INT.\n\nExamples\n--------\n\nCREATE TABLE integer_example (\n example INTEGER\n);\n\nURL: https://mariadb.com/docs/server/reference/data-types/numeric-data-types/integer', '', 'https://mariadb.com/docs/server/reference/data-types/numeric-data-types/integer'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (30, 22, 'MEDIUMINT', 'Syntax\n------\n\nMEDIUMINT[(M)] [SIGNED | UNSIGNED | ZEROFILL]\n\nDescription\n-----------\n\nA medium-sized integer. The signed range is -8388608 to 8388607. The unsigned range is 0 to 16777215.\n\nZEROFILL pads the integer with zeroes and assumes UNSIGNED (even if UNSIGNED is not specified).\n\nINT3 is a synonym for MEDIUMINT.\n\nFor details on the attributes, see Numeric Data Type Overview.\n\nExamples\n--------\n\nCREATE TABLE mediumints (a MEDIUMINT,b MEDIUMINT UNSIGNED,c MEDIUMINT ZEROFILL);\n\nDESCRIBE mediumints;\n+-------+--------------------------------+------+-----+---------+-------+\n| Field | Type | Null | Key | Default | Extra |\n+-------+--------------------------------+------+-----+---------+-------+\n| a | mediumint(9) | YES | | NULL | |\n| b | mediumint(8) unsigned | YES | | NULL | |\n| c | mediumint(8) unsigned zerofill | YES | | NULL | |\n+-------+--------------------------------+------+-----+---------+-------+\n\nURL: https://mariadb.com/docs/server/reference/data-types/numeric-data-types/mediumint', '', 'https://mariadb.com/docs/server/reference/data-types/numeric-data-types/mediumint'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (31, 22, 'MIDDLEINT', 'Description\n-----------\n\nSee MEDIUMINT.\n\nExamples\n--------\n\nCREATE TABLE middleint_example (\n example MIDDLEINT\n);\n\nURL: https://mariadb.com/docs/server/reference/data-types/numeric-data-types/middleint', '', 'https://mariadb.com/docs/server/reference/data-types/numeric-data-types/middleint'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (32, 22, 'NUMBER', 'Description\n-----------\n\n``sql\nNUMBER[(M[,D])] [SIGNED | UNSIGNED | ZEROFILL]\n`\n\nIn Oracle mode, NUMBER` is a synonym for DECIMAL.\n\nExamples\n--------\n\nSET sql_mode=''oracle'';\n\nURL: https://mariadb.com/docs/server/reference/data-types/numeric-data-types/number', '', 'https://mariadb.com/docs/server/reference/data-types/numeric-data-types/number'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (33, 22, 'Numeric Data Type Overview', 'Description\n-----------\n\nThere are a number of numeric data types:\n\n BOOLEAN - Synonym for TINYINT(1)\n INT1 - Synonym for TINYINT\n INT2 - Synonym for SMALLINT\n INT3 - Synonym for MEDIUMINT\n INT, INTEGER\n INT4 - Synonym for INT\n INT8 - Synonym for BIGINT\n TINYINT\n SMALLINT\n MEDIUMINT\n BIGINT\n DECIMAL, DEC, NUMERIC, FIXED\n FLOAT\n DOUBLE, DOUBLE PRECISION, REAL\n BIT\n VECTOR\n\nSee the specific articles for detailed information on each.\n\nSIGNED, UNSIGNED and ZEROFILL\n\nMost numeric types can be defined as SIGNED, UNSIGNED or ZEROFILL, for example:\n\n``sql\nTINYINT[(M)] [SIGNED | UNSIGNED | ZEROFILL]\n`\n\nIf SIGNED, or no attribute, is specified, a portion of the numeric type will be reserved for the sign (plus or minus). For example, a TINYINT SIGNED can range from -128 to 127.\n\nIf UNSIGNED is specified, no portion of the numeric type is reserved for the sign, so for integer types range can be larger. For example, a TINYINT UNSIGNED can range from 0 to 255. Floating point and fixed-point types also can be UNSIGNED, but this only prevents negative values from being stored and doesn''t alter the range.\n\nIf ZEROFILL is specified, the column will be set to UNSIGNED and the spaces used by default to pad the field are replaced with zeros. ZEROFILL is ignored in expressions or as part of a UNION. ZEROFILL is a non-standard MySQL and MariaDB enhancement.\n\nNote that although the preferred syntax indicates that the attributes are exclusive, more than one attribute can be specified.\n\nOnly the following combinations are supported:\n\n SIGNED\n UNSIGNED\n ZEROFILL\n UNSIGNED ZEROFILL\n ZEROFILL UNSIGNED\n\nThe latter two should be replaced with simply ZEROFILL`, but are still accepted by the parser.\n\nExamples\n--------\n\nCREATE TABLE zf (\n i1 TINYINT SIGNED,\n i2 TINYINT UNSIGNED,\n i3 TINYINT ZEROFILL\n);\n\nINSERT INTO zf VALUES (2,2,2);\n\nSELECT FROM zf;\n+------+------+------+\n| i1 | i2 | i3 |\n+------+------+------+\n| 2 | 2 | 002 |\n+------+------+------+\n\nURL: https://mariadb.com/docs/server/reference/data-types/numeric-data-types/numeric-data-type-overview', '', 'https://mariadb.com/docs/server/reference/data-types/numeric-data-types/numeric-data-type-overview'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (34, 22, 'DEC', 'Description\n-----------\n\nSee DECIMAL.\n\nExamples\n--------\n\nCREATE TABLE dec_example (\n example DEC\n);\n\nURL: https://mariadb.com/docs/server/reference/data-types/numeric-data-types/numeric-data-types-dec', '', 'https://mariadb.com/docs/server/reference/data-types/numeric-data-types/numeric-data-types-dec'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (35, 22, 'NUMERIC', 'Description\n-----------\n\nSee DECIMAL.\n\nExamples\n--------\n\nCREATE TABLE numeric_example (\n example NUMERIC\n);\n\nURL: https://mariadb.com/docs/server/reference/data-types/numeric-data-types/numeric', '', 'https://mariadb.com/docs/server/reference/data-types/numeric-data-types/numeric'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (36, 22, 'REAL', 'Description\n-----------\n\nSee DOUBLE.\n\nExamples\n--------\n\nCREATE TABLE real_example (\n example REAL\n);\n\nURL: https://mariadb.com/docs/server/reference/data-types/numeric-data-types/real', '', 'https://mariadb.com/docs/server/reference/data-types/numeric-data-types/real'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (37, 22, 'SMALLINT', 'Syntax\n------\n\nSMALLINT[(M)] [SIGNED | UNSIGNED | ZEROFILL]\n\nDescription\n-----------\n\nA small integer. The signed range is -32768 to 32767. The unsigned range is 0 to 65535.\n\nIf a column has been set to ZEROFILL, all values will be prepended by zeros so that the SMALLINT value contains a number of M digits.\n\nNote:\n\nIf the ZEROFILL attribute has been specified, the column will automatically become UNSIGNED.\n\nINT2 is a synonym for SMALLINT.\n\nFor more details on the attributes, see Numeric Data Type Overview.\n\nExamples\n--------\n\nCREATE TABLE smallints (a SMALLINT,b SMALLINT UNSIGNED,c SMALLINT ZEROFILL);\n\nURL: https://mariadb.com/docs/server/reference/data-types/numeric-data-types/smallint', '', 'https://mariadb.com/docs/server/reference/data-types/numeric-data-types/smallint'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (38, 22, 'TINYINT', 'Syntax\n------\n\nTINYINT[(M)] [SIGNED | UNSIGNED | ZEROFILL]\n\nDescription\n-----------\n\nA very small integer. The signed range is -128 to 127. The unsigned range is 0 to 255. For details on the attributes, see Numeric Data Type Overview.\n\nINT1, BOOL, and BOOLEAN are synonyms for TINYINT.\n\nExamples\n--------\n\nCREATE TABLE tinyints (a TINYINT,b TINYINT UNSIGNED,c TINYINT ZEROFILL);\n\nURL: https://mariadb.com/docs/server/reference/data-types/numeric-data-types/tinyint', '', 'https://mariadb.com/docs/server/reference/data-types/numeric-data-types/tinyint'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (39, 22, 'VECTOR', 'Syntax\n------\n\nVECTOR(N)\n\nDescription\n-----------\n\nThe VECTOR data type was added as part of the vectors feature, which permits MariaDB Server to perform as a relational vector database. N represents the fixed number of dimensions of the vector up to a maximum of 16383. The N dimension will be determined by the embedding algorithm.\n\nExamples\n--------\n\nCREATE TABLE t1 (id INT AUTO_INCREMENT PRIMARY KEY, v VECTOR(5) NOT NULL,\n VECTOR INDEX (v));\n\nURL: https://mariadb.com/docs/server/reference/data-types/numeric-data-types/vector', '', 'https://mariadb.com/docs/server/reference/data-types/numeric-data-types/vector'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (40, 22, 'ROW TYPE OF', 'Description\n-----------\n\nThis is special declaration only available inside a stored procedure.\n\nExamples\n--------\n\nCREATE TABLE rowtypeof_table(\n descr VARCHAR(20),\n val INT\n);\n\nURL: https://mariadb.com/docs/server/reference/data-types/row-type-of', '', 'https://mariadb.com/docs/server/reference/data-types/row-type-of'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (41, 22, 'SERIAL', 'Description\n-----------\n\nThis is an alias for BIGINT UNSIGNED NOT NULL AUTO_INCREMENT UNIQUE.\n\nExamples\n--------\n\nCREATE TABLE serial_example (\n id SERIAL,\n data VARCHAR(32)\n);\n\nURL: https://mariadb.com/docs/server/reference/data-types/serial', '', 'https://mariadb.com/docs/server/reference/data-types/serial'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (42, 22, 'BINARY', 'Description\n-----------\n\nThe BINARY type is similar to the CHAR type, but stores binary byte strings rather than non-binary character strings. M represents the column length in bytes.\n\nIt contains no character set, and comparison and sorting are based on the numeric value of the bytes.\n\nIf the maximum length is exceeded, and SQL strict mode is not enabled , the extra characters will be dropped with a warning. If strict mode is enabled, an error will occur.\n\nBINARY values are right-padded with 0x00 (the zero byte) to the specified length when inserted. The padding is _not_ removed on select, so this needs to be taken into account when sorting and comparing, where all bytes are significant. The zero byte, 0x00 is less than a space for comparison purposes.\n\nUse Cases for Zero Length\n\nA BINARY(0) or VARBINARY(0) column is restricted to an empty byte string or NULL.\n\n Schema Preservation: Use these columns when a system expects a specific column to exist, but no data storage is required for your current application.\n Space-Efficient Indicators: These columns can act as a two-state indicator where the presence of an empty byte string represents one state and NULL represents another.\n\nIf you attempt to insert a value other than an empty string, MariaDB returns an ERROR 1406 (22001) indicating the data is too long for the column.\n\nExamples\n--------\n\nCREATE TABLE bins (a BINARY(10));\n\nINSERT INTO bins VALUES(''12345678901'');\nQuery OK, 1 row affected, 1 warning (0.04 sec)\n\nSELECT * FROM bins;\n+------------+\n| a |\n+------------+\n| 1234567890 |\n+------------+\n\nSET sql_mode=''STRICT_ALL_TABLES'';\n\nINSERT INTO bins VALUES(''12345678901'');\nERROR 1406 (22001): Data too long for column ''a'' at row 1\n\nURL: https://mariadb.com/docs/server/reference/data-types/string-data-types/binary', '', 'https://mariadb.com/docs/server/reference/data-types/string-data-types/binary'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (43, 22, 'BLOB and TEXT Data Types', 'Description\n-----------\n\nA BLOB is a binary large object that can hold a variable amount of data. The four BLOB types are\n\n TINYBLOB,\n BLOB,\n MEDIUMBLOB, and\n LONGBLOB.\n\nThese differ only in the maximum length of the values they can hold.\n\nThe TEXT types are\n\n TINYTEXT,\n TEXT,\n MEDIUMTEXT, and\n LONGTEXT.\n JSON (alias for LONGTEXT)\n\nThese correspond to the four BLOB types and have the same maximum lengths and storage requirements.\n\nBLOB and TEXT columns can have a DEFAULT value.\n\nIt is possible to set a unique index on columns that use the BLOB or TEXT data types.\n\nHandling Large Data via APIs\n\nWhen working with very large BLOB or TEXT values, the data may exceed the limit set by the max_allowed_packet system variable. To avoid this—and to reduce memory consumption on the client—most MariaDB connectors allow you to "stream" data in chunks.\n\n Connector/C: Use mysql_stmt_send_long_data() to send parameter data in pieces before calling mysql_stmt_execute(). This bypasses max_allowed_packet limits and reduces the peak memory footprint (RSS) of the application.\n Connector/J: Use PreparedStatement.setBinaryStream() (for BLOB) or PreparedStatement.setCharacterStream() (for TEXT).\n Protocol: These APIs utilize the COM_STMT_SEND_LONG_DATA command, which appends data to a parameter on the server side.\n\nTechnical Rules for C/C++\n\n 0-Based Indexing: Parameter numbering starts at 0.\n The is_null Flag: This must be 0; if set to nonzero, the server may discard the streamed data.\n Resetting: Use mysql_stmt_reset() to clear all accumulated long data on the server if you need to abort or retry.\n Chunk Size: A practical performance "sweet spot" is between 64 KB and 1 MB per chunk.\n\nURL: https://mariadb.com/docs/server/reference/data-types/string-data-types/blob-and-text-data-types', '', 'https://mariadb.com/docs/server/reference/data-types/string-data-types/blob-and-text-data-types'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (44, 22, 'BLOB', 'Syntax\n------\n\nBLOB[(M)]\n\nDescription\n-----------\n\nIf you are handling large binary data that exceeds the max_allowed_packet limit, you can stream the data in chunks using specialized API functions like mysql_stmt_send_long_data() or setBinaryStream(). See Handling Large Data via APIs for more details.\n\nA BLOB column with a maximum length of 65,535 (2¹⁶ - 1) bytes. Each BLOB value is stored using a two-byte length prefix that indicates the number of bytes in the value.\n\nAn optional length M can be given for this type. If this is done, MariaDB creates the column as the smallest BLOB type large enough to hold values _M_ bytes long.\n\nBLOB values can also be used to store dynamic columns.\n\nBLOB and TEXT columns can both be assigned a DEFAULT value.\n\nIndexing\n\nOn a column that uses the BLOB data type, setting a unique index is now possible.\n\nNote\n\nIn previous releases, setting a unique index on a column that uses the BLOB data type was not possible. Index would only guarantee the uniqueness of a fixed number of characters.\n\nOracle Mode\n\nIn Oracle mode, BLOB is a synonym for LONGBLOB.\n\nExamples\n--------\n\nCREATE TABLE blob_example (\n description VARCHAR(20),\n example BLOB\n) DEFAULT CHARSET=latin1; -- One byte per char makes the examples clearer\n\nURL: https://mariadb.com/docs/server/reference/data-types/string-data-types/blob', '', 'https://mariadb.com/docs/server/reference/data-types/string-data-types/blob'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (45, 22, 'CHAR BYTE', 'Description\n-----------\n\nThe CHAR BYTE data type is an alias for the BINARY data type. This is a compatibility feature.\n\nExamples\n--------\n\nCREATE TABLE char_byte_example (\n example CHAR BYTE\n);\n\nURL: https://mariadb.com/docs/server/reference/data-types/string-data-types/char-byte', '', 'https://mariadb.com/docs/server/reference/data-types/string-data-types/char-byte'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (46, 22, 'CHAR VARYING', 'Description\n-----------\n\nThis is a synonym for VARCHAR.\n\nExamples\n--------\n\nCREATE TABLE char_varying_example (\n example CHAR VARYING(32)\n);\n\nURL: https://mariadb.com/docs/server/reference/data-types/string-data-types/char-varying', '', 'https://mariadb.com/docs/server/reference/data-types/string-data-types/char-varying'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (47, 22, 'CHAR', 'Syntax\n------\n\n[NATIONAL] CHAR[(M)] [CHARACTER SET charset_name] [COLLATE collation_name]\n\nDescription\n-----------\n\nA fixed-length string that is always right-padded with spaces to the specified length when stored. M represents the column length in characters. The range of M is 0 to 255. If M is omitted, the length is 1.\n\nTrailing spaces are removed when CHAR values are retrieved unless the PAD_CHAR_TO_FULL_LENGTH SQL mode is enabled.\n\nIf a unique index consists of a column where trailing pad characters are stripped or ignored, inserts into that column where values differ only by the number of trailing pad characters will result in a duplicate-key error.\n\nCHAR(0) columns can contain 2 values: an empty string or NULL. Such columns cannot be part of an index. The CONNECT storage engine does not support CHAR(0).\n\nUse Cases for Zero Length\n\nA CHAR(0) or VARCHAR(0) column occupies minimal space and is restricted to two possible values: an empty string ('''') or NULL. You can use these columns for the following purposes:\n\n Legacy Compatibility: Include these columns to maintain compatibility with older applications that require a specific table schema, even if the data is no longer collected.\n Two-State Flags: A CHAR(0) NULL column can function as a boolean indicator. It uses only one bit of storage to distinguish between a "set" state (the empty string) and an "unset" state (NULL).\n* Row Marking: You can use a CHAR(0) column to mark a specific row in a table. For example, if you require only one "active" row, set that row to an empty string while keeping all other rows NULL.\n\nThe following error occurs if you attempt to insert any character data into a 0-length column: ERROR 1406 (22001): Data too long for column.\n\nExamples\n--------\n\nCREATE TABLE strtest (c CHAR(10));\nINSERT INTO strtest VALUES(''Maria '');\n\nSELECT c=''Maria'',c=''Maria '' FROM strtest;\n+-----------+--------------+\n| c=''Maria'' | c=''Maria '' |\n+-----------+--------------+\n| 1 | 1 |\n+-----------+--------------+\n\nSELECT c LIKE ''Maria'',c LIKE ''Maria '' FROM strtest;\n+----------------+-------------------+\n| c LIKE ''Maria'' | c LIKE ''Maria '' |\n+----------------+-------------------+\n| 1 | 0 |\n+----------------+-------------------+\n\nURL: https://mariadb.com/docs/server/reference/data-types/string-data-types/char', '', 'https://mariadb.com/docs/server/reference/data-types/string-data-types/char'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (48, 22, 'Character Set and Collation Overview', 'Description\n-----------\n\nWhat are Character Sets and Collations?\n\nA character set is a set of characters, while a collation comprises the rules for comparing and sorting a particular character set.\n\nFor example, a subset of a character set could consist of the letters A, B and C. A default collation could define these as appearing in an ascending order of A, B, C.\n\nIf we consider different case characters, more complexity is added. A binary collation would evaluate the characters A and a differently, ordering them in a particular way. A case-insensitive collation would evaluate A and a equivalently, while the German phone book collation evaluates the characters ue and ü equivalently.\n\nA character set can have many collations associated with it, while each collation is only associated with one character set. In MariaDB, the character set name is always part of the collation name. For example, the latin1_german1_ci collation applies only to the latin1 character set. Each character set also has one default collation. The latin1 default collation is latin1_swedish_ci.\n\nAs an example, by default, the character y comes between x and z, while in Lithuanian, it''s sorted between i and k. Similarly, the German phone book order is different to the German dictionary order, so while they share the same character set, the collation is different.\n\nViewing Character Sets and Collations\n\nThe default character set is utf8mb4 and the default collation is utf8mb4_uca1400_ai_ci.\\\nThis may differ in some distros, see for example Differences in MariaDB in Debian.\n\nThe default character set is latin1 and the default collation is latin1_swedish_ci.\\\nThis may differ in some distros, see for example Differences in MariaDB in Debian.\n\nYou can view a full list of character sets and collations supported by MariaDB at Supported Character Sets and Collations, or see what''s supported on your server with the SHOW CHARACTER SET and SHOW COLLATION commands.\n\nBy default, A comes before Z, so the following evaluates to true:\n\n``sql\nSELECT "A" < "Z";\n+-----------+\n| "A" < "Z" |\n+-----------+\n| 1 |\n+-----------+\n`\n\nBy default, comparisons are case-insensitive:\n\n`sql\nSELECT "A" < "a", "A" = "a";\n+-----------+-----------+\n| "A" < "a" | "A" = "a" |\n+-----------+-----------+\n| 0 | 1 |\n+-----------+-----------+\n`\n\nChanging Character Sets and Collations\n\nCharacter sets and collations can be set from the server level right down to the column level, as well as for client-server communication.\n\nFor example, ue and ü are by default evaluated differently.\n\n`sql\nSELECT ''Mueller'' = ''Müller'';\n+----------------------+\n| ''Müller'' = ''Mueller'' |\n+----------------------+\n| 0 |\n+----------------------+\n`\n\nBy using the collation_connection system variable to change the connection character set to latin1_german2_ci, or German phone book, the same two characters will evaluate as equivalent.\n\n`sql\nSET collation_connection = latin1_german2_ci;\n\nSELECT ''Mueller'' = ''Müller'';\n+-----------------------+\n| ''Mueller'' = ''Müller'' |\n+-----------------------+\n| 1 |\n+-----------------------+\n``\n\nSee Setting Character Sets and Collations for more.\n\nURL: https://mariadb.com/docs/server/reference/data-types/string-data-types/character-sets/character-set-and-collation-overview', '', 'https://mariadb.com/docs/server/reference/data-types/string-data-types/character-sets/character-set-and-collation-overview'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (49, 22, 'Coordinated Universal Time', 'Description\n-----------\n\nUTC stands for Coordinated Universal Time. It is the world standard for regulating time.\n\nMariaDB stores values internally in UTC, converting them to the required time zone as required.\n\nIn general terms it is equivalent to Greenwich Mean Time (GMT), but UTC is used in technical contexts, as it is precisely defined at the subsecond level.\n\nTime zones are offset relative to UTC. For example, time in Tonga is UTC + 13, so 03h00 UTC is 16h00 in Tonga.\n\nURL: https://mariadb.com/docs/server/reference/data-types/string-data-types/character-sets/internationalization-and-localization/coordinated-universal-time', '', 'https://mariadb.com/docs/server/reference/data-types/string-data-types/character-sets/internationalization-and-localization/coordinated-universal-time'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (50, 22, 'Locales Plugin', 'Description\n-----------\n\nThe LOCALES plugin creates the LOCALES table in the INFORMATION_SCHEMA database. The plugin also adds the SHOW LOCALES statement.The table and statement can be queried to see all locales that are compiled into the server.\n\nInstalling the Plugin\n\nAlthough the plugin''s shared library is distributed with MariaDB by default, the plugin is not actually installed by MariaDB by default. There are two methods that can be used to install the plugin with MariaDB.\n\nThe first method can be used to install the plugin without restarting the server. You can install the plugin dynamically by executing INSTALL SONAME or INSTALL PLUGIN. For example:\n\n``sql\nINSTALL SONAME ''locales'';\n`\n\nThe second method can be used to tell the server to load the plugin when it starts up. The plugin can be installed this way by providing the --plugin-load or the --plugin-load-add options. This can be specified as a command-line argument to mysqld or it can be specified in a relevant server option group in an option file. For example:\n\n`sql\n[mariadb]\n...\nplugin_load_add = locales\n`\n\nUninstalling the Plugin\n\nYou can uninstall the plugin dynamically by executing UNINSTALL SONAME or UNINSTALL PLUGIN. For example:\n\n`sql\nUNINSTALL SONAME ''locales'';\n``\n\nIf you installed the plugin by providing the --plugin-load or the --plugin-load-add options in a relevant server option group in an option file, then those options should be removed to prevent the plugin from being loaded the next time the server is restarted.\n\nExamples\n--------\n\nSELECT * FROM INFORMATION_SCHEMA.LOCALES;\n+-----+-------+-------------------------------------+-----------------------+---------------------+---------------+--------------+------------------------+\n| ID | NAME | DESCRIPTION | MAX_MONTH_NAME_LENGTH | MAX_DAY_NAME_LENGTH | DECIMAL_POINT | THOUSAND_SEP | ERROR_MESSAGE_LANGUAGE |\n+-----+-------+-------------------------------------+-----------------------+---------------------+---------------+--------------+------------------------+\n| 0 | en_US | English - United States | 9 | 9 | . | , | english |\n| 1 | en_GB | English - United Kingdom | 9 | 9 | . | , | english |\n| 2 | ja_JP | Japanese - Japan | 3 | 3 | . | , | japanese |\n| 3 | sv_SE | Swedish - Sweden | 9 | 7 | , | | swedish |\n| 4 | de_DE | German - Germany | 9 | 10 | , | . | german |\n| 5 | fr_FR | French - France | 9 | 8 | , | | french |\n| 6 | ar_AE | Arabic - United Arab Emirates | 6 | 8 | . | , | english |\n| 7 | ar_BH | Arabic - Bahrain | 6 | 8 | . | , | english |\n| 8 | ar_JO | Arabic - Jordan | 12 | 8 | . | , | english |\n...\n| 106 | no_NO | Norwegian - Norway | 9 | 7 | , | . | norwegian |\n| 107 | sv_FI | Swedish - Finland | 9 | 7 | , | | swedish |\n| 108 | zh_HK | Chinese - Hong Kong SAR | 3 | 3 | . | , | english |\n| 109 | el_GR | Greek - Greece | 11 | 9 | , | . | greek |\n| 110 | rm_CH | Romansh - Switzerland | 9 | 9 | , | . | english |\n+-----+-------+-------------------------------------+-----------------------+---------------------+---------------+--------------+------------------------+\n\nURL: https://mariadb.com/docs/server/reference/data-types/string-data-types/character-sets/internationalization-and-localization/locales-plugin', '', 'https://mariadb.com/docs/server/reference/data-types/string-data-types/character-sets/internationalization-and-localization/locales-plugin'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (51, 22, 'Server Locale', 'Description\n-----------\n\nThe lc_time_names server system variable sets the language used by the date and time functions DAYNAME(), MONTHNAME(), and DATE_FORMAT(), and the lc_messages sets the language for error messages.\n\nThe list of the locales supported by the current MariaDB installation can be obtained via the LOCALES plugin.\n\nMariaDB supports the following locale values:\n\n| Locale | Language | Territory |\n| ------ | ----------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| ar_AE | Arabic | United Arab Emirates |\n| ar_BH | Arabic | Bahrain |\n| ar_DZ | Arabic | Algeria |\n| ar_EG | Arabic | Egypt |\n| ar_IN | Arabic | Iran |\n| ar_IQ | Arabic | Iraq |\n| ar_JO | Arabic | Jordan |\n| ar_KW | Arabic | Kuwait |\n| ar_LB | Arabic | Lebanon |\n| ar_LY | Arabic | Libya |\n| ar_MA | Arabic | Morocco |\n| ar_OM | Arabic | Oman |\n| ar_QA | Arabic | Qatar |\n| ar_SA | Arabic | Saudi Arabia |\n| ar_SD | Arabic | Sudan |\n| ar_SY | Arabic | Syria |\n| ar_TN | Arabic | Tunisia |\n| ar_YE | Arabic | Yemen |\n| be_BY | Belarusian | Belarus |\n| bg_BG | Bulgarian | Bulgaria |\n| ca_ES | Catalan | Catalan |\n| cs_CZ | Czech | Czech Republic |\n| da_DK | Danish | Denmark |\n| de_AT | German | Austria |\n| de_BE | German | Belgium |\n| de_CH | German | Switzerland |\n| de_DE | German | Germany |\n| de_LU | German | Luxembourg |\n| el_GR | Greek | Greece |\n| en_AU | English | Australia |\n| en_CA | English | Canada |\n| en_GB | English | United Kingdom |\n| en_IN | English | India |\n| en_NZ | English | New Zealand |\n| en_PH | English | Philippines |\n| en_US | English | United States |\n| en_ZA | English | South Africa |\n| en_ZW | English | Zimbabwe |\n| es_AR | Spanish | Argentina |\n| es_BO | Spanish | Bolivia |\n| es_CL | Spanish | Chile |\n| es_CO | Spanish | Columbia |\n| es_CR | Spanish | Costa Rica |\n| es_DO | Spanish | Dominican Republic |\n| es_EC | Spanish | Ecuador |\n| es_ES | Spanish | Spain |\n| es_GT | Spanish | Guatemala |\n| es_HN | Spanish | Honduras |\n| es_MX | Spanish | Mexico |\n| es_NI | Spanish | Ni\n\n[Truncated — full content at mariadb.com/docs]', '', 'https://mariadb.com/docs/server/reference/data-types/string-data-types/character-sets/internationalization-and-localization/server-locale'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (52, 22, 'Setting the Language for Error Messages', 'Description\n-----------\n\nMariaDB server error messages are by default in English. However, MariaDB server also supports error message localization in many different languages. Each supported language has its own version of the error message file called errmsg.sys in a dedicated directory for that language.\n\nSupported Languages for Error Messages\n\nError message localization is supported for the following languages:\n\n Bulgarian\n Chinese (from MariaDB 10.4.25, 10.5.16, 10.6.8, 10.7.4, 10.8.3)\n Czech\n Danish\n Dutch\n English\n Estonian\n French\n Georgian (from MariaDB 10.11.3)\n German\n Greek\n Hindi\n Hungarian\n Italian\n Japanese\n Korean\n Norwegian\n Norwegian-ny (Nynorsk)\n Polish\n Portuguese\n Romanian\n Russian\n Serbian\n Slovak\n Spanish\n Swahili (from MariaDB 11.1.2)\n Swedish\n Ukrainian\n\nSetting the lc_messages and lc_messages_dir System Variables\n\nThe lc_messages and lc_messages_dir system variables can be used to set the server locale used for error messages.\n\nThe lc_messages system variable can be specified as a locale name. The language of the associated locale will be used for error messages. See Server Locales for a list of supported locales and their associated languages.\n\nThe lc_messages system variable is set to en_US by default, which means that error messages are in English by default.\n\nIf the lc_messages system variable is set to a valid locale name, but the server can''t find an error message file for the language associated with the locale, then the default language will be used instead.\n\nThis system variable can be specified as command-line arguments to mariadbd or it can be specified in a relevant server option group in an option file. For example:\n\n``ini\n[mariadb]\n...\nlc_messages=fr_CA\n`\n\nThe lc_messages system variable can also be changed dynamically with SET GLOBAL. For example:\n\n`sql\nSET GLOBAL lc_messages=''fr_CA'';\n`\n\nIf a server has the lc_messages system variable set to the fr_CA locale like the above example, then error messages would be in French. For example:\n\n`sql\nSELECT blah;\nERROR 1054 (42S22): Champ ''blah'' inconnu dans field list\n`\n\nThe lc_messages_dir system variable can be specified either as the path to the directory storing the server''s error message files or as the path to the directory storing the specific language''s error message file.\n\nThe server initially tries to interpret the value of the lc_messages_dir system variable as a path to the directory storing the server''s error message files. Therefore, it constructs the path to the language''s error message file by concatenating the value of the lc_messages_dir system variable with the language name of the locale specified by the lc_messages system variable .\n\nIf the server does not find the error message file for the language, then it tries to interpret the value of the lc_messages_dir system variable as a direct path to the directory storing the specific language''s error message file.\n\nThis system variable can be specified as command-line arguments to mariadbd or it can be specified in a relevant server option group in an option file.\n\nFor example, to specify the path to the directory storing the server''s error message files:\n\n`ini\n[mariadb]\n...\nlc_messages_dir=/usr/share/mysql/\n`\n\nOr to specify the path to the directory storing the specific language''s error message file:\n\n`ini\n[mariadb]\n...\nlc_messages_dir=/usr/share/mysql/french/\n`\n\nThe lc_messages_dir system variable can not be changed dynamically.\n\nSetting the --language Option\n\nThe --language option can also be used to set the server''s language for error messages, but it is deprecated. It is recommended to set the lc_messages system variable instead.\n\nThe --language option can be specified either as a language name or as the path to the directory storing the language''s error message file. See Server Locales for a list of supported locales and their associated languages.\n\nThis option can be specified as command-line arguments to mariadbd or it can be specified in a relevant server option group in an option file.\n\nFor example, to specify a language name:\n\n`ini\n[mariadb]\n...\nlanguage=french\n`\n\nOr to specify the path to the directory storing the language''s error message file:\n\n`ini\n[mariadb]\n...\nlanguage=/usr/share/mysql/french/\n``\n\nCharacter Set\n\nThe character set that the error messages are returned in is determined by the character_set_results variable, which defaults to UTF8.\n\nURL: https://mariadb.com/docs/server/reference/data-types/string-data-types/character-sets/internationalization-and-localization/setting-the-language-for-error-messages', '', 'https://mariadb.com/docs/server/reference/data-types/string-data-types/character-sets/internationalization-and-localization/setting-the-language-for-error-messages'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (53, 22, 'Time Zones', 'Description\n-----------\n\nMariaDB keeps track of several time zone settings.\n\nSetting the Time Zone\n\nThe time_zone system variable is the primary way to set the time zone. It can be specified in one of the following formats:\n\n The default value is SYSTEM, which indicates that the system time zone defined in the system_time_zone system variable will be used. Note that if you are using SYSTEM with replication in either statement or mixed mode, you MUST use the same value for system_time_zone on all replicas (otherwise TIMESTAMP columns will not replicate correctly). See System Time Zone below for more information.\n An offset from Coordinated Universal Time (UTC), such as +5:00 or -9:00, can also be used.\n If the time zone tables in the mysql database were loaded, then a named time zone, such as America/New_York, Africa/Johannesburg, or Europe/Helsinki, is also permissible. See mysql Time Zone Tables below for more information.\n\nThere are two time zone settings that can be set within MariaDB--the global server time zone, and the time zone for your current session. There is also a third time zone setting which may be relevant--the system time zone.\n\nGlobal Server Time Zone\n\nThe global server time zone can be changed at server startup by setting the --default-time-zone option either on the command-line or in a server option group in an option file. For example:\n\n``ini\n[mariadb]\n...\ndefault_time_zone = ''America/New_York''\n`\n\nThe global server time zone can also be changed dynamically by setting the time_zone system variable as a user account that has the SUPER privilege. For example:\n\n`sql\nSET GLOBAL time_zone = ''America/New_York'';\n`\n\nThe current global server time zone can be viewed by looking at the global value of the time_zone system variable. For example:\n\n`sql\nSHOW GLOBAL VARIABLES LIKE ''time_zone'';\n+---------------+--------+\n| Variable_name | Value |\n+---------------+--------+\n| time_zone | SYSTEM |\n+---------------+--------+\n`\n\nSession Time Zone\n\nEach session that connects to the server will also have its own time zone. This time zone is initially inherited from the global value of the time_zone system variable, which sets the session value of the same variable.\n\nA session''s time zone can be changed dynamically by setting the time_zone system variable. For example:\n\n`sql\nSET time_zone = ''America/New_York'';\n`\n\nThe current session time zone can be viewed by looking at the session value of the time_zone system variable. For example:\n\n`sql\nSHOW SESSION VARIABLES LIKE ''time_zone'';\n+---------------+--------+\n| Variable_name | Value |\n+---------------+--------+\n| time_zone | SYSTEM |\n+---------------+--------+\n`\n\nSystem Time Zone\n\nThe system time zone is determined when the server starts, and it sets the value of the system_time_zone system variable. The system time zone is usually read from the operating system''s environment. You can change the system time zone in several different ways, such as:\n\n If you are starting the server with mariadbd-safe, then you can set the system time zone with the --timezone option either on the command-line or in the \\[mariadbd-safe] option group in an option file. For example:\n\n`ini\n[mariadbd-safe]\ntimezone=''America/New_York''\n`\n\n If you are using a Unix-like operating system, then you can set the system time zone by setting the TZ environment variable in your shell before starting the server. For example:\n\n`bash\n$ export TZ=''America/New_York''\n$ service mariadb start\n`\n\n On some Linux operating systems, you can change the default time zone for the whole system by making the /etc/localtime symbolic link point to the desired time zone. For example:\n\n`bash\n$ sudo rm /etc/localtime\n$ sudo ln -s /usr/share/zoneinfo/America/New_York /etc/localtime\n`\n\n On some Debian-based Linux operating systems, you can change the default time zone for the whole system by executing the following:\n\n`bash\nsudo dpkg-reconfigure tzdata\n`\n\n On Linux operating systems that use systemd, you can change the default time zone for the whole system by using the timedatectl utility. For example:\n\n`bash\nsudo timedatectl set-timezone America/New_York\n``\n\nTime Zone Effects\n\nTime Zone Effects on Functions\n\nSome functions are affected by the time zone settings. These include:\n\n NOW()\n SYSDATE()\n CURDATE()\n CURTIME()\n UNIX_TIMESTAMP()\n\nSome functions are not affected. These include:\n\n UTC_DATE()\n UTC_TIME()\n UTC_TIMESTAMP()\n\nTime Zone Effects on Data Types\n\nSome data types are affected by the time zone settings.\n\n TIMESTAMP - See TIMESTAMP: Time Zones for information on how this data type is affected by time zones.\n DATETIME - See DATETIME: Time Zones for information on how this data type is affected by time zones.\n\nmysql Time Zone Tables\n\nThe mysql database contains a number of time zone tables:\n\n time_zone\n time_zone_leap_second\n time_zone_name\n time_zone_transition\n* time_zone_transition_type\n\nBy default, these time zone tables in the mysql database are created, but not populated.\n\nIf you are using a Unix-like operating system, then you can populate these tables using the mariadb-tzinfo-to-sql utility, which uses the zoneinfo data available on Linux, Mac OS X, FreeBSD and Solaris.\n\nIf you are using Windows, then you will need to import pre-populated time zone tables. These are available at MariaDB mirrors.\n\nTime zone data needs to be updated on occasion. When that happens, the time zone tables may need to be reloaded.\n\nURL: https://mariadb.com/docs/server/reference/data-types/string-data-types/character-sets/internationalization-and-localization/time-zones', '', 'https://mariadb.com/docs/server/reference/data-types/string-data-types/character-sets/internationalization-and-localization/time-zones'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (54, 22, 'SET CHARACTER SET', 'Syntax\n------\n\nSET {CHARACTER SET | CHARSET}\n {charset_name | DEFAULT}\n\nDescription\n-----------\n\nSets the character_set_client and character_set_results session system variables to the specified character set and collation_connection to the value of collation_database, which implicitly sets character_set_connection to the value of character_set_database.\n\nThis maps all strings sent between the current client and the server with the given mapping.\n\nExamples\n--------\n\nSHOW VARIABLES LIKE ''character_set_%'';\n+--------------------------+--------+\n| Variable_name | Value |\n+--------------------------+--------+\n| character_set_client | utf8 |\n| character_set_connection | utf8 |\n| character_set_database | latin1 |\n| character_set_filesystem | binary |\n| character_set_results | utf8 |\n| character_set_server | latin1 |\n| character_set_system | utf8 |\n+--------------------------+--------+\n\nSHOW VARIABLES LIKE ''collation%'';\n+----------------------+-------------------+\n| Variable_name | Value |\n+----------------------+-------------------+\n| collation_connection | utf8_general_ci |\n| collation_database | latin1_swedish_ci |\n| collation_server | latin1_swedish_ci |\n+----------------------+-------------------+\n\nSET CHARACTER SET utf8mb4;\n\nSHOW VARIABLES LIKE ''character_set_%'';\n+--------------------------+---------+\n| Variable_name | Value |\n+--------------------------+---------+\n| character_set_client | utf8mb4 |\n| character_set_connection | latin1 |\n| character_set_database | latin1 |\n| character_set_filesystem | binary |\n| character_set_results | utf8mb4 |\n| character_set_server | latin1 |\n| character_set_system | utf8 |\n+--------------------------+---------+\n\nSHOW VARIABLES LIKE ''collation%'';\n+----------------------+-------------------+\n| Variable_name | Value |\n+----------------------+-------------------+\n| collation_connection | latin1_swedish_ci |\n| collation_database | latin1_swedish_ci |\n| collation_server | latin1_swedish_ci |\n+----------------------+-------------------+\n\nURL: https://mariadb.com/docs/server/reference/data-types/string-data-types/character-sets/set-character-set', '', 'https://mariadb.com/docs/server/reference/data-types/string-data-types/character-sets/set-character-set'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (55, 22, 'SET NAMES', 'Syntax\n------\n\nSET NAMES {''charset_name''\n [COLLATE ''collation_name''] | DEFAULT}\n\nDescription\n-----------\n\nSets the character_set_client, character_set_connection, character_set_results and, implicitly, the collation_connection session system variables to the specified character set and collation.\n\nThis determines which character set the client will use to send statements to the server, and the server will use for sending results back to the client.\n\nucs2, utf16, utf16le and utf32 are not valid character sets for SET NAMES, as they cannot be used as client character sets.\n\nThe collation clause is optional. If not defined (or if DEFAULT is specified), the default collation for the character set will be used.\n\nQuotes are optional for the character set or collation clauses.\n\nExamples\n--------\n\nSET NAMES DEFAULT; \n\nSELECT VARIABLE_NAME, SESSION_VALUE \n FROM INFORMATION_SCHEMA.SYSTEM_VARIABLES WHERE \n VARIABLE_NAME LIKE ''character_set_con%'' OR \n VARIABLE_NAME LIKE ''character_set_cl%'' OR \n VARIABLE_NAME LIKE ''character_set_re%'' OR \n VARIABLE_NAME LIKE ''collation_c%'';\n+--------------------------+-----------------------+\n| VARIABLE_NAME | SESSION_VALUE |\n+--------------------------+-----------------------+\n| CHARACTER_SET_RESULTS | utf8mb4 |\n| CHARACTER_SET_CONNECTION | utf8mb4 |\n| CHARACTER_SET_CLIENT | utf8mb4 |\n| COLLATION_CONNECTION | utf8mb4_uca1400_ai_ci |\n+--------------------------+-----------------------+\n\nURL: https://mariadb.com/docs/server/reference/data-types/string-data-types/character-sets/set-names', '', 'https://mariadb.com/docs/server/reference/data-types/string-data-types/character-sets/set-names'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (56, 22, 'Setting Character Sets and Collations', 'Description\n-----------\n\nThe default character set is utf8mb4 and the default collation is utf8mb4_uca1400_ai_ci.\\\nThis may differ in some distros, see for example Differences in MariaDB in Debian.\n\nThe default character set is latin1 and the default collation is latin1_swedish_ci.\\\nThis may differ in some distros, see for example Differences in MariaDB in Debian.\n\nIn MariaDB 11.6, the default character set changed from latin1 to utf8mb4.\n\nWhen upgrading to 11.6 or above from a previous release series, this can lead to behavior different from what you''ve been seeing in the old version.\n\nSee this section for details, including the impact on replicating to older MariaDB (or MySQL) replicas.\n\nThe character sets and the collations can be specified from the server right down to the column level, as well as for client-server connections. When changing a character set and not specifying a collation, the default collation for the new character set is always used.\n\nCharacter sets and collations always cascade down, so a column without a specified collation will look for the table default, the table for the database, and the database for the server. It''s therefore possible to have extremely fine-grained control over all the character sets and collations used in your data.\n\nDefault collations for each character set can be viewed with the SHOW COLLATION statement, for example, to find the default collation for the latin2 character set:\n\n``sql\nSHOW COLLATION LIKE ''latin2%'';\n+---------------------+---------+----+---------+----------+---------+\n| Collation | Charset | Id | Default | Compiled | Sortlen |\n+---------------------+---------+----+---------+----------+---------+\n| latin2_czech_cs | latin2 | 2 | | Yes | 4 |\n| latin2_general_ci | latin2 | 9 | Yes | Yes | 1 |\n| latin2_hungarian_ci | latin2 | 21 | | Yes | 1 |\n| latin2_croatian_ci | latin2 | 27 | | Yes | 1 |\n| latin2_bin | latin2 | 77 | | Yes | 1 |\n+---------------------+---------+----+---------+----------+---------+\n`\n\nServer Level\n\nThe character_set_server system variable can be used to change the default server character set. It can be set both on startup or dynamically, with the SET command:\n\n`sql\nSET character_set_server = ''latin2'';\n`\n\nSimilarly, the collation_server variable is used for setting the default server collation.\n\n`sql\nSET collation_server = ''latin2_czech_cs'';\n`\n\nDatabase Level\n\nThe CREATE DATABASE and ALTER DATABASE statements have optional character set and collation clauses. If these are left out, the server defaults are used.\n\n`sql\nCREATE DATABASE czech_slovak_names \n CHARACTER SET = ''keybcs2''\n COLLATE = ''keybcs2_bin'';\n`\n\n`sql\nALTER DATABASE czech_slovak_names COLLATE = ''keybcs2_general_ci'';\n`\n\nTo determine the default character set used by a database, use:\n\n`sql\nSHOW CREATE DATABASE czech_slovak_names;\n+--------------------+--------------------------------------------------------------------------------+\n| Database | Create Database |\n+--------------------+--------------------------------------------------------------------------------+\n| czech_slovak_names | CREATE DATABASE czech_slovak_names /!40100 DEFAULT CHARACTER SET keybcs2 / |\n+--------------------+--------------------------------------------------------------------------------+\n`\n\nAlternatively, for the character set and collation:\n\n`sql\nSELECT FROM INFORMATION_SCHEMA.SCHEMATA;\n+--------------+--------------------+----------------------------+------------------------+----------+\n| CATALOG_NAME | SCHEMA_NAME | DEFAULT_CHARACTER_SET_NAME | DEFAULT_COLLATION_NAME | SQL_PATH |\n+--------------+--------------------+----------------------------+------------------------+----------+\n| def | czech_slovak_names | keybcs2 | keybcs2_general_ci | NULL |\n| def | information_schema | utf8 | utf8_general_ci | NULL |\n| def | mysql | latin1 | latin1_swedish_ci | NULL |\n| def | performance_schema | utf8 | utf8_general_ci | NULL |\n| def | test | latin1 | latin1_swedish_ci | NULL |\n+--------------+--------------------+----------------------------+------------------------+----------+\n`\n\nIt is also possible to specify only the collation, and, since each collation only applies to one character set, the associated character set will automatically be specified.\n\n`sql\nCREATE DATABASE danish_names COLLATE ''utf8_danish_ci'';\n\nSHOW CREATE DATABASE danish_names;\n+--------------+----------------------------------------------------------------------------------------------+\n| Database | Create Database |\n+--------------+----------------------------------------------------------------------------------------------+\n| danish_names | CREATE DATABASE danish_names /!40100 DEFAULT CHARACTER SET utf8 COLLATE utf8_danish_ci / |\n+--------------+----------------------------------------------------------------------------------------------+\n`\n\nAlthough there are character_set_database and collation_database system variables which can be set dynamically, these are used for determining the character set and collation for the default database, and should only be set by the server.\n\nTable Level\n\nThe CREATE TABLE and ALTER TABLE statements support optional character set and collation clauses, a MariaDB and MySQL extension to standard SQL.\n\n`sql\nCREATE TABLE english_names (id INT, name VARCHAR(40)) \n CHARACTER SET ''utf8'' \n COLLATE ''utf8_icelandic_ci'';\n`\n\nIf neither character set nor collation is provided, the database default will be used. If only the character set is provided, the default collation for that character set will be used . If only the collation is provided, the associated character set will be used. See Supported Character Sets and Collations.\n\n`sql\nALTER TABLE table_name\n CONVERT TO CHARACTER SET charset_name [COLLATE collation_name];\n`\n\nIf no collation is provided, the collation will be set to the default collation for that character set. See Supported Character Sets and Collations.\n\nFor VARCHAR or TEXT columns, CONVERT TO CHARACTER SET changes the data type if needed to ensure the new column is long enough to store as many characters as the original column.\n\nFor example, an ascii TEXT column requires a single byte per character, so the column can hold up to 65,535 characters. If the column is converted to utf8mb4, 4 bytes can be required for each character, so the column will be converted to MEDIUMTEXT to be able to hold the same number of characters.\n\nCONVERT TO CHARACTER SET binary will convert CHAR, VARCHAR and TEXT columns to BINARY, VARBINARY and BLOB respectively, and from that point will no longer have a character set, or be affected by future CONVERT TO CHARACTER SET statements.\n\nTo avoid data type changes resulting from CONVERT TO CHARACTER SET, use MODIFY on the individual columns instead. For example:\n\n`sql\nALTER TABLE table_name MODIFY ascii_text_column TEXT CHARACTER SET utf8;\nALTER TABLE table_name MODIFY ascii_varchar_column VARCHAR(M) CHARACTER SET utf8;\n`\n\nColumn Level\n\nCharacter sets and collations can also be specified for columns that are character types CHAR, TEXT or VARCHAR. The CREATE TABLE and ALTER TABLE statements support optional character set and collation clauses for this purpose - unlike those at the table level, the column level definitions are standard SQL.\n\n`sql\nCREATE TABLE european_names (\n croatian_names VARCHAR(40) COLLATE ''cp1250_croatian_ci'',\n greek_names VARCHAR(40) CHARACTER SET ''greek'');\n`\n\nIf neither collation nor character set is provided, the table default is used. If only the character set is specified, that character set''s default collation is used, while if only the collation is specified, the associated character set is used.\n\nWhen using ALTER TABLE to change a column''s character set, you need to ensure the character sets are compatible with your data. MariaDB will map the data as best it can, but it''s possible to lose data if care is not taken.\n\nThe SHOW CREATE TABLE statement or INFORMATION SCHEMA database can be used to determine column character sets and collations.\n\n`sql\nSHOW CREATE TABLE european_names\\G\n*********************** 1. row ***********************\n Table: european_names\nCreate Table: CREATE TABLE european_names (\n croatian_names varchar(40) CHARACTER SET cp1250 COLLATE cp1250_croatian_ci DEFAULT NULL,\n greek_names varchar(40) CHARACTER SET greek DEFAULT NULL\n) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_danish_ci\n`\n\n`sql\nSELECT FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME LIKE ''european%''\\G\n************************ 1. row *********************\n TABLE_CATALOG: def\n TABLE_SCHEMA: danish_names\n TABLE_NAME: european_names\n COLUMN_NAME: croatian_names\n ORDINAL_POSITION: 1\n COLUMN_DEFAULT: NULL\n IS_NULLABLE: YES\n DATA_TYPE: varchar\nCHARACTER_MAXIMUM_LENGTH: 40\n CHARACTER_OCTET_LENGTH: 40\n NUMERIC_PRECISION: NULL\n NUMERIC_SCALE: NULL\n DATETIME_PRECISION: NULL\n CHARACTER_SET_NAME: cp1250\n COLLATION_NAME: cp1250_croatian_ci\n COLUMN_TYPE: varchar(40)\n COLUMN_KEY: \n EXTRA: \n PRIVILEGES: select,insert,update,references\n COLUMN_COMMENT: \n********************* 2. row ***********************\n TABLE_CATALOG: def\n TABLE_SCHEMA: danish_names\n TABLE_NAME: european_names\n COLUMN_NAME: greek_names\n ORDINAL_POSITION: 2\n COLUMN_DEFAULT: NULL\n IS_NULLABLE: YES\n DATA_TYPE: varchar\nCHARACTER_MAXIMUM_LENGTH: 40\n CHARACTER_OCTET_LENGTH: 40\n NUMERIC_PRECISION: NULL\n NUMERIC_SCALE: NULL\n DATETIME_PRECISION: NULL\n CHARACTER_SET_NAME: greek\n COLLATION_NAME: greek_general_ci\n COLUMN_TYPE: varchar(40)\n COLUMN_KEY: \n EXTRA: \n PRIVILEGES: select,insert,update,references\n COLUMN_COMMENT:\n`\n\nFilenames\n\nThe character_set_filesystem system variable has controlled interpretation of file names that are given as literal strings. This affects the following statements and functions:\n\n SELECT INTO DUMPFILE\n SELECT INTO OUTFILE\n LOAD DATA INFILE\n LOAD XML\n LOAD_FILE()\n\nLiterals\n\nBy default, the character set and collation used for literals is determined by the character_set_connection and collation_connection system variables. However, they can also be specified explicitly:\n\n`sql\n[_charset_name]''string'' [COLLATE collation_name]\n`\n\nThe character set of string literals that do not have a character set introducer is determined by the character_set_connection system variable.\n\nThis query always returns the same character set name in both columns.:\n\n`sql\nSELECT CHARSET(''a''), @@character_set_connection;\n`\n\ncharacter_set_client and character_set_connection are normally (e.g. during handshake, or after a SET NAMES` query) are set to equal values. However, it''s possible to set to different values.\n\nExamples\n--------\n\nCREATE TABLE t1 (a VARCHAR(10)) CHARACTER SET utf8 COLLATE utf8_general_ci;\nINSERT INTO t1 VALUES (''oe''),(''ö'');\n\nURL: https://mariadb.com/docs/server/reference/data-types/string-data-types/character-sets/setting-character-sets-and-collations', '', 'https://mariadb.com/docs/server/reference/data-types/string-data-types/character-sets/setting-character-sets-and-collations'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (57, 22, 'Supported Character Sets and Collations', 'Description\n-----------\n\nCharacter Sets\n\nYou can see which character sets are available in a particular version by running the SHOW CHARACTER SET statement or by querying the Information Schema CHARACTER_SETS Table.\n\nIt is possible to change the default collation associated with a character set. See Changing Default Collation.\n\nIt is not possible to change the default collation associated with a character set. See Changing Default Collation\n\nMariaDB supports the following character sets:\n\n| Charset | Description | Default collation | Maxlen |\n| -------- | --------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------ |\n| armscii8 | ARMSCII-8 Armenian | armscii8_general_ci | 1 |\n| ascii | US ASCII | ascii_general_ci | 1 |\n| big5 | Big5 Traditional Chinese | big5_chinese_ci | 2 |\n| binary | Binary pseudo charset | binary | 1 |\n| cp1250 | Windows Central European | cp1250_general_ci | 1 |\n| cp1251 | Windows Cyrillic | cp1251_general_ci | 1 |\n| cp1256 | Windows Arabic | cp1256_general_ci | 1 |\n| cp1257 | Windows Baltic | cp1257_general_ci | 1 |\n| cp850 | DOS West European | cp850_general_ci | 1 |\n| cp852 | DOS Central European | cp852_general_ci | 1 |\n| cp866 | DOS Russian | cp866_general_ci | 1 |\n| cp932 | SJIS for Windows Japanese | cp932_japanese_ci | 2 |\n| dec8 | DEC West European | dec8_swedish_ci | 1 |\n| eucjpms | UJIS for Windows Japanese | eucjpms_japanese_ci | 3 |\n| euckr | EUC-KR Korean | euckr_korean_ci | 2 |\n| gb2312 | GB2312 Simplified Chinese | gb2312_chinese_ci | 2 |\n| gbk | GBK Simplified Chinese | gbk_chinese_ci | 2 |\n| geostd8 | GEOSTD8 Georgian | geostd8_general_ci | 1 |\n| greek | ISO 8859-7 Greek | greek_general_ci | 1 |\n| hebrew | ISO 8859-8 Hebrew | hebrew_general_ci | 1 |\n| hp8 | HP West European | hp8_english_ci | 1 |\n| keybcs2 | DOS Kamenicky Czech-Slovak | keybcs2_general_ci | 1 |\n| koi8r | KOI8-R Relcom Russian | koi8r_general_ci | 1 |\n| koi8u | KOI8-U Ukrainian | koi8u_general_ci | 1 |\n| latin1 | cp1252 West European | latin1_swedish_ci | 1 |\n| latin2 | ISO 8859-2 Central European | latin2_general_ci | 1 |\n| latin5 | ISO 8859-9 Turkish | latin5_turkish_ci | 1 |\n| latin7 | ISO 8859-13 Baltic | latin7_general_ci | 1 |\n| macce | Mac Central European | macce_general_ci | 1 |\n| macroman | Mac West European | macroman_general_ci | 1 |\n| sjis | Shift-JIS Japanese | sjis_japanese_ci | 2 |\n| swe7 | 7bit Swedish | swe7_swedish_ci\n\n[Truncated — full content at mariadb.com/docs]', '', 'https://mariadb.com/docs/server/reference/data-types/string-data-types/character-sets/supported-character-sets-and-collations'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (58, 22, 'Unicode', 'Description\n-----------\n\nUnicode is a standard for encoding text across multiple writing systems. MariaDB supports a number of character sets for storing Unicode data:\n\n| Character Set | Description |\n| ------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| ucs2 | UCS-2, each character is represented by a 2-byte code with the most significant byte first. Fixed-length 16-bit encoding. |\n| utf8 | utf8 is an alias for utf8mb3, but this can changed to ut8mb4 by changing the default value of the old_mode system variable. |\n| utf8mb3 | UTF-8 encoding using one to three bytes per character. Basic Latin letters, numbers and punctuation use one byte. European and Middle East letters mostly fit into 2 bytes. Korean, Chinese, and Japanese ideographs use 3-bytes. No supplementary characters are stored. Until MariaDB 10.5, this was an alias for utf8. From MariaDB 10.6, utf8 is by default an alias for utf8mb3, but this can changed to ut8mb4 by changing the default value of the old_mode system variable. |\n| utf8mb4 | UTF-8 encoding the same as utf8mb3 but which stores supplementary characters in four bytes. |\n| utf16 | UTF-16, same as ucs2, but stores supplementary characters in 32 bits. 16 or 32-bits. |\n| utf32 | UTF-32, fixed-length 32-bit encoding. |\n\nSupport for the UCA-14.0.0 collations was added in MariaDB 10.10 (MDEV-27009).\n\nSupport for the MySQL 8.0 UCA-9-0-0 (utf8mb4_0900_...) collations will be added to MariaDB 11.4.5.\n\nURL: https://mariadb.com/docs/server/reference/data-types/string-data-types/character-sets/unicode', '', 'https://mariadb.com/docs/server/reference/data-types/string-data-types/character-sets/unicode'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (59, 22, 'CHARACTER', 'Description\n-----------\n\nThis is a synonym for CHAR.\n\nExamples\n--------\n\nCREATE TABLE character_example (\n example CHARACTER\n);\n\nURL: https://mariadb.com/docs/server/reference/data-types/string-data-types/character', '', 'https://mariadb.com/docs/server/reference/data-types/string-data-types/character'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (60, 22, 'CLOB', 'Description\n-----------\n\nThis is a synonym for LONGTEXT.\n\nExamples\n--------\n\nSET sql_mode=''oracle'';\n\nCREATE TABLE clob_example (\n example CLOB\n);\n\nURL: https://mariadb.com/docs/server/reference/data-types/string-data-types/clob', '', 'https://mariadb.com/docs/server/reference/data-types/string-data-types/clob'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (61, 22, 'ENUM', 'Syntax\n------\n\nENUM(''value1'',''value2'',...) [CHARACTER SET charset_name] [COLLATE collation_name]\n\nDescription\n-----------\n\nAn enumeration. A string object that can have only one value, chosen from the list of values ''value1'', ''value2'', ..., NULL or the special '''' error value. In theory, an ENUM column can have a maximum of 65,535 distinct values; in practice, the real maximum depends on many factors. ENUM values are represented internally as integers.\n\nTrailing spaces are automatically stripped from ENUM values on table creation.\n\nENUM values require relatively little storage space compared to strings, either one or two bytes depending on the number of enumeration values.\n\nNULL and empty values\n\nAn ENUM can also contain NULL and empty values. If the ENUM column is declared to permit NULL values, NULL becomes a valid value, as well as the default value (see below). If strict SQL Mode is not enabled, and an invalid value is inserted into an ENUM, a special empty string, with an index value of zero (see Numeric index, below), is inserted, with a warning. This may be confusing, because the empty string is also a possible value, and the only difference if that is this case its index is not 0. Inserting will fail with an error if strict mode is active.\n\nIf a DEFAULT clause is missing, the default value will be:\n\n NULL if the column is nullable;\n otherwise, the first value in the enumeration.\n\nNumeric index\n\nENUM values are indexed numerically in the order they are defined, and sorting will be performed in this numeric order. We suggest not using ENUM to store numerals, as there is little to no storage space benefit, and it is easy to confuse the enum integer with the enum numeral value by leaving out the quotes.\n\nAn ENUM defined as ENUM(''apple'',''orange'',''pear'') would have the following index values:\n\n| Index | Value |\n| ----- | -------- |\n| NULL | NULL |\n| 0 | '''' |\n| 1 | ''apple'' |\n| 2 | ''orange'' |\n| 3 | ''pear'' |\n\nExamples\n--------\n\nCREATE TABLE fruits (\n id INT NOT NULL auto_increment PRIMARY KEY,\n fruit ENUM(''apple'',''orange'',''pear''),\n bushels INT);\n\nDESCRIBE fruits;\n+---------+-------------------------------+------+-----+---------+----------------+\n| Field | Type | Null | Key | Default | Extra |\n+---------+-------------------------------+------+-----+---------+----------------+\n| id | int(11) | NO | PRI | NULL | auto_increment |\n| fruit | enum(''apple'',''orange'',''pear'') | YES | | NULL | |\n| bushels | int(11) | YES | | NULL | |\n+---------+-------------------------------+------+-----+---------+----------------+\n\nINSERT INTO fruits\n (fruit,bushels) VALUES\n (''pear'',20),\n (''apple'',100),\n (''orange'',25);\n\nINSERT INTO fruits\n (fruit,bushels) VALUES\n (''avocado'',10);\nERROR 1265 (01000): Data truncated for column ''fruit'' at row 1\n\nSELECT * FROM fruits;\n+----+--------+---------+\n| id | fruit | bushels |\n+----+--------+---------+\n| 1 | pear | 20 |\n| 2 | apple | 100 |\n| 3 | orange | 25 |\n+----+--------+---------+\n\nURL: https://mariadb.com/docs/server/reference/data-types/string-data-types/enum', '', 'https://mariadb.com/docs/server/reference/data-types/string-data-types/enum'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (62, 22, 'INET4', 'Syntax\n------\n\nINET4\n\nDescription\n-----------\n\nINET4 is a data type to store IPv4 addresses, as 4-byte binary strings.\n\nCasting from INET4 data types to INET6 is permitted, allowing for example comparisons between the two data types, and for INET4 values to be inserted into INET6 columns.\n\nCasting from INET4 data types to INET6 is not permitted.\n\nExamples\n--------\n\nCREATE OR REPLACE TABLE t1 (a INET4);\n\nINSERT INTO t1 VALUES(''0.0.0.0''), (''255.10.0.0''), (''255.255.255.255'');\n\nINSERT INTO t1 VALUES (0xa0000001);\nINSERT INTO t1 VALUES (0xf0000000);\nINSERT INTO t1 VALUES (0xff000001);\n\nSELECT HEX(a), a FROM t1 ORDER BY a;\n+----------+-----------------+\n| HEX(a) | a |\n+----------+-----------------+\n| 00000000 | 0.0.0.0 |\n| A0000001 | 160.0.0.1 |\n| F0000000 | 240.0.0.0 |\n| FF000001 | 255.0.0.1 |\n| FF0A0000 | 255.10.0.0 |\n| FFFFFFFF | 255.255.255.255 |\n+----------+-----------------+\n\nURL: https://mariadb.com/docs/server/reference/data-types/string-data-types/inet4', '', 'https://mariadb.com/docs/server/reference/data-types/string-data-types/inet4'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (63, 22, 'INET6', 'Syntax\n------\n\nINET6\n\nDescription\n-----------\n\nThe INET6 data type is intended for storage of IPv6 addresses, as well as IPv4 addresses assuming conventional mapping of IPv4 addresses into IPv6 addresses.\n\nBoth short and long IPv6 notation are permitted, according to RFC-5952.\n\n Values are stored as a 16-byte fixed length binary string, with most significant byte first.\n Storage engines see INET6 as BINARY(16).\n Clients see INET6 as CHAR(39) and get text representation on retrieval.\n\nThe IPv4-compatible notation is considered as deprecated. It is supported for compatibility with the INET6_ATON function, which also understands this format. It''s recommended to use the mapped format to store IPv4 addresses in INET6.\n\nWhen an IPv4 mapped (or compatible) value is stored in INET6, it still occupies 16 bytes:\n\nRetrieval\n\nOn retrieval, in the client-server text protocol, INET6 values are converted to the short text representation, according to RFC-5952, that is with all leading zeroes in each group removed and with consequent zero groups compressed.\n\nBesides creating one''s own stored function, there is no a way to retrieve an INET6 value using long text representation.\n\nCasting\n\n CAST from a character string to INET6 understands addresses in short or long text notation (including IPv4 mapped and compatible addresses). NULL is returned if the format is not understood.\n CAST from a binary string to INET6 requires a 16-byte string as an argument. NULL is returned if the argument length is not equal to 16.\n CAST from other data types to INET6 first converts data to a character string, then CAST from character string to INET6 is applied.\n CAST from INET6 to CHAR returns short text address notation.\n CAST from INET6 to BINARY returns its 16-byte binary string representation.\n CAST from INET6 to data types other than CHAR (e.g. SIGNED, UNSIGNED, TIME, etc) returns an error.\n\nComparisons\n\nAn INET6 expression can be compared to:\n\n another INET6 expression\n a character string expression with a text (short or long) address representation:\n a 16-byte binary string expression.\n\nAttempting to compare INET6 to an expression of any other data type returns an error.\n\nMixing INET6 Values for Result\n\nAn INET6 expression can be mixed for result (i.e. UNION, CASE..THEN, COALESCE etc) with:\n\n another INET6 expression. The resulting data type is INET6.\n a character string in text (short or long) address representation. The result data type is INET6. The character string counterpart is automatically converted to INET6. If the string format is not understood, it''s converted with a warning to either NULL or to ''::'', depending on the NULL-ability of the result.\n a 16-byte binary string. The resulting data type is INET6. The binary string counterpart is automatically converted to INET6. If the length of the binary string is not equal to 16, it''s converted with a warning to NULL or to ''::'' depending on the NULL-ability of the result.\n\nAttempts to mix INET6 for result with other data types will return an error.\n\nMixing INET6 with other data types for LEAST and GREATEST, when mixing for comparison and mixing for result are involved at the same time, uses the same rules with mixing for result, described in the previous paragraphs.\n\nFunctions and Operators\n\n HEX() with an INET6 argument returns a hexadecimal representation of the underlying 16-byte binary string\n Arithmetic operators (+,-,\\,/,MOD,DIV) are not supported for INET6. This may change in the future.\n The INET6_ATON function now understands INET6 values as an argument\n The prototypes of the IS_IPV4_COMPAT and I S_IPV4_MAPPED functions have changed from a BINARY(16) to a INET6,\n\nWhen the argument for the aforementioned two functions is not INET6, automatic implicit CAST to INET6 is applied. As a consequence, both functions understand arguments in both text representation and binary(16) representation.\n\nWhen the argument for the aforementioned two functions is not INET6, automatic implicit CAST to INET6 is not applied.\n\nPrepared Statement Parameters\n\nINET6 understands both text and binary(16) address representation in prepared statement parameters (PREPARE..EXECUTE and EXECUTE IMMEDIATE statements).\n\nMigration between BINARY(16) and INET6\n\nYou may have used BINARY(16) as a storage for IPv6 internet addresses, in combination with INET6_ATON and INET6_NTOA to respectively insert and retrieve data.\n\nHowever, you can ALTER BINARY(16) columns storing IPv6 addresses to INET6. After such an alter, there is no a need to use INET6_ATON() and INET6_NTOA(). Addresses can be inserted and retrieved directly.\n\nYou may use BINARY(16) as a storage for IPv6 internet addresses, in combination with INET6_ATON and INET6_NTOA to respectively insert and retrieve data.\n\nIt is also possible to convert INET6 columns to BINARY(16) and continue using the data in combination with INET6_NTOA() and INET6_ATON().\n\nExamples\n--------\n\nCREATE TABLE t1 (a INET6);\n\nURL: https://mariadb.com/docs/server/reference/data-types/string-data-types/inet6', '', 'https://mariadb.com/docs/server/reference/data-types/string-data-types/inet6'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (64, 22, 'JSON Data Type', 'Description\n-----------\n\nThe JSON alias was added to make it possible to use JSON columns in statement based replication from MySQL to MariaDB and to make it possible for MariaDB to read mysqldumps from MySQL.\n\nJSON is an alias for LONGTEXT COLLATE utf8mb4_bin introduced for compatibility reasons with MySQL''s JSON data type. MariaDB implements this as a LONGTEXT rather, as the JSON data type contradicts the SQL:2016 standard, and MariaDB''s benchmarks indicate that performance is at least equivalent.\n\nIn order to ensure that a valid json document is inserted, the JSON_VALID function can be used as a CHECK constraint. This constraint is automatically included for types using the JSON alias.\n\nThe assigned text value is retained verbatim. If a value fails JSON_VALID(), an error is raised. This CHECK constraint can also be manually added to any LONGTEXT field. When a JSON object contains duplicate keys, only the first key-value pair is accessible via functions like JSON_EXTRACT().\n\nExamples\n--------\n\nCREATE TABLE t (j JSON);\n\nDESC t;\n+-------+----------+------+-----+---------+-------+\n| Field | Type | Null | Key | Default | Extra |\n+-------+----------+------+-----+---------+-------+\n| j | longtext | YES | | NULL | |\n+-------+----------+------+-----+---------+-------+\n\nURL: https://mariadb.com/docs/server/reference/data-types/string-data-types/json', '', 'https://mariadb.com/docs/server/reference/data-types/string-data-types/json'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (65, 22, 'LONG and LONG VARCHAR', 'Description\n-----------\n\nLONG and LONG VARCHAR are synonyms for MEDIUMTEXT.\n\n``sql\nCREATE TABLE t1 (a LONG, b LONG VARCHAR);\n\nDESC t1;\n+-------+------------+------+-----+---------+-------+\n| Field | Type | Null | Key | Default | Extra |\n+-------+------------+------+-----+---------+-------+\n| a | mediumtext | YES | | NULL | |\n| b | mediumtext | YES | | NULL | |\n+-------+------------+------+-----+---------+-------+\n``\n\nURL: https://mariadb.com/docs/server/reference/data-types/string-data-types/long-and-long-varchar', '', 'https://mariadb.com/docs/server/reference/data-types/string-data-types/long-and-long-varchar'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (66, 22, 'LONG CHAR VARYING', 'Description\n-----------\n\nSee MEDIUMTEXT.\n\nExamples\n--------\n\nCREATE TABLE long_char_varying_example (\n example LONG CHAR VARYING\n);\n\nURL: https://mariadb.com/docs/server/reference/data-types/string-data-types/long-char-varying', '', 'https://mariadb.com/docs/server/reference/data-types/string-data-types/long-char-varying'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (67, 22, 'LONG CHARACTER VARYING', 'Description\n-----------\n\nSee MEDIUMTEXT.\n\nExamples\n--------\n\nCREATE TABLE long_character_varying_example (\n example LONG CHARACTER VARYING\n);\n\nURL: https://mariadb.com/docs/server/reference/data-types/string-data-types/long-character-varying', '', 'https://mariadb.com/docs/server/reference/data-types/string-data-types/long-character-varying'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (68, 22, 'LONG VARBINARY', 'Description\n-----------\n\nSee MEDIUMBLOB.\n\nExamples\n--------\n\nCREATE TABLE long_varbinary_example (\n example LONG VARBINARY\n);\n\nURL: https://mariadb.com/docs/server/reference/data-types/string-data-types/long-varbinary', '', 'https://mariadb.com/docs/server/reference/data-types/string-data-types/long-varbinary'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (69, 22, 'LONG VARCHAR', 'Description\n-----------\n\nSee MEDIUMTEXT.\n\nExamples\n--------\n\nCREATE TABLE long_varchar_example (\n example LONG VARCHAR\n);\n\nURL: https://mariadb.com/docs/server/reference/data-types/string-data-types/long-varchar', '', 'https://mariadb.com/docs/server/reference/data-types/string-data-types/long-varchar'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (70, 22, 'LONG VARCHARACTER', 'Description\n-----------\n\nSee MEDIUMTEXT.\n\nExamples\n--------\n\nCREATE TABLE long_varcharacter_example (\n example LONG VARCHARACTER\n);\n\nURL: https://mariadb.com/docs/server/reference/data-types/string-data-types/long-varcharacter', '', 'https://mariadb.com/docs/server/reference/data-types/string-data-types/long-varcharacter'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (71, 22, 'LONGBLOB', 'Syntax\n------\n\nLONGBLOB\n\nDescription\n-----------\n\nA BLOB column with a maximum length of 4,294,967,295 bytes (2³² - 1), or 4GB. The effective maximum length of LONGBLOB columns depends on the configured maximum packet size in the client/server protocol and available memory. Each LONGBLOB value is stored using a four-byte length prefix that indicates the number of bytes in the value.\n\nOracle Mode\n\nIn Oracle mode, BLOB is a synonym for LONGBLOB.\n\nExamples\n--------\n\nCREATE TABLE longblob_example (\n description VARCHAR(20),\n example LONGBLOB\n) DEFAULT CHARSET=latin1; -- One byte per char makes the examples clearer\n\nURL: https://mariadb.com/docs/server/reference/data-types/string-data-types/longblob', '', 'https://mariadb.com/docs/server/reference/data-types/string-data-types/longblob'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (72, 22, 'LONGTEXT', 'Syntax\n------\n\nLONGTEXT [CHARACTER SET charset_name] [COLLATE collation_name]\n\nDescription\n-----------\n\nA TEXT column with a maximum length of 4,294,967,295 or 4GB (2³² - 1) characters. The effective maximum length is less if the value contains multi-byte characters. The effective maximum length of LONGTEXT columns also depends on the configured maximum packet size in the client/server protocol and available memory. Each LONGTEXT value is stored using a four-byte length prefix that indicates the number of bytes in the value.\n\nJSON is an alias for LONGTEXT. See JSON Data Type for details.\n\nOracle Mode\n\nIn Oracle mode, CLOB is a synonym for LONGTEXT.\n\nExamples\n--------\n\nCREATE TABLE longtext_example (\n description VARCHAR(20),\n example LONGTEXT\n) DEFAULT CHARSET=latin1; -- One byte per char makes the examples clearer\n\nURL: https://mariadb.com/docs/server/reference/data-types/string-data-types/longtext', '', 'https://mariadb.com/docs/server/reference/data-types/string-data-types/longtext'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (73, 22, 'MEDIUMBLOB', 'Syntax\n------\n\nMEDIUMBLOB\n\nDescription\n-----------\n\nA BLOB column with a maximum length of 16,777,215 (2²⁴ - 1) bytes. Each MEDIUMBLOB value is stored using a three-byte length prefix that indicates the number of bytes in the value.\n\nLONG VARBINARY is a synonym for MEDIUMBLOB .\n\nExamples\n--------\n\nCREATE TABLE mediumblob_example (\n description VARCHAR(20),\n example MEDIUMBLOB\n) DEFAULT CHARSET=latin1; -- One byte per char makes the examples clearer\n\nURL: https://mariadb.com/docs/server/reference/data-types/string-data-types/mediumblob', '', 'https://mariadb.com/docs/server/reference/data-types/string-data-types/mediumblob'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (74, 22, 'MEDIUMTEXT', 'Syntax\n------\n\nMEDIUMTEXT [CHARACTER SET charset_name] [COLLATE collation_name]\n\nDescription\n-----------\n\nA TEXT column with a maximum length of 16,777,215 (2²⁴ - 1) characters. The effective maximum length is less if the value contains multi-byte characters. Each MEDIUMTEXT value is stored using\\\na three-byte length prefix that indicates the number of bytes in the value.\n\nSYNONYMS\n\nThe following are synonyms for MEDIUMTEXT:\n\n LONG\n LONG CHAR VARYING\n LONG CHARACTER VARYING\n LONG VARCHAR\n* LONG VARCHARACTER\n\nExamples\n--------\n\nCREATE TABLE mediumtext_example (\n description VARCHAR(20),\n example MEDIUMTEXT\n) DEFAULT CHARSET=latin1; -- One byte per char makes the examples clearer\n\nURL: https://mariadb.com/docs/server/reference/data-types/string-data-types/mediumtext', '', 'https://mariadb.com/docs/server/reference/data-types/string-data-types/mediumtext'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (75, 22, 'NATIONAL CHAR VARYING', 'Description\n-----------\n\nSee NATIONAL VARCHAR.\n\nExamples\n--------\n\nCREATE TABLE national_char_varying_example (\n example NATIONAL CHAR VARYING(32)\n);\n\nURL: https://mariadb.com/docs/server/reference/data-types/string-data-types/national-char-varying', '', 'https://mariadb.com/docs/server/reference/data-types/string-data-types/national-char-varying'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (76, 22, 'NATIONAL CHAR', 'Description\n-----------\n\nFixed-length string of specific character set with limit up to 255 bytes.\n\nExamples\n--------\n\nCREATE TABLE national_char_example (\n example NATIONAL CHAR(32)\n);\n\nURL: https://mariadb.com/docs/server/reference/data-types/string-data-types/national-char', '', 'https://mariadb.com/docs/server/reference/data-types/string-data-types/national-char'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (77, 22, 'NATIONAL CHARACTER VARYING', 'Description\n-----------\n\nSee NATIONAL VARCHAR.\n\nExamples\n--------\n\nCREATE TABLE national_character_varying_example (\n example NATIONAL CHARACTER VARYING(32)\n);\n\nURL: https://mariadb.com/docs/server/reference/data-types/string-data-types/national-character-varying', '', 'https://mariadb.com/docs/server/reference/data-types/string-data-types/national-character-varying'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (78, 22, 'NATIONAL CHARACTER', 'Description\n-----------\n\nSee NATIONAL CHAR.\n\nExamples\n--------\n\nCREATE TABLE national_character_example (\n example NATIONAL CHARACTER(32)\n);\n\nURL: https://mariadb.com/docs/server/reference/data-types/string-data-types/national-character', '', 'https://mariadb.com/docs/server/reference/data-types/string-data-types/national-character'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (79, 22, 'NATIONAL VARCHAR', 'Description\n-----------\n\nVariable-length string of specific character set with limit up to 65,535 bytes.\n\nExamples\n--------\n\nCREATE TABLE national_varchar_example (\n example NATIONAL VARCHAR(32)\n);\n\nURL: https://mariadb.com/docs/server/reference/data-types/string-data-types/national-varchar', '', 'https://mariadb.com/docs/server/reference/data-types/string-data-types/national-varchar'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (80, 22, 'NATIONAL VARCHARACTER', 'Description\n-----------\n\nSee NATIONAL VARCHAR.\n\nExamples\n--------\n\nCREATE TABLE national_varcharacter_example (\n example NATIONAL VARCHARACTER(32)\n);\n\nURL: https://mariadb.com/docs/server/reference/data-types/string-data-types/national-varcharacter', '', 'https://mariadb.com/docs/server/reference/data-types/string-data-types/national-varcharacter'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (81, 22, 'NCHAR VARCHAR', 'Description\n-----------\n\nSee NATIONAL VARCHAR.\n\nExamples\n--------\n\nCREATE TABLE nchar_varchar_example (\n example NCHAR VARCHAR(32)\n);\n\nURL: https://mariadb.com/docs/server/reference/data-types/string-data-types/nchar-varchar', '', 'https://mariadb.com/docs/server/reference/data-types/string-data-types/nchar-varchar'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (82, 22, 'NCHAR VARCHARACTER', 'Description\n-----------\n\nSee NATIONAL VARCHAR.\n\nExamples\n--------\n\nCREATE TABLE nchar_varcharacter_example (\n example NCHAR VARCHARACTER(32)\n);\n\nURL: https://mariadb.com/docs/server/reference/data-types/string-data-types/nchar-varcharacter', '', 'https://mariadb.com/docs/server/reference/data-types/string-data-types/nchar-varcharacter'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (83, 22, 'NCHAR VARYING', 'Description\n-----------\n\nSee NATIONAL VARCHAR.\n\nExamples\n--------\n\nCREATE TABLE nchar_varying_example (\n example NCHAR VARYING(32)\n);\n\nURL: https://mariadb.com/docs/server/reference/data-types/string-data-types/nchar-varying', '', 'https://mariadb.com/docs/server/reference/data-types/string-data-types/nchar-varying'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (84, 22, 'NCHAR', 'Description\n-----------\n\nSee NATIONAL VARCHAR.\n\nExamples\n--------\n\nCREATE TABLE nchar_example (\n example NCHAR(32)\n);\n\nURL: https://mariadb.com/docs/server/reference/data-types/string-data-types/nchar', '', 'https://mariadb.com/docs/server/reference/data-types/string-data-types/nchar'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (85, 22, 'RAW', 'Description\n-----------\n\nSee VARBINARY.\n\nExamples\n--------\n\nSET sql_mode=''oracle'';\n\nURL: https://mariadb.com/docs/server/reference/data-types/string-data-types/raw', '', 'https://mariadb.com/docs/server/reference/data-types/string-data-types/raw'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (86, 22, 'ROW', 'Syntax\n------\n\nROW ( [{, }... ])\n\nDescription\n-----------\n\nROW is a data type for stored procedure variables.\n\nFeatures\n\nROW fields as normal variables\n\nROW fields (members) act as normal variables, and are able to appear in all query parts where a stored procedure variable is allowed:\n\n Assignment is using the := operator and the SET command:\n\n``sql\na.x:= 10;\na.x:= b.x;\nSET a.x= 10, a.y=20, a.z= b.z;\n`\n\n Passing to functions and operators:\n\n`sql\nSELECT f1(rec.a), rec.a<10;\n`\n\n Clauses (select list, WHERE, HAVING, LIMIT, etc...,):\n\n`sql\nSELECT var.a, t1.b FROM t1 WHERE t1.b=var.b LIMIT var.c;\n`\n\n INSERT values:\n\n`sql\nINSERT INTO t1 VALUES (rec.a, rec.b, rec.c);\n`\n\n SELECT .. INTO targets:\n\n`sql\nSELECT a,b INTO rec.a, rec.b FROM t1 WHERE t1.id=10;\n`\n\n Dynamic SQL out parameters (EXECUTE and EXECUTE IMMEDIATE)\n\n`sql\nEXECUTE IMMEDIATE ''CALL proc_with_out_param(?)'' USING rec.a;\n`\n\nROW type variables as FETCH targets\n\nROW type variables are allowed as FETCH targets:\n\n`sql\nFETCH cur INTO rec;\n`\n\nwhere cur is a CURSOR and rec is a ROW type stored procedure variable.\n\nNote, currently an attempt to use FETCH for a ROW type variable returns this error:\n\n`sql\nERROR 1328 (HY000): Incorrect number of FETCH variables\n`\n\nFETCH from a cursor cur into a ROW variable rec works as follows:\n\n The number of fields in cur must match the number of fields in rec. Otherwise, an error is reported.\n Assignment is done from left to right. The first cursor field is assigned to the first variable field, the second cursor field is assigned to the second variable field, etc.\n Field names in rec are not important and can differ from field names in cur.\n\nSee FETCH Examples (below) for examples of using this withsql_mode=ORACLE and sql_mode=DEFAULT.\n\nROW type variables as SELECT...INTO targets\n\nROW type variables are allowed as SELECT..INTO targets with some differences depending on which sql_mode is in use.\n\n When using sql_mode=ORACLE, table%ROWTYPE and cursor%ROWTYPE variables can be used as SELECT...INTO targets.\n Using multiple ROW variables in the SELECT..INTO list will report an error.\n Using ROW variables with a different column count than in the SELECT..INTO list will report an error.\n\nSee SELECT...INTO Examples (below) for examples of using this with sql_mode=ORACLE and sql_mode=DEFAULT.\n\nFeatures not implemented\n\nThe following features are planned, but not implemented yet:\n\n Returning a ROW type expression from a stored function (see MDEV-12252). This will need some grammar change to support field names after parentheses:\n\n`sql\nSELECT f1().x FROM DUAL;\n`\n\n Returning a ROW type expression from a built-in hybrid type function, such as CASE, IF, etc.\n* ROW of ROW` values\n\nExamples\n--------\n\nDELIMITER $$\nCREATE PROCEDURE p1()\nBEGIN\n DECLARE r ROW (c1 INT, c2 VARCHAR(10));\n SET r.c1= 10;\n SET r.c2= ''test'';\n INSERT INTO t1 VALUES (r.c1, r.c2);\nEND;\n$$\nDELIMITER ;\nCALL p1();\n\nURL: https://mariadb.com/docs/server/reference/data-types/string-data-types/row', '', 'https://mariadb.com/docs/server/reference/data-types/string-data-types/row'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (87, 22, 'SET Data Type', 'Syntax\n------\n\nSET(''value1'',''value2'',...) [CHARACTER SET charset_name] [COLLATE collation_name]\n\nDescription\n-----------\n\nA set. A string object that can have zero or more values, each of which must be chosen from the list of values ''value1'', ''value2'', ... A SET column can have a maximum of 64 members. SET values are\\\nrepresented internally as integers.\n\nSET values cannot contain commas.\n\nIf a SET contains duplicate values, an error will be returned if strict mode is enabled, or a warning if strict mode is not enabled.\n\nExamples\n--------\n\nCREATE TABLE set_example (\n description VARCHAR(20),\n example SET(''Foo'', ''Bar'', ''Baz'', ''Bob'')\n);\n\nURL: https://mariadb.com/docs/server/reference/data-types/string-data-types/set-data-type', '', 'https://mariadb.com/docs/server/reference/data-types/string-data-types/set-data-type'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (88, 22, 'TEXT', 'Syntax\n------\n\nTEXT[(M)] [CHARACTER SET charset_name] [COLLATE collation_name]\n\nDescription\n-----------\n\nIf you are handling large text data that exceeds the max_allowed_packet limit, you can stream the data in chunks using specialized API functions like mysql_stmt_send_long_data() or setCharacterStream(). See Handling Large Data via APIs for more details.\n\nA TEXT column with a maximum length of 65,535 (2¹⁶ - 1) characters. The effective maximum length is less if the value contains multi-byte characters. Each TEXT value is stored using a two-byte length prefix that indicates the number of bytes in the value. If you need a bigger storage, consider using MEDIUMTEXT instead.\n\nAn optional length M can be given for this type. If this is done, MariaDB creates the column as the smallest TEXT type large enough to hold valuesM characters long.\n\nBLOB and TEXT columns can be assigned a DEFAULT value.\n\nExamples\n--------\n\nCREATE TABLE strtest (d TEXT(10));\nINSERT INTO strtest VALUES(''Maria '');\n\nSELECT d=''Maria'',d=''Maria '' FROM strtest;\n+-----------+--------------+\n| d=''Maria'' | d=''Maria '' |\n+-----------+--------------+\n| 1 | 1 |\n+-----------+--------------+\n\nSELECT d LIKE ''Maria'',d LIKE ''Maria '' FROM strtest;\n+----------------+-------------------+\n| d LIKE ''Maria'' | d LIKE ''Maria '' |\n+----------------+-------------------+\n| 0 | 1 |\n+----------------+-------------------+\n\nURL: https://mariadb.com/docs/server/reference/data-types/string-data-types/text', '', 'https://mariadb.com/docs/server/reference/data-types/string-data-types/text'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (89, 22, 'TINYBLOB', 'Syntax\n------\n\nTINYBLOB\n\nDescription\n-----------\n\nA BLOB column with a maximum length of 255 (2⁸ - 1) bytes. Each TINYBLOB value is stored using a one-byte length prefix that indicates the number of bytes in the value.\n\nExamples\n--------\n\nCREATE TABLE tinyblob_example (\n description VARCHAR(20),\n example TINYBLOB\n) DEFAULT CHARSET=latin1; -- One byte per char makes the examples clearer\n\nURL: https://mariadb.com/docs/server/reference/data-types/string-data-types/tinyblob', '', 'https://mariadb.com/docs/server/reference/data-types/string-data-types/tinyblob'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (90, 22, 'TINYTEXT', 'Syntax\n------\n\nTINYTEXT [CHARACTER SET charset_name] [COLLATE collation_name]\n\nDescription\n-----------\n\nA TEXT column with a maximum length of 255 (2⁸ - 1) characters. The effective maximum length is less if the value contains multi-byte characters. Each TINYTEXT value is stored using a one-byte length prefix that indicates the number of bytes in the value.\n\nExamples\n--------\n\nCREATE TABLE tinytext_example (\n description VARCHAR(20),\n example TINYTEXT\n) DEFAULT CHARSET=latin1; -- One byte per char makes the examples clearer\n\nURL: https://mariadb.com/docs/server/reference/data-types/string-data-types/tinytext', '', 'https://mariadb.com/docs/server/reference/data-types/string-data-types/tinytext'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (91, 22, 'UUID Data Type', 'Syntax\n------\n\nUUID\n\nDescription\n-----------\n\nThe UUID data type is intended for the storage of 128-bit UUID (Universally Unique Identifier) data. See the UUID function page for more details on UUIDs themselves.\n\nRetrieval\n\nData retrieved by this data type is in the string representation defined in RFC4122.\n\nCasting\n\nString literals of hexadecimal characters and CHAR/VARCHAR/TEXT can be cast to the UUID data type. Likewise hexadecimal literals, binary-literals, and BINARY/VARBINARY/BLOB types can also be cast to UUID.\n\nThe data type will not accept a short UUID generated with the UUID_SHORT function, but will accept a value without the - character generated by the SYS_GUID function (or inserted directly). Hyphens can be partially omitted as well, or included after any group of two digits.\n\nThe type does not accept UUID values in braces, permitted by some implementations.\n\nStorage\n\nUUID values are stored in an index-friendly manner; the order of a UUID of llllllll-mmmm-Vhhh-vsss-nnnnnnnnnnnn is stored as:\n\n``sql\nnnnnnnnnnnnn-vsss-Vhhh-mmmm-llllllll\n`\n\nThis provides a sorting order, assuming a UUIDv1 (node and timestamp) is used, of the node, followed by the timestamp. The key aspect is the timestamps are sequential.\n\nMariaDB starting with 10.10\n\nTaking into account that UUIDv7 and other versions are designed around time ordering, UUID values version >= 6 are stored without byte-swapping, and UUID values with version >=8 and variant=0 are now considered invalid (as the SQL standard suggests).\n\nUUID values version >= 6 are not stored without byte-swapping, and UUID` values with version >=8 and variant=0 are not considered invalid.\n\nExamples\n--------\n\nCREATE TABLE t1 (id UUID);\n\nURL: https://mariadb.com/docs/server/reference/data-types/string-data-types/uuid-data-type', '', 'https://mariadb.com/docs/server/reference/data-types/string-data-types/uuid-data-type'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (92, 22, 'VARBINARY', 'Syntax\n------\n\nVARBINARY(M)\n\nDescription\n-----------\n\nThe VARBINARY type is similar to the VARCHAR type, but stores binary byte strings rather than non-binary character strings. M represents the maximum column length in bytes.\n\nIt contains no character set, and comparison and sorting are based on the numeric value of the bytes.\n\nIf the maximum length is exceeded, and SQL strict mode is not enabled , the extra characters will be dropped with a warning. If strict mode is enabled, an error will occur.\n\nUnlike BINARY values, VARBINARY values are not right-padded when inserting.\n\nUse Cases for Zero Length\n\nA BINARY(0) or VARBINARY(0) column is restricted to an empty byte string or NULL.\n\n Schema Preservation: Use these columns when a system expects a specific column to exist, but no data storage is required for your current application.\n Space-Efficient Indicators: These columns can act as a two-state indicator where the presence of an empty byte string represents one state and NULL represents another.\n\nIf you attempt to insert a value other than an empty string, MariaDB returns an ERROR 1406 (22001) indicating the data is too long for the column.\n\nOracle Mode\n\nIn Oracle mode, RAW is a synonym for VARBINARY.\n\nExamples\n--------\n\nCREATE TABLE varbins (a VARBINARY(10));\n\nINSERT INTO varbins VALUES(''12345678901'');\nQuery OK, 1 row affected, 1 warning (0.04 sec)\n\nSELECT * FROM varbins;\n+------------+\n| a |\n+------------+\n| 1234567890 |\n+------------+\n\nSET sql_mode=''STRICT_ALL_TABLES'';\n\nINSERT INTO varbins VALUES(''12345678901'');\nERROR 1406 (22001): Data too long for column ''a'' at row 1\n\nURL: https://mariadb.com/docs/server/reference/data-types/string-data-types/varbinary', '', 'https://mariadb.com/docs/server/reference/data-types/string-data-types/varbinary'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (93, 22, 'VARCHAR', 'Syntax\n------\n\n[NATIONAL] VARCHAR(M) [CHARACTER SET charset_name] [COLLATE collation_name]\n\nDescription\n-----------\n\nA variable-length string. M represents the maximum column length in characters. The range of M is 0 to 65,532. The effective maximum length of a VARCHAR is subject to the maximum row size and the character set used. For example, utf-8 characters can require up to three bytes per character, so a VARCHAR column that uses the utf-8 character set can be declared to be a maximum of 21,844 characters.\n\nVARCHAR is shorthand for CHARACTER VARYING. NATIONAL VARCHAR is the standard SQL way to define that a VARCHAR column should use some predefined character set. MariaDB uses utf-8 as its\\\npredefined character set, as does MySQL. NVARCHAR is shorthand for NATIONAL VARCHAR.\n\nMariaDB stores VARCHAR values as a one-byte or two-byte length prefix plus data. The length prefix indicates the number of bytes in the value. A VARCHAR column uses one length byte if values require no more than 255 bytes, two length bytes if values may require more than 255 bytes.\n\nMariaDB follows the standard SQL specification and does not remove trailing spaces from VARCHAR values.\n\nIf a unique index consists of a column where trailing pad characters are stripped or ignored, inserts into that column where values differ only by the number of trailing pad characters will result in a duplicate-key error.\n\nFor the ColumnStore engine, M represents the maximum column length in bytes.\n\nFor MariaDB, a number of NO PAD collations are available.\n\nVARCHAR(0) columns can contain 2 values: an empty string or NULL. Such columns cannot be part of an index. The CONNECT storage engine does not support VARCHAR(0).\n\nUse Cases for Zero Length\n\nA CHAR(0) or VARCHAR(0) column occupies minimal space and is restricted to two possible values: an empty string ('''') or NULL. You can use these columns for the following purposes:\n\n Legacy Compatibility: Include these columns to maintain compatibility with older applications that require a specific table schema, even if the data is no longer collected.\n Two-State Flags: A CHAR(0) NULL column can function as a boolean indicator. It uses only one bit of storage to distinguish between a "set" state (the empty string) and an "unset" state (NULL).\n Row Marking: You can use a CHAR(0) column to mark a specific row in a table. For example, if you require only one "active" row, set that row to an empty string while keeping all other rows NULL.\n\nThe following error occurs if you attempt to insert any character data into a 0-length column: ERROR 1406 (22001): Data too long for column.\n\nSYNONYMS\n\nThe following are synonyms for VARCHAR:\n\n CHAR VARYING\n CHARACTER VARYING\n VARCHAR2\n* VARCHARACTER\n\nExamples\n--------\n\nVARCHAR(30) CHARACTER SET utf8\nNATIONAL VARCHAR(30)\nNVARCHAR(30)\nNCHAR VARCHAR(30)\nNATIONAL CHARACTER VARYING(30)\nNATIONAL CHAR VARYING(30)\n\nURL: https://mariadb.com/docs/server/reference/data-types/string-data-types/varchar', '', 'https://mariadb.com/docs/server/reference/data-types/string-data-types/varchar'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (94, 22, 'VARCHAR2', 'Description\n-----------\n\nThis is a synonym for VARCHAR.\n\nExamples\n--------\n\nSET sql_mode=''oracle'';\n\nCREATE TABLE varchar2_example (\n example VARCHAR2(32)\n);\n\nURL: https://mariadb.com/docs/server/reference/data-types/string-data-types/varchar2', '', 'https://mariadb.com/docs/server/reference/data-types/string-data-types/varchar2'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (95, 22, 'VARCHARACTER', 'Description\n-----------\n\nSee VARCHAR.\n\nExamples\n--------\n\nCREATE TABLE varcharacter_example (\n example VARCHARACTER(32)\n);\n\nURL: https://mariadb.com/docs/server/reference/data-types/string-data-types/varcharacter', '', 'https://mariadb.com/docs/server/reference/data-types/string-data-types/varcharacter'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (96, 22, 'XMLTYPE', 'Description\n-----------\n\nXMLTYPE is a data type introduced in MariaDB 12.3 for storing XML data. It is designed to:\n\n Provide convenient storage of XML data\n Ensure compatibility with Oracle databases\n Support future XML validation and processing capabilities\n\nIn its initial implementation_,_ XMLTYPE provides basic XML storage capabilities only_,_ without validation or specialized XML-specific functionality_._ When using string functions, the data type is effectively converted to strings and is maintained in temporary tables.\n\nCharacteristics\n\n Maximum storage capacity: 4GB (same as LONGBLOB)\n Compatibility: Designed to be compatible with Oracle’s XMLTYPE\n Validation: XML validation or schema enforcement is not supported\n Length restriction: Length cannot be specified.\n\nExample (invalid usage):\n\n``\nCREATE TABLE t1 (a XMLTYPE(6));\n`\n\nXMLTYPE does not accept length parameters, unlike data types such as VARCHAR(255) or DECIMAL(10,2)_._\n\nRelated Functions\n\nWith MariaDB 12.3, the following functions return the XMLTYPE data type:\n\n UPDATEXML \n CAST \n\nExamples\n\nBasic Tables Creation\n\n`\nCREATE TABLE t1(id INT, x xmltype);\nSHOW CREATE TABLE t1;\n`\n\nOutput\n\n`\nTable Create Table\nt1 CREATE TABLE t1 (\n id int(11) DEFAULT NULL,\n x xmltype DEFAULT NULL\n) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci\n`\n\nCharacter Set Specification\n\n`\nCREATE TABLE t1(id INT, x xmltype CHARACTER SET utf8mb3) CHARACTER SET utf8mb4;\nSHOW CREATE TABLE t1;\n`\n\nOutput\n\n`\nTable Create Table\nt1 CREATE TABLE t1 (\n id int(11) DEFAULT NULL,\n x xmltype CHARACTER SET utf8mb3 COLLATE utf8mb3_uca1400_ai_ci DEFAULT NULL\n) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci\n`\n\nBinary Attribute\n\n`\nCREATE TABLE t1 (a xmltype binary) CHARACTER SET utf8mb4;\nSHOW CREATE TABLE t1;\n`\n\nOutput\n\n`\nTable Create Table\nt1 CREATE TABLE t1 (\n a xmltype CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL\n) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci\n`\n\nBasic Data Insertion and Selection\n\n`\nCREATE TABLE t1(id INT, x xmltype);\nINSERT INTO t1 VALUES (1, ''one''), (2, ''two''), (3, ''three'');\nSELECT FROM t1;\n`\n\nOutput\n\n`\nid x\n1 one\n2 two\n3 three\n`\n\nRestrictions and Error Cases\n\nLength Specification Not Permitted\n\nIf a length parameter is provided for XMLTYPE_,_ the system returns an error:\n\n`\nCREATE TABLE t1 (a XMLTYPE(6));\n`\n\nOutput\n\n`\nERROR HY000: Data type ''XMLTYPE'' doesn''t support LENGTH attribute.\n`\n\nREF_SYSTEM_ID Attribute Not Supported\n\n`\nCREATE TABLE t1 (a XMLTYPE REF_SYSTEM_ID=4);\n`\n\nOutput\n\n`\nERROR HY000: Data type ''XMLTYPE'' doesn''t support REF_SYSTEM_ID attribute.\n\n`\n\nLength Parameters in Complex Column Definitions\n\n`\nCREATE TABLE t1(id INT, x xmltype(10, 2));\n`\n\nOutput\n\n`\nERROR HY000: Data type ''xmltype'' doesn''t support LENGTH attribute.\n``\n\nURL: https://mariadb.com/docs/server/reference/data-types/string-data-types/xmltype', '', 'https://mariadb.com/docs/server/reference/data-types/string-data-types/xmltype'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (97, 22, 'TYPE OF', 'Description\n-----------\n\nThis is special declaration only available inside a stored procedure.\n\nExamples\n--------\n\nCREATE TABLE typeof_table(\n descr VARCHAR(20),\n val INT\n);\n\nURL: https://mariadb.com/docs/server/reference/data-types/type-of', '', 'https://mariadb.com/docs/server/reference/data-types/type-of'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (98, 35, 'Options, System & Status Variables', 'Description\n-----------\n\n -a (--ansii)\n --abort-slave-event-count\n Aborted_clients\n Aborted_connects\n Aborted_connects_preauth\n Access_denied_errors\n Acl_column_grants\n Acl_database_grants\n Acl_function_grants\n Acl_package_body_grants\n Acl_package_spec_grants\n Acl_procedure_grants\n Acl_proxy_users\n Acl_role_grants\n Acl_roles\n Acl_table_grants\n Acl_users\n \\--allow-suspicious-udfs, allow_suspicious_udfs\n alter_algorithm\n analyze_max_length\n analyze_sample_percentage\n \\--ansii\n aria_block_size\n aria_checkpoint_interval\n aria_checkpoint_log_activity\n aria_encrypt_tables\n aria_force_start_after_recovery_failures\n aria_group_commit\n aria_group_commit_interval\n aria_log_dir_path\n aria_log_file_size\n aria_log_purge_type\n aria_max_sort_file_size\n aria_page_checksum\n aria_pagecache_age_threshold\n aria_pagecache_blocks_not_flushed\n aria_pagecache_blocks_unused\n aria_pagecache_blocks_used\n aria_pagecache_buffer_size\n aria_pagecache_division_limit\n aria_pagecache_file_hash_size\n aria_pagecache_read_requests\n aria_pagecache_reads\n aria_pagecache_segments\n aria_pagecache_write_requests\n aria_pagecache_writes\n aria_recover\n aria_recover_options\n aria_repair_threads\n aria_sort_buffer_size\n aria_stats_method\n aria_sync_log_dir\n aria_transaction_log_syncs\n aria_used_for_temp_tables\n autocommit\n auto_increment_increment\n auto_increment_offset\n automatic_sp_privileges\n aws_key_management_key_spec\n aws_key_management_log_level\n aws_key_management_master_key_id\n aws_key_management_mock\n aws_key_management_region\n aws_key_management_request_timeout\n aws_key_management_rotate_key\n back_log\n -b, basedir\n big_tables\n bind_address\n binlog_alter_two_phase\n binlog_annotate_row_events\n Binlog_bytes_written\n Binlog_cache_disk_use\n binlog_cache_size\n Binlog_cache_use\n binlog_checksum\n binlog_commit_wait_count\n binlog_commit_wait_usec\n Binlog_commits\n binlog_direct_non_transactional_updates\n Binlog_disk_use\n --binlog-do-db, binlog_do_db\n binlog_expire_logs_seconds\n binlog_file_cache_size\n binlog_format\n Binlog_group_commits\n Binlog_group_commit_trigger_count\n Binlog_group_commit_trigger_lock_wait\n Binlog_group_commit_trigger_timeout\n binlog_gtid_index\n Binlog_gtid_index_hit\n Binlog_gtid_index_miss\n binlog_gtid_index_page_size\n binlog_gtid_index_span_min\n \\--binlog-ignore-db, binlog_ignore_db\n binlog_large_commit_threshold\n binlog_legacy_event_pos\n binlog_optimize_thread_scheduling\n binlog_row_image\n \\--binlog-row-event-max-size, binlog_row_event_max_size\n binlog_row_metadata\n Binlog_snapshot_file\n Binlog_snapshot_position\n binlog_space_limit\n Binlog_stmt_cache_disk_use\n Binlog_stmt_cache_use\n binlog_stmt_cache_size\n block_encryption_mode\n \\--bootstrap\n bulk_insert_buffer_size\n Busy_time\n Bytes_received\n Bytes_sent\n cassandra_default_thrift_host\n cassandra_failure_retries\n cassandra_insert_batch_size\n cassandra_multiget_batch_size\n Cassandra_multiget_keys_scanned\n Cassandra_multiget_reads\n Cassandra_multiget_rows_read\n Cassandra_network_exceptions\n cassandra_read_consistency\n cassandra_rnd_batch_size\n Cassandra_row_inserts\n Cassandra_row_insert_batches\n Cassandra_timeout_exceptions\n Cassandra_unavailable_exceptions\n cassandra_write_consistency\n character_set_client\n \\--character-set-client-handshake\n character_set_collations\n character_set_connection\n character_set_database\n character_set_filesystem\n character_set_results\n -C, character_set_server\n character_set_system\n character_sets_dir\n check_constraint_checks\n -r, --chroot\n collation_connection\n collation_database\n collation_server\n Column_compressions\n column_compression_threshold\n column_compression_zlib_level\n column_compression_zlib_strategy\n column_compression_zlib_wrap\n Column_decompressions\n Com_admin_commands\n Com_alter_db\n Com_alter_db_upgrade\n Com_alter_event\n Com_alter_function\n Com_alter_procedure\n Com_alter_sequence\n Com_alter_server\n Com_alter_table\n Com_alter_tablespace\n Com_alter_user\n Com_analyze\n Com_assign_to_keycache\n Com_backup\n Com_backup_lock\n Com_backup_table\n Com_begin\n Com_binlog\n Com_call_procedure\n Com_change_db\n Com_change_master\n Com_check\n Com_checksum\n Com_commit\n Com_compound_sql\n Com_create_db\n Com_create_event\n Com_create_function\n Com_create_index\n Com_create_package\n Com_create_package_body\n Com_create_procedure\n Com_create_role\n Com_create_sequence\n Com_create_server\n Com_create_table\n Com_create_temporary_table\n Com_create_trigger\n Com_create_udf\n Com_create_user\n Com_create_view\n Com_dealloc_sql\n Com_delete\n Com_delete_multi\n Com_do\n Com_drop_db\n Com_drop_event\n Com_drop_function\n Com_drop_index\n Com_drop_package\n Com_drop_package_body\n Com_drop_procedure\n Com_drop_role\n Com_drop_sequence\n Com_drop_server\n Com_drop_table\n Com_drop_temporary_table\n Com_drop_trigger\n Com_drop_user\n Com_drop_user\n Com_drop_view\n Com_empty_query\n Com_execute_immediate\n Com_execute_sql\n Com_flush\n Com_get_diagnostics\n Com_grant\n Com_grant_role\n Com_ha_close\n Com_ha_open\n Com_ha_read\n Com_help\n Com_insert\n Com_insert_select\n Com_install_plugin\n Com_kill\n Com_load\n Com_load_master_data\n Com_load_master_table\n Com_lock_tables\n Com_multi\n Com_optimize\n Com_preload_keys\n Com_prepare_sql\n Com_purge\n Com_purge_before_date\n Com_release_savepoint\n Com_rename_table\n Com_rename_user\n Com_repair\n Com_replace\n Com_replace_select\n Com_reset\n Com_resignal\n Com_restore_table\n Com_revoke\n Com_revoke_all\n Com_revoke_grant\n Com_rollback\n Com_rollback_to_savepoint\n Com_savepoint\n Com_select\n Com_set_option\n Com_show_authors\n Com_show_binlog_events\n Com_show_binlogs\n Com_show_charsets\n Com_show_client_statistics\n Com_show_collations\n Com_show_column_types\n Com_show_contributors\n Com_show_create_db\n Com_show_create_event\n Com_show_create_func\n Com_show_create_package\n Com_show_create_package_body\n Com_show_create_proc\n Com_show_create_table\n Com_show_create_trigger\n Com_show_create_user\n Com_show_databases\n Com_show_engine_logs\n Com_show_engine_mutex\n Com_show_engine_status\n Com_show_events\n Com_show_errors\n Com_show_explain\n Com_show_fields\n Com_show_function_status\n Com_show_generic\n Com_show_grants\n Com_show_keys\n Com_show_index_statistics\n Com_show_binlog_status\n Com_show_master_status\n Com_show_new_master\n Com_show_open_tables\n Com_show_package_status\n Com_show_package_body_status\n Com_show_plugins\n Com_show_privileges\n Com_show_procedure_status\n Com_show_processlist\n Com_show_profile\n Com_show_profiles\n Com_show_relaylog_events\n Com_show_slave_hosts\n Com_show_slave_status\n Com_show_status\n Com_show_storage_engines\n Com_show_table_statistics\n Com_show_table_status\n Com_show_tables\n Com_show_triggers\n Com_show_user_statistics\n Com_show_variable\n Com_show_warnings\n Com_shutdown\n Com_signal\n Com_slave_start\n Com_slave_stop\n Com_start_all_slaves\n Com_start_slave\n Com_stop_all_slaves\n Com_stop_slave\n Com_stmt_close\n Com_stmt_execute\n Com_stmt_fetch\n Com_stmt_prepare\n Com_stmt_reprepare\n Com_stmt_reset\n Com_stmt_send_long_data\n Com_truncate\n Com_uninstall_plugin\n Com_unlock_tables\n Com_update\n Com_update_multi\n Com_xa_commit\n Com_xa_end\n Com_xa_prepare\n Com_xa_recover\n Com_xa_rollback\n Com_xa_start\n completion_type\n Compression\n concurrent_insert\n connect_class_path\n connect_cond_push\n connect_conv_size\n connect_default_depth\n connect_default_prec\n connect_enable_mongo\n connect_exact_info\n connect_force_bson\n connect_indx_map\n connect_java_wrapper\n connect_json_all_path\n connect_json_grp_size\n connect_json_null\n connect_jvm_path\n connect_timeout\n connect_type_conv\n connect_use_tempfile\n connect_work_size\n connect_xtrace\n Connection_errors_accept\n Connection_errors_internal\n Connection_errors_max_connections\n Connection_errors_peer_address\n Connection_errors_select\n Connection_errors_tcpwrap\n Connections\n --console\n core_file\n Cpu_time\n \\--cracklib-password-check\n cracklib_password_check-dictionary\n create_tmp_table_binlog_formats\n Created_tmp_disk_tables\n Created_tmp_files\n Created_tmp_tables\n -h, datadir\n date_format\n datetime_format\n deadlock_search_depth_long\n deadlock_search_depth_short\n deadlock_timeout_long\n deadlock_timeout_short\n -#, debug\n --debug-assert-if-crashed-table\n --debug-binlog-fsync-sleep\n --debug-crc-break\n --debug-flush\n --debug-no-sync\n debug_no_thread_alarm\n debug_sync\n --debug-sync-timeout\n \\--default-character-set\n default_master_connection\n default_password_lifetime\n default_regex_flags\n default_storage_engine\n default_table_type\n default_tmp_storage_engine\n \\--default-time-zone\n default_week_format\n \\--defaults-extra-file\n \\--defaults-file\n delay_key_write\n Delayed_errors\n delayed_insert_limit\n Delayed_insert_threads\n delayed_insert_timeout\n delayed_queue_size\n Delayed_writes\n Delete_scan\n \\--des-key-file\n disconnect_on_expired_password\n \\--disconnect-slave-event-count\n \\--disks\n div_precision_increment\n Empty_queries\n encrypt_binlog\n encrypt_tmp_disk_tables\n encrypt_tmp_files\n encryption_algorithm\n enforce_storage_engine\n engine_condition_pushdown\n eq_range_index_dive_limit\n error_count\n event_scheduler\n Executed_events\n Executed_triggers\n -T, --exit-info\n expensive_subquery_limit\n expire_logs_days\n explicit_defaults_for_timestamp\n \\--external-locking\n external_user\n extra_max_connections\n extra_port\n Feature_application_time_periods\n Feature_check_constraint\n Feature_custom_aggregate_functions\n Feature_delay_key_write\n Feature_dynamic_columns\n Feature_fulltext\n Feature_gis\n Feature_insert_returning\n Feature_invisible_columns\n Feature_json\n Feature_locale\n Feature_subquery\n Feature_timezone\n Feature_trigger\n Feature_window_functions\n Feature_xml\n \\--feedback\n feedback_http_proxy\n feedback_send_retry_wait\n feedback_send_timeout\n feedback_server_uid\n feedback_url\n feedback_user_info\n file_key_management_encryption_algorithm\n file_key_management_filekey\n file_key_management_filename\n \\--flashback\n flush\n Flush_commands\n flush_time\n foreign_key_checks\n ft_boolean_syntax\n ft_max_word_len\n ft_min_word_len\n ft_query_expansion_limit\n ft_stopword_file\n \\--gdb\n general_log\n general_log_file\n \\--getopt-prefix-matching\n group_concat_max_len\n gssapi_keytab_path\n gssapi_principal_name\n gssapi_mech_name\n gtid_binlog_pos\n gtid_binlog_state\n gtid_cleanup_batch_size\n gtid_current_pos\n gtid_domain_id\n gtid_ignore_duplicates\n gtid_pos_auto_engines\n gtid_seq_no\n gtid_slave_pos\n gtid_strict_mode\n -h, datadir\n Handler_commit\n Handler_delete\n Handler_discover\n Handler_external_lock\n Handler_icp_attempts\n Handler_icp_match\n Handler_mrr_init\n Handler_mrr_key_refills\n Handler_mrr_rowid_refills\n Handler_prepare\n Handler_read_first\n Handler_read_key\n Handler_read_last\n Handler_read_next\n Handler_read_prev\n Handler_read_retry\n Handler_read_rnd\n Handler_read_rnd_deleted\n Handler_read_rnd_next\n Handler_rollback\n Handler_savepoint\n Handler_savepoint_rollback\n Handler_tmp_delete\n Handler_tmp_update\n Handler_tmp_write\n Handler_update\n Handler_write\n handlersocket_accept_balance\n handlersocket_address\n handlersocket_backlog\n handlersocket_epoll\n handlersocket_plain_secret\n handlersocket_plain_secret_wr\n handlersocket_port\n handlersocket_port_wr\n handlersocket_rcvbuf\n handlersocket_readsize\n handlersocket_sndbuf\n handlersocket_threads\n handlersocket_threads_wr\n handlersocket_timeout\n handlersocket_verbose\n handlersocket_wrlock_timeout\n hashicorp-key-management-cache-timeout\n hashicorp-key-management-cache-version-timeout\n hashicorp-key-management-caching-enabled\n hashicorp-key-management-check-kv-version\n hashicorp-key-management-max-retries\n hashicorp-key-management-timeout\n hashicorp-key-management-token\n hashicorp-key-management-use-cache-on-timeout\n hashicorp-key-management-vault-ca\n hashicorp-key-management-vault-url\n have_compress\n have_crypt\n have_csv\n have_dynamic_loading\n have_geometry\n have_innodb\n have_ndbcluster\n have_openssl\n have_partitioning\n have_profiling\n have_query_cache\n have_rtree_keys\n have_ssl\n have_symlink\n \\--help\n histogram_size\n histogram_type\n host_cache_size\n hostname\n identity\n idle_readonly_transaction_timeout\n idle_transaction_timeout\n idle_write_transaction_timeout\n ignore_db_dirs\n ignore_builtin_innodb\n in_predicate_conversion_threshold\n in_transaction\n init_connect\n init_file\n \\--init-rpl-role\n init_slave\n \\--innodb\n innodb_adaptive_checkpoint\n innodb_adaptive_flushing\n innodb_adaptive_flushing_lwm\n innodb_adaptive_flushing_method\n Innodb_adaptive_hash_cells\n Innodb_adaptive_hash_hash_searches\n Innodb_adaptive_hash_heap_buffers\n innodb_adaptive_hash_index\n innodb_adaptive_hash_index_partitions\n innodb_adaptive_hash_index_parts\n Innodb_adaptive_hash_non_hash_searches\n innodb_adaptive_max_sleep_delay\n innodb_additional_mem_pool_size\n innodb_alter_copy_bulk\n innodb_api_bk_commit_interval\n innodb_api_disable_rowlock\n innodb_api_enable_binlog\n innodb_api_enable_mdl\n innodb_api_trx_level\n Innodb_async_reads_pending\n Innodb_async_reads_queue_size\n Innodb_async_reads_tasks_running\n Innodb_async_reads_total_enqueues\n Innodb_async_reads_total_count\n Innodb_async_reads_wait_slot_sec\n Innodb_async_writes_pending\n Innodb_async_writes_queue_size\n Innodb_async_writes_tasks_running\n Innodb_async_writes_total_enqueues\n Innodb_async_writes_total_count\n Innodb_async_writes_wait_slot_sec\n innodb-auto-lru-dump\n innodb_autoextend_increment\n innodb_autoinc_lock_mode\n Innodb_available_undo_logs\n Innodb_background_log_sync\n innodb_background_scrub_data_check_interval\n innodb_background_scrub_data_compressed\n innodb_background_scrub_data_interval\n innodb_background_scrub_data_uncompressed\n innodb_blocking_buffer_pool_restore\n innodb_buf_dump_status_frequency\n Innodb_buffer_pool_bytes_data\n Innodb_buffer_pool_bytes_dirty\n innodb_buffer_pool_chunk_size\n innodb_buffer_pool_dump_at_shutdown\n innodb_buffer_pool_dump_now\n innodb_buffer_pool_dump_pct\n Innodb_buffer_pool_dump_status\n innodb_buffer_pool_evict\n innodb_buffer_pool_filename\n innodb_buffer_pool_instances\n innodb_buffer_pool_load_abort\n innodb_buffer_pool_load_at_startup\n innodb_buffer_pool_load_now\n Innodb_buffer_pool_load_incomplete\n innodb_buffer_pool_load_pages_abort\n Innodb_buffer_pool_load_status\n Innodb_buffer_pool_pages_data\n Innodb_buffer_pool_pages_dirty\n Innodb_buffer_pool_pages_flushed\n Innodb_buffer_pool_pages_LRU_flushed\n Innodb_buffer_pool_pages_LRU_freed\n Innodb_buffer_pool_pages_free\n Innodb_buffer_pool_pages_made_not_young\n Innodb_buffer_pool_pages_made_young\n Innodb_buffer_pool_pages_misc\n Innodb_buffer_pool_pages_old\n Innodb_buffer_pool_pages_total\n innodb_buffer_pool_populate\n Innodb_buffer_pool_read_ahead\n Innodb_buffer_pool_read_ahead_evicted\n Innodb_buffer_pool_read_ahead_rnd\n Innodb_buffer_pool_read_requests\n Innodb_buffer_pool_reads\n Innodb_buffer_pool_resize_status\n innodb_buffer_pool_restore_at_startup\n innodb_buffer_pool_shm_checksum\n innodb_buffer_pool_shm_key\n innodb_buffer_pool_size\n innodb_buffer_pool_size_auto_min\n innodb_buffer_pool_size_max\n Innodb_buffer_pool_wait_free\n Innodb_buffer_pool_write_requests\n Innodb_buffered_aio_submitted\n innodb_change_buffer_dump\n innodb_change_buffer_max_size\n innodb_change_buffering\n innodb_change_buffering_debug\n Innodb_checkpoint_age\n innodb_checkpoint_age_target\n Innodb_c\n\n[Truncated — full content at mariadb.com/docs]', '', 'https://mariadb.com/docs/server/reference/full-list-of-mariadb-options-system-and-status-variables'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (99, 5, 'Authentication Plugin - caching\\_sha2\\_password', 'Description\n-----------\n\nTo aid migrations MariaDB provides MySQL compatible caching_sha2_password authentication plugin. It allows to move users from MySQL to MariaDB without requiring them to change their passwords. It should be only used for migration, otherwise a more secure and convenient PARSEC plugin is recommended.\n\nInstalling the Plugin\n\nThe caching_sha2_password authentication plugin''s shared library is included in MariaDB packages as the auth_mysql_sha2.so or auth_mysql_sha2.dll shared library on systems where it can be built.\n\nAlthough the plugin''s shared library is distributed with MariaDB, the plugin is not actually installed into MariaDB by default. There are two methods that can be used to install the plugin into MariaDB.\n\nThe first method can be used to install the plugin without restarting the server. You can install the plugin dynamically by executing INSTALL SONAME or INSTALL PLUGIN:\n\n``sql\nINSTALL SONAME ''auth_mysql_sha2'';\n`\n\nThe second method can be used to tell the server to load the plugin when it starts up. The plugin can be installed this way by providing the --plugin-load or the --plugin-load-add options. This can be specified as a command-line argument to mariadbd or it can be specified in a relevant server option group in an option file:\n\n`ini\n[mariadb]\n...\nplugin_load_add = auth_mysql_sha2\n`\n\nUninstalling the Plugin\n\nYou can uninstall the plugin dynamically by executing UNINSTALL SONAME or UNINSTALL PLUGIN:\n\n`sql\nUNINSTALL SONAME ''auth_mysql_sha2'';\n`\n\nIf you installed the plugin by providing the --plugin-load or the --plugin-load-add options in a relevant server option group in an option file, then those options must be removed to prevent the plugin from being loaded the next time the server is restarted.\n\nUsing the Plugin\n\nTo create a user in MariaDB that was using caching_sha2_password plugin in MySQL, issue this statement:\n\n`sql\nCREATE USER user@host IDENTIFIED WITH caching_sha2_password USING ''authentication_string'';\n`\n\nHere, authentication_string is taken from the mysql.user table for the corresponding user in MySQL installation. Beware that the authentication string for caching_sha2_password in MySQL can contain non-printable characters and copying it from the terminal window will likely not work.\n\nSystem Variables\n\ncaching_sha2_password_private_key_path\n\n Description: A path to the private RSA key used for authentication.\n Command line: --caching-sha2-password-private-key-path\n Scope: Global\n Dynamic: No\n Data Type: string\n Default Value: private_key.pem\n Introduced: MariaDB 11.4.9, MariaDB 11.8.4\n\ncaching_sha2_password_public_key_path\n\n Description: A path to the public RSA key used for authentication.\n Command line: --caching-sha2-password-public-key-path\n Scope: Global\n Dynamic: No\n Data Type: string\n Default Value: public_key.pem\n Introduced: MariaDB 11.4.9, MariaDB 11.8.4\n\ncaching_sha2_password_auto_generate_rsa_keys\n\n Description: Auto generate RSA keys at server startup if key paths are not explicitly set and key files are not present at their default locations.\n Command line: --caching-sha2-password-auto-generate-rsa-keys\n Scope: Global\n Dynamic: No\n Data Type: boolean\n Default Value: ON\n Introduced: MariaDB 11.4.9, MariaDB 11.8.4\n\ncaching_sha2_password_digest_rounds\n\n Description: Number of SHA2 rounds to be performed when computing a password hash.\n Command line: --caching-sha2-password-digest-rounds\n Scope: Global\n Dynamic: No\n Data Type: integer\n Default Value: 5000`\n Introduced: MariaDB 11.4.9, MariaDB 11.8.4\n\nURL: https://mariadb.com/docs/server/reference/plugins/authentication-plugins/authentication-plugin-caching_sha2_password', '', 'https://mariadb.com/docs/server/reference/plugins/authentication-plugins/authentication-plugin-caching_sha2_password'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (100, 5, 'Authentication Plugin - ed25519', 'Description\n-----------\n\nMySQL has used SHA-1 based authentication since version 4.1. The authentication plugin is called mysql_native_password. Over the years as computers became faster, new attacks on SHA-1 were being developed. Nowadays SHA-1 is no longer considered as secure as it was in 2001. That''s why the ed25519 authentication plugin was created.\n\nThe ed25519 authentication plugin uses Elliptic Curve Digital Signature Algorithm (ECDSA) to securely store users'' passwords and to authenticate users. The ed25519 algorithm is the same one that is used by OpenSSH. It is based on the elliptic curve and code created by Daniel J. Bernstein.\n\nInstalling the Plugin\n\nAlthough the plugin''s shared library is distributed by default with MariaDB, with a file name of auth_ed25519.so (Unix) or auth_ed25519.dll (Windows), the plugin is not actually installed by MariaDB by default. There are two methods that can be used to install the plugin with MariaDB.\n\nThe first method can be used to install the plugin without restarting the server. You can install the plugin dynamically by executing INSTALL SONAME or INSTALL PLUGIN:\n\n``sql\nINSTALL SONAME ''auth_ed25519'';\n`\n\nThe second method can be used to tell the server to load the plugin when it starts up. The plugin can be installed this way by providing the --plugin-load or the --plugin-load-add options. This can be specified as a command-line argument to mariadbd or it can be specified in a relevant server option group in an option file:\n\n`ini\n[mariadb]\n...\nplugin_load_add = auth_ed25519\n`\n\nUninstalling the Plugin\n\nYou can uninstall the plugin dynamically by executing UNINSTALL SONAME or UNINSTALL PLUGIN:\n\n`sql\nUNINSTALL SONAME ''auth_ed25519'';\n`\n\nIf you installed the plugin by providing the --plugin-load or the --plugin-load-add options in a relevant server option group in an option file, those options must be removed to prevent the plugin from being loaded the next time the server is restarted.\n\nCreating Users\n\nYou can create a user account by executing the CREATE USER statement and providing the IDENTIFIED VIA clause followied by the name of the plugin, ed25519, and providing the USING clause followed by the PASSWORD() function, with the plain-text password as an argument:\n\n`sql\nCREATE USER username@hostname IDENTIFIED VIA ed25519 USING PASSWORD(''secret'');\n`\n\nIf SQL_MODE does not have NO_AUTO_CREATE_USER set, then you can also create the user account via GRANT:\n\n`sql\nGRANT SELECT ON db. TO username@hostname IDENTIFIED VIA ed25519 USING PASSWORD(''secret'');\n`\n\nThe PASSWORD() function and SET PASSWORD statements don''t work with the ed25519 authentication plugin. Instead, you have to use the UDF that comes with the authentication plugin to calculate the password hash:\n\n`sql\nCREATE FUNCTION ed25519_password RETURNS STRING SONAME "auth_ed25519.so";\n`\n\nNow you can calculate a password hash by executing this query:\n\n`sql\nSELECT ed25519_password("secret");\n+---------------------------------------------+\n| SELECT ed25519_password("secret"); |\n+---------------------------------------------+\n| ZIgUREUg5PVgQ6LskhXmO+eZLS0nC8be6HPjYWR4YJY |\n+---------------------------------------------+\n`\n\nNow you can use it to create the user account using the new password hash. As with any password, you should always use a complex password that isn''t easy to guess. If you don''t, if anyone gets access to the stored passwords in the mysql.user table, they could use rainbow tables to figure out the original password.\n\nTo create a user account via CREATE USER, specify the name of the plugin in the IDENTIFIED VIA clause while providing the password hash as the USING clause:\n\n`sql\nCREATE USER username@hostname IDENTIFIED VIA ed25519 \n USING ''ZIgUREUg5PVgQ6LskhXmO+eZLS0nC8be6HPjYWR4YJY'';\n`\n\nIf SQL_MODE does not have NO_AUTO_CREATE_USER set, you can also create the user account via GRANT:\n\n`sql\nGRANT SELECT ON db. TO username@hostname IDENTIFIED VIA ed25519 \n USING ''ZIgUREUg5PVgQ6LskhXmO+eZLS0nC8be6HPjYWR4YJY'';\n`\n\nNote that users require a password in order to be able to connect. It is possible to create users without specifying a password, but they will be unable to connect.\n\nChanging User Passwords\n\nYou can change a user account''s password by executing the SET PASSWORD statement followed by the PASSWORD() function and providing the plain-text password as an argument:\n\n`sql\nSET PASSWORD = PASSWORD(''new_secret'')\n`\n\nYou can also change the user account''s password with the ALTER USER statement. You would have to specify the name of the plugin in the IDENTIFIED VIA clause while providing the plain-text password as an argument to the PASSWORD() function in the USING clause:\n\n`sql\nALTER USER username@hostname IDENTIFIED VIA ed25519 USING PASSWORD(''new_secret'');\n`\n\nThe PASSWORD() function and SET PASSWORD statement did not work with the ed25519 authentication plugin. Instead, you would have to use the UDF that comes with the authentication plugin to calculate the password hash:\n\n`sql\nCREATE FUNCTION ed25519_password RETURNS STRING SONAME "auth_ed25519.so";\n`\n\nNow you can calculate a password hash by executing this query:\n\n`sql\nSELECT ed25519_password("secret");\n+---------------------------------------------+\n| SELECT ed25519_password("secret"); |\n+---------------------------------------------+\n| ZIgUREUg5PVgQ6LskhXmO+eZLS0nC8be6HPjYWR4YJY |\n+---------------------------------------------+\n`\n\nNow you can change the user account''s password using the new password hash.\n\nYou can change the user account''s password with the ALTER USER statement. You have to specify the name of the plugin in the IDENTIFIED VIA clause, while providing the password hash as the USING clause:\n\n`sql\nALTER USER username@hostname IDENTIFIED VIA ed25519 \n USING ''ZIgUREUg5PVgQ6LskhXmO+eZLS0nC8be6HPjYWR4YJY'';\n`\n\nClient Authentication Plugins\n\nFor clients that use the libmysqlclient or MariaDB Connector/C libraries, MariaDB provides one client authentication plugin that is compatible with the ed25519 authentication plugin:\n\n client_ed25519\n\nWhen connecting with a client or utility to a server as a user account that authenticates with the ed25519 authentication plugin, you may need to tell the client where to find the relevant client authentication plugin by specifying the --plugin-dir option:\n\n`bash\nmysql --plugin-dir=/usr/local/mysql/lib64/mysql/plugin --user=alice\n`\n\nclient_ed25519\n\nThe client_ed25519 client authentication plugin hashes and signs the password using the Elliptic Curve Digital Signature Algorithm (ECDSA) before sending it to the server.\n\nSupport in Client Libraries\n\nUsing the Plugin with MariaDB Connector/C\n\nMariaDB Connector/C supports ed25519 authentication using the client authentication plugins mentioned in the previous section.\n\nUsing the Plugin with MariaDB Connector/ODBC\n\nMariaDB Connector/ODBC supports ed25519 authentication using the client authentication plugins mentioned in the previous section.\n\nUsing the Plugin with MariaDB Connector/J\n\nMariaDB Connector/J supports ed25519 authentication.\n\nUsing the Plugin with MariaDB Connector/Node.js\n\nMariaDB Connector/Node.js supports ed25519 authentication.\n\nUsing the Plugin with MySqlConnector for .NET\n\nMySqlConnector for ADO.NET supports ed25519 authentication.\n\nThe connector implemented support for this authentication plugin in a separate NuGet package called MySqlConnector.Authentication.Ed25519. After the package is installed, your application must call Ed25519AuthenticationPlugin.Install to enable it.\n\nOptions\n\ned25519\n\n Description: Controls how the server should treat the plugin when it starts up.\n Valid values are:\n OFF - Disables the plugin without removing it from the mysql.plugins table.\n ON - Enables the plugin. If the plugin cannot be initialized, then the server will still continue starting up, but the plugin will be disabled.\n FORCE - Enables the plugin. If the plugin cannot be initialized, then the server will fail to start with an error.\n FORCE_PLUS_PERMANENT - Enables the plugin. If the plugin cannot be initialized, then the server will fail to start with an error. In addition, the plugin cannot be uninstalled with UNINSTALL SONAME or UNINSTALL PLUGIN while the server is running.\n See Plugin Overview: Configuring Plugin Activation at Server Startup for more information.\n Command line: --ed25519=value\n Data Type: enumerated\n Default Value: ON\n Valid Values: OFF, ON, FORCE, FORCE_PLUS_PERMANENT`\n\nURL: https://mariadb.com/docs/server/reference/plugins/authentication-plugins/authentication-plugin-ed25519', '', 'https://mariadb.com/docs/server/reference/plugins/authentication-plugins/authentication-plugin-ed25519'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (101, 5, 'Authentication Plugin - GSSAPI', 'Description\n-----------\n\nThe gssapi authentication plugin allows the user to authenticate with services that use the Generic Security Services Application Program Interface (GSSAPI). Windows has a slightly different but very similar API called Security Support Provider Interface (SSPI). The GSSAPI is a standardized API described in RFC2743 and RFC2744. The client and server negotiate using a standardized protocol described in RFC7546.\n\nOn Windows, this authentication plugin supports Kerberos and NTLM authentication. Windows authentication is supported regardless of whether a domain is used in the environment.\n\nOn Unix systems, the most dominant GSSAPI service is Kerberos). However, it is less commonly used on Unix systems than it is on Windows. Regardless, this authentication plugin also supports Kerberos authentication on Unix.\n\nThe gssapi authentication plugin is most often used for authenticating with Microsoft Active Directory.\n\nThis article gives instructions on configuring the gssapi authentication plugin\\\nfor MariaDB for passwordless login.\n\nInstalling the Plugin''s Package\n\nSince MariaDB 10.11, on Windows, the plugin is included in the server. There is no need for separate installation.\n\nThe gssapi authentication plugin''s shared library is included in MariaDB packages as the auth_gssapi.so or auth_gssapi.dll shared library on systems where it can be built.\n\nInstalling on Linux\n\nThe gssapi authentication plugin is included in binary tarballs on Linux.\n\nInstalling with a Package Manager\n\nThe gssapi authentication plugin can also be installed via a package manager on Linux. In order to do so, your system needs to be configured to install from one of the MariaDB repositories.\n\nYou can configure your package manager to install it from MariaDB Corporation''s MariaDB Package Repository by using the MariaDB Package Repository setup script.\n\nYou can also configure your package manager to install it from MariaDB Foundation''s MariaDB Repository by using the MariaDB Repository Configuration Tool.\n\nInstalling with yum/dnf\n\nOn RHEL, CentOS, Fedora, and other similar Linux distributions, it is highly recommended to install the relevant RPM package from MariaDB''s repository using yum or dnf). Starting with RHEL 8 and Fedora 22, yum has been replaced by dnf, which is the next major version of yum. However, yum commands still work on many systems that use dnf:\n\n``bash\nsudo yum install MariaDB-gssapi-server\n`\n\nInstalling with apt-get\n\nOn Debian, Ubuntu, and other similar Linux distributions, it is highly recommended to install the relevant DEB package from MariaDB''s repository using apt-get:\n\n`bash\nsudo apt-get install mariadb-plugin-gssapi-server\n`\n\nInstalling with zypper\n\nOn SLES, OpenSUSE, and other similar Linux distributions, it is highly recommended to install the relevant RPM package from MariaDB''s repository using zypper:\n\n`bash\nsudo zypper install MariaDB-gssapi-server\n`\n\nInstalling on Windows\n\nBefore MariaDB 10.11, the gssapi authentication plugin is included in MSI and ZIP packages on Windows.\n\nInstalling the Plugin\n\nSince MariaDB 10.11, on Windows, the plugin is included in the server. There is no need for separate installation.\n\nOn Windows, and on other operating systems, although the plugin''s shared library is distributed with MariaDB by default, the plugin is not actually installed by MariaDB by default. There are two methods that can be used to install the plugin with MariaDB.\n\nThe first method can be used to install the plugin without restarting the server. You can install the plugin dynamically by executing INSTALL SONAME or INSTALL PLUGIN:\n\n`sql\nINSTALL SONAME ''auth_gssapi'';\n`\n\nThe second method can be used to tell the server to load the plugin when it starts up. The plugin can be installed this way by providing the --plugin-load or the --plugin-load-add options. This can be specified as a command-line argument to mariadbd or it can be specified in a relevant server option group in an option file:\n\n`ini\n[mariadb]\n...\nplugin_load_add = auth_gssapi\n`\n\nUninstalling the Plugin\n\nYou can uninstall the plugin dynamically by executing UNINSTALL SONAME or UNINSTALL PLUGIN:\n\n`sql\nUNINSTALL SONAME ''auth_gssapi'';\n`\n\nIf you installed the plugin by providing the --plugin-load or the --plugin-load-add options in a relevant server option group in an option file, then those options must be removed to prevent the plugin from being loaded the next time the server is restarted.\n\nConfiguring the Plugin\n\nIf the MariaDB server is running on Unix, then some additional configuration steps will need to be implemented in order to use the plugin.\n\nIf the MariaDB server is running on Windows, then no special configuration steps will need to be implemented in order to use the plugin, as long as the following is true:\n\n The Windows server is joined to a domain.\n The MariaDB server process is running as either a NetworkService Account or a Domain User Account.\n\nCreating a Keytab File on Unix\n\nIf the MariaDB server is running on Unix, then the KDC server will need to create a keytab file for the MariaDB server. The keytab file contains the service principal name, which is the identity that the MariaDB server will use to communicate with the KDC server. The keytab will need to be transferred to the MariaDB server, and the mysqld server process will need read access to this keytab file.\n\nHow this keytab file is generated depends on whether the KDC server is Microsoft Active Directory KDC or MIT Kerberos KDC.\n\nCreating a Keytab File with Microsoft Active Directory\n\nIf you are using Microsoft Active Directory KDC, you may need to create a keytab using the ktpass.exe utility on a Windows host. The service principal will need to be mapped to an existing domain user. To do so, follow the steps listed below.\n\nBe sure to replace the following items in the step below:\n\n Replace ${HOST} with the fully qualified DNS name for the MariaDB server host.\n Replace ${DOMAIN} with the Active Directory domain.\n Replace ${AD_USER} with the existing domain user.\n Replace ${PASSWORD} with the password for the service principal.\n\nTo create the service principal, execute the following command:\n\n`bash\nktpass.exe /princ mariadb/${HOST}@${DOMAIN} /mapuser ${AD_USER} /pass ${PASSWORD} /out mariadb.keytab /crypto all /ptype KRB5_NT_PRINCIPAL /mapop set\n`\n\nCreating a Keytab File with MIT Kerberos\n\nIf you are using MIT Kerberos KDC, then you can create a keytab file using the kadmin utility. To do so, follow the steps listed below.\n\nIn the following steps, be sure to replace ${HOST} with the fully qualified DNS name for the MariaDB server host.\n\nFirst, create the service principal using the kadmin utility:\n\n`bash\nkadmin -q "addprinc -randkey mariadb/${HOST}"\n`\n\nThen, export the newly created user to the keytab file using the kadmin utility:\n\n`bash\nkadmin -q "ktadd -k /path/to/mariadb.keytab mariadb/${HOST}"\n`\n\nMore details can be found at the following links:\n\n MIT Kerberos Documentation: Database administration\n MIT Kerberos Documentation: Application servers\n\nConfiguring the Path to the Keytab File on Unix\n\nIf the MariaDB server is running on Unix, then the path to the keytab file that was previously created can be set by configuring the gssapi_keytab_path system variable. This can be specified as a command-line argument to mariadbd, or it can be specified in a relevant server option group in an option file:\n\n`ini\n[mariadb]\n...\ngssapi_keytab_path=/path/to/mariadb.keytab\n`\n\nConfiguring the Service Principal Name\n\nThe service principal name can be set by configuring the gssapi_principal_name system variable. This can be specified as a command-line argument to mariadbd, or it can be specified in a relevant server option group in an option file:\n\n`ini\n[mariadb]\n...\ngssapi_principal_name=service_principal_name/host.domain.com@REALM\n`\n\nIf a service principal name is not provided, the plugin tries to use mariadb/host.domain.com@REALM by default.\n\nIf the MariaDB server is running on Unix, the plugin needs a service principal name in order to function.\n\nIf the MariaDB server is running on Windows, the plugin does not usually need a service principal in order to function. However, if you want to use one, anyway, it can be created with the setspn utility.\n\nDifferent KDC implementations may use different canonical forms to identify principals. See RFC2744: Section 3.10 to learn what the standard says about principal names.\n\nMore details can be found at the following links:\n\n Active Directory Domain Services: Service Principal Names\n MIT Kerberos Documentation: Realm configuration decisions\n MIT Kerberos Documentation: Principal names and DNS\n\nCreating Users\n\nTo create a user account via CREATE USER, specify the name of the plugin in the IDENTIFIED VIA clause:\n\n`sql\nCREATE USER username@hostname IDENTIFIED VIA gssapi;\n`\n\nIf SQL_MODE does not have NO_AUTO_CREATE_USER set, then you can also create the user account via GRANT:\n\n`sql\nGRANT SELECT ON db. TO username@hostname IDENTIFIED VIA gssapi;\n`\n\nYou can also specify the user''s realm for MariaDB with the USING clause:\n\n`sql\nCREATE USER username@hostname IDENTIFIED VIA gssapi USING ''username@EXAMPLE.COM'';\n`\n\nThe format of the realm depends on the specific authentication mechanism that is used. For example, the format would need to be machine\\\\username for Windows users authenticating with NTLM.\n\nIf the realm is not provided in the user account''s definition, then the realm is not used for comparison. Therefore, ''usr1@EXAMPLE.COM'', ''usr1@EXAMPLE.CO.UK'' and ''mymachine\\usr1'' would all identify as the following user account:\n\n`sql\nCREATE USER usr1@hostname IDENTIFIED VIA gssapi;\n`\n\nCreating Users Identified Via Group Membership or SID (Windows-specific)\n\nOn Windows only, it is possible to login using a AD or local group-membership. This is achieved by using the GROUP prefix in IDENTIFIED ... AS:\n\n`sql\nCREATE USER root IDENTIFIED VIA gssapi AS ''GROUP:Administrators''\nCREATE USER root IDENTIFIED VIA gssapi AS ''GROUP:BUILTIN\\\\Administrators''\n`\n\nThe effect of the above definition is that every user that identifies as a member of group Administrators can log in using the user name root without a password.\n\nUser can also login using own or group SID (Security Identifier):\n\n`sql\nCREATE USER root IDENTIFIED VIA gssapi AS ''SID:S-1-5-32-544''\n`\n\nUsing SIDs will perform slightly faster than using name (since it will spare translation between SID and name which is otherwise done). SIDs are immune against user or group renaming.\n\nPasswordless login on Windows\n\nThis feature is available from MariaDB 10.11.\n\nOn Windows, in addition to the usual authentication with a password, passwordless authentication is permitted when creating the root user during installation. This works in a similar manner to Unix socket authentication. However, since auth_gssapi, unlike unix_socket, requires client support, to avoid failures when MariaDB is used with third-party drivers, authentication on Windows first attempts password-based native_authentication, and only if it fails, falls back to passwordless auth_gssapi.\n\nClient Authentication Plugins\n\nFor clients that use the libmysqlclient or MariaDB Connector/C libraries, MariaDB provides one client authentication plugin that is compatible with the gssapi authentication plugin:\n\n auth_gssapi_client\n\nWhen connecting with a client or utility to a server as a user account that authenticates with the gssapi authentication plugin, you may need to tell the client where to find the relevant client authentication plugin by specifying the --plugin-dir option:\n\n`bash\nmysql --plugin-dir=/usr/local/mysql/lib64/mysql/plugin --user=alice\n`\n\nauth_gssapi_client\n\nThe auth_gssapi_client client authentication plugin receives the principal name from the server, and then uses either the gss_init_sec_context function (on Unix) or the InitializeSecurityContext function (on Windows) to establish a security context on the client.\n\nSupport in Client Libraries\n\nUsing the Plugin with MariaDB Connector/C\n\nMariaDB Connector/C supports gssapi authentication using the client authentication plugins mentioned in the previous section.\n\nUsing the Plugin with MariaDB Connector/ODBC\n\nMariaDB Connector/ODBC supports gssapi authentication using the client authentication plugins mentioned in the previous section.\n\nUsing the Plugin with MariaDB Connector/J\n\nMariaDB Connector/J supports gssapi authentication. Current documentation can be found here.\n\nUsing the Plugin with MariaDB Connector/Node.js\n\nMariaDB Connector/Node.js does not yet support gssapi authentication. See CONJS-72 for more information.\n\nUsing the Plugin with MySqlConnector for .NET\n\nMySqlConnector for ADO.NET supports gssapi authentication.\n\nThe support is transparent. Normally, the connector only needs to be provided the correct user name, and no other parameters are required.\n\nHowever, this connector also supports the ServerSPN connection string parameter, which can be used for mutual authentication.\n\n.NET specific problems/workarounds\n\nWhen connecting from Unix client to Windows server with ADO.NET, in an Active Directory domain environment, be aware that .NET Core on Unix does not support principal names in UPN(User Principal Name) form, which is default on Windows (e.g machine$@domain.com) . Thus, upon encountering an authentication exception with "server not found in Kerberos database", use one of workarounds below\n\n Force host-based SPN on server side.\n For example, this can be done by setting the gssapi_principal_name system variable to HOST/machine in a server option group in an option file.\n Pass host-based SPN on client side.\n For example, this can be done by setting the connector''s ServerSPN connection string parameter to HOST/machine.\n\nSystem Variables\n\ngssapi_keytab_path\n\n Description: Defines the path to the server''s keytab file.\n This system variable is only meaningful on Unix.\n See Creating a Keytab File on Unix and Configuring the Path to the Keytab File on Unix for more information.\n Command line: --gssapi-keytab-path\n Scope: Global\n Dynamic: No\n Data Type: string\n Default Value: ''''\n Introduced: MariaDB 10.1.11\n\ngssapi_principal_name\n\n Description: Name of the service principal.\n See Configuring the Service Principal Name for more information.\n Command line: --gssapi-principal-name\n Scope: Global\n Dynamic: No\n Data Type: string\n Default Value: ''''\n Introduced: MariaDB 10.1.11\n\ngssapi_mech_name\n\n Description: Name of the SSPI package used by server. Can be either ''Kerberos'' or ''Negotiate''. Set it to ''Kerberos'', to prevent less secure NTLM in domain environments, but leave it as default (Negotiate) to allow non-domain environments (e.g if server does not run in a domain environment).\n This system variable is only meaningful on Windows.\n Command line: --gssapi-mech-name\n Scope: Global\n Dynamic: No\n Data Type: enumerated\n Default Value: Negotiate\n Valid Values: Kerberos, Negotiate\n Introduced: MariaDB 10.1.11\n\nOptions\n\ngssapi\n\n Description: Controls how the server should trea\n\n[Truncated — full content at mariadb.com/docs]', '', 'https://mariadb.com/docs/server/reference/plugins/authentication-plugins/authentication-plugin-gssapi'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (102, 5, 'Authentication Plugin - mysql\\_native\\_password', 'Description\n-----------\n\nThe mysql_native_password authentication plugin is the default authentication plugin that will be used for an account created when no authentication plugin is explicitly mentioned and old_passwords=0 is set. It uses the password hashing algorithm introduced in MySQL 4.1, which is also used by the PASSWORD() function when old_passwords=0 is set. This hashing algorithm is based on SHA-1.\n\nIt is not recommended to use the mysql_native_password authentication plugin for new installations that require high password security. If someone is able to both listen to the connection protocol and get a copy of the mysql.user table, then the person would be able to use this information to connect to the MariaDB server. The ed25519 authentication plugin is a more modern authentication plugin that provides simple password authentication using a more secure algorithm.\n\nInstalling the Plugin\n\nThe mysql_native_password authentication plugin is statically linked into the server, so no installation is necessary.\n\nCreating Users\n\nThe easiest way to create a user account with the mysql_native_password authentication plugin is to make sure that old_passwords=0 is set, and then create a user account via CREATE USER that does not specify an authentication plugin, but does specify a password via the IDENTIFIED BY clause:\n\n``sql\nSET old_passwords=0;\nCREATE USER username@hostname IDENTIFIED BY ''mariadb'';\n`\n\nIf SQL_MODE does not have NO_AUTO_CREATE_USER set, then you can also create the user account via GRANT:\n\n`sql\nSET old_passwords=0;\nGRANT SELECT ON db. TO username@hostname IDENTIFIED BY ''mariadb'';\n`\n\nYou can also create the user account by providing a password hash via the IDENTIFIED BY PASSWORD clause, and MariaDB will validate whether the password hash is one that is compatible with mysql_native_password:\n\n`sql\nSET old_passwords=0;\n\nSELECT PASSWORD(''mariadb'');\n+-------------------------------------------+\n| PASSWORD(''mariadb'') |\n+-------------------------------------------+\n| 54958E764CE10E50764C2EECBB71D01F08549980 |\n+-------------------------------------------+\n\nCREATE USER username@hostname\n IDENTIFIED BY PASSWORD ''54958E764CE10E50764C2EECBB71D01F08549980'';\n`\n\nSimilar to all other authentication plugins, you could also specify the name of the plugin in the IDENTIFIED VIA clause while providing the password hash as the USING clause:\n\n`sql\nCREATE USER username@hostname\n IDENTIFIED VIA mysql_native_password USING ''54958E764CE10E50764C2EECBB71D01F08549980'';\n`\n\nChanging User Passwords\n\nYou can change a user account''s password with the SET PASSWORD statement while providing the plain-text password as an argument to the PASSWORD() function:\n\n`sql\nSET PASSWORD = PASSWORD(''new_secret'')\n`\n\nYou can also change the user account''s password with the ALTER USER statement. You would have to make sure that old_passwords=0 is set, and then you would have to specify a password via the IDENTIFIED BY clause:\n\n`sql\nSET old_passwords=0;\nALTER USER username@hostname IDENTIFIED BY ''new_secret'';\n`\n\nClient Authentication Plugins\n\nFor clients that use the libmysqlclient or MariaDB Connector/C libraries, MariaDB provides one client authentication plugin that is compatible with the mysql_native_password authentication plugin:\n\n* mysql_native_password\n\nWhen connecting with a client or utility to a server as a user account that authenticates with the mysql_native_password authentication plugin, you may need to tell the client where to find the relevant client authentication plugin by specifying the --plugin-dir option:\n\n`bash\nmysql --plugin-dir=/usr/local/mysql/lib64/mysql/plugin --user=alice\n`\n\nHowever, the mysql_native_password client authentication plugin is generally statically linked into client libraries like libmysqlclient or MariaDB Connector/C, so this is not usually necessary.\n\nmysql_native_password\n\nThe mysql_native_password client authentication plugin hashes the password before sending it to the server.\n\nSupport in Client Libraries\n\nThe mysql_native_password authentication plugin is one of the conventional authentication plugins, so all client libraries should support it.\n\nKnown Old Issues (Only Relevant for Old Installations)\n\nMismatches Between Password and authentication_string Columns\n\nFor compatibility reasons, the mysql_native_password authentication plugin tries to read the password hash from both the Password and authentication_string columns in the mysql.user table. This has caused issues in the past if one of the columns had a different value than the other.\n\nCREATE USER, ALTER USER, GRANT, and SET PASSWORD set the Password and authentication_string columns in the mysql.user table whenever an account''s password is changed.\n\nCREATE USER, ALTER USER, GRANT, and SET PASSWORD do not set the Password and authentication_string` columns in the mysql.user table whenever an account''s password is changed.\n\nURL: https://mariadb.com/docs/server/reference/plugins/authentication-plugins/authentication-plugin-mysql_native_password', '', 'https://mariadb.com/docs/server/reference/plugins/authentication-plugins/authentication-plugin-mysql_native_password'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (103, 5, 'Authentication Plugin - mysql\\_old\\_password', 'Description\n-----------\n\nThe mysql_old_password authentication plugin is the default authentication plugin that is used for an account created when no authentication plugin is explicitly mentioned and old_passwords=1 is set. It uses the pre-MySQL 4.1 password hashing algorithm, which is also used by the OLD_PASSWORD() function and by the PASSWORD() function when old_passwords=1 is set.\n\nIt is not recommended to use the mysql_old_password authentication plugin for new installations. The password hashing algorithm is no longer secure, and the plugin is primarily provided for backward compatibility. The ed25519 authentication plugin is a more modern authentication plugin that provides simple password authentication.\n\nInstalling the Plugin\n\nThe mysql_old_password authentication plugin is statically linked into the server, so no installation is necessary.\n\nCreating Users\n\nThe easiest way to create a user account with the mysql_old_password authentication plugin is to make sure that old_passwords=1 is set, and create a user account via CREATE USER that does not specify an authentication plugin, but instead specifies a password via the IDENTIFIED BY clause:\n\n``sql\nSET old_passwords=1;\nCREATE USER username@hostname IDENTIFIED BY ''mariadb'';\n`\n\nIf SQL_MODE does not have NO_AUTO_CREATE_USER set, then you can also create the user via GRANT:\n\n`sql\nSET old_passwords=1;\nGRANT SELECT ON db. TO username@hostname IDENTIFIED BY ''mariadb'';\n`\n\nYou can also create the user account by providing a password hash via the IDENTIFIED BY PASSWORD clause, and MariaDB validates whether the password hash is one that is compatible with mysql_old_password:\n\n`sql\nSET old_passwords=1;\nQuery OK, 0 rows affected (0.000 sec)\n\nSELECT PASSWORD(''mariadb'');\n+---------------------+\n| PASSWORD(''mariadb'') |\n+---------------------+\n| 021bec665bf663f1 |\n+---------------------+\n1 row in set (0.000 sec)\n\nCREATE USER username@hostname IDENTIFIED BY PASSWORD ''021bec665bf663f1'';\nQuery OK, 0 rows affected (0.000 sec)\n`\n\nSimilar to all other authentication plugins, you could also specify the name of the plugin in the IDENTIFIED VIA clause, while providing the password hash as the USING clause:\n\n`sql\nCREATE USER username@hostname IDENTIFIED VIA mysql_old_password USING ''021bec665bf663f1'';\nQuery OK, 0 rows affected (0.000 sec)\n`\n\nChanging User Passwords\n\nYou can change a user account''s password with the SET PASSWORD statement, while providing the plain-text password as an argument to the PASSWORD() function:\n\n`sql\nSET PASSWORD = PASSWORD(''new_secret'')\n`\n\nYou can also change the user account''s password with the ALTER USER statement. You have to make sure that old_passwords=1 is set, and you have to specify a password via the IDENTIFIED BY clause:\n\n`sql\nSET old_passwords=1;\nALTER USER username@hostname IDENTIFIED BY ''new_secret'';\n`\n\nClient Authentication Plugins\n\nFor clients that use the libmysqlclient or MariaDB Connector/C libraries, MariaDB provides one client authentication plugin that is compatible with the mysql_old_password authentication plugin:\n\n mysql_old_password\n\nWhen connecting with a client or utility to a server as a user account that authenticates with the mysql_old_password authentication plugin. You may need to tell the client where to find the relevant client authentication plugin by specifying the --plugin-dir option:\n\n`bash\nmysql --plugin-dir=/usr/local/mysql/lib64/mysql/plugin --user=alice\n`\n\nHowever, the mysql_old_password client authentication plugin is generally statically linked into client libraries like libmysqlclient or MariaDB Connector/C, so this is not usually necessary.\n\nmysql_old_password\n\nThe mysql_old_password client authentication plugin hashes the password before sending it to the server.\n\nSupport in Client Libraries\n\nThe mysql_old_password` authentication plugin is one of the conventional authentication plugins, so all client libraries should support it.\n\nURL: https://mariadb.com/docs/server/reference/plugins/authentication-plugins/authentication-plugin-mysql_old_password', '', 'https://mariadb.com/docs/server/reference/plugins/authentication-plugins/authentication-plugin-mysql_old_password'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (104, 5, 'Authentication Plugin - Named Pipe', 'Description\n-----------\n\nThe named_pipe authentication plugin allows the user to use operating system credentials when connecting to MariaDB via named pipe on Windows. Named pipe connections are enabled by the named_pipe system variable.\n\nThe named_pipe authentication plugin works by using named pipe impersonation.aspx) and calling GetUserName() to retrieve the user name of the process that is connected to the named pipe. Once it has the user name, it authenticates the connecting user as the MariaDB account that has the same user name.\n\nInstalling the Plugin\n\nAlthough the plugin''s shared library is distributed with MariaDB by default, the plugin is not actually installed by MariaDB by default. There are two methods that can be used to install the plugin with MariaDB.\n\nThe first method can be used to install the plugin without restarting the server. You can install the plugin dynamically by executing INSTALL SONAME or INSTALL PLUGIN:\n\n``sql\nINSTALL SONAME ''auth_named_pipe'';\n`\n\nThe second method can be used to tell the server to load the plugin when it starts up. The plugin can be installed this way by providing the --plugin-load or the --plugin-load-add options. This can be specified as a command-line argument to mariadbd, or it can be specified in a relevant server option group in an option file:\n\n`ini\n[mariadb]\n...\nplugin_load_add = auth_named_pipe\n`\n\nUninstalling the Plugin\n\nYou can uninstall the plugin dynamically by executing UNINSTALL SONAME or UNINSTALL PLUGIN:\n\n`sql\nUNINSTALL SONAME ''auth_named_pipe'';\n`\n\nIf you installed the plugin by providing the --plugin-load or the --plugin-load-add options in a relevant server option group in an option file, those options should be removed to prevent the plugin from being loaded the next time the server is restarted.\n\nCreating Users\n\nTo create a user account via CREATE USER, specify the name of the plugin in the IDENTIFIED VIA clause:\n\n`sql\nCREATE USER username@hostname IDENTIFIED VIA named_pipe;\n`\n\nIf SQL_MODE does not have NO_AUTO_CREATE_USER set, then you can also create the user account via GRANT:\n\n`sql\nGRANT SELECT ON db.* TO username@hostname IDENTIFIED VIA named_pipe;\n`\n\nClient Authentication Plugins\n\nThe named_pipe authentication plugin does not require any specific client authentication plugins. It should work with all clients.\n\nSupport in Client Libraries\n\nThe named_pipe` authentication plugin does not require any special support in client libraries. It should work with all client libraries.\n\nExamples\n--------\n\nCREATE USER wlad IDENTIFIED VIA named_pipe;\nCREATE USER monty IDENTIFIED VIA named_pipe;\nquit\n\nC:\\>echo %USERNAME%\nwlad\n\nC:\\> mysql --user=wlad --protocol=PIPE\nWelcome to the MariaDB monitor. Commands end with ; or \\g.\nYour MariaDB connection id is 4\nServer version: 10.1.12-MariaDB-debug Source distribution\n\nCopyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others.\n\nType ''help;'' or ''\\h'' for help. Type ''\\c'' to clear the current input statement.\n\nMariaDB [(none)]> quit\nBye\n\nC:\\> mysql --user=monty --protocol=PIPE\nERROR 1698 (28000): Access denied for user ''monty''@''localhost''\n\nURL: https://mariadb.com/docs/server/reference/plugins/authentication-plugins/authentication-plugin-named-pipe', '', 'https://mariadb.com/docs/server/reference/plugins/authentication-plugins/authentication-plugin-named-pipe'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (105, 5, 'Authentication Plugin - PARSEC', 'Description\n-----------\n\n The KDF function is pbkdf2 (supported by everything, including windows native, Java, javascript, PHP, .NET.\n Parameters to the pbkdf2 are stored in with authentication plugin data : hash function (SHA512,SHA256), iteration count, salt, key_length, together with derived key = PBKDF2(func, password, salt, iteration_count, key_length).\n The number of iterations is a power of 2, greater than 9.\n The algorithm is ed25519, "hash" is the public key generated using ed25519 from the PBKDF2(password).\n\nThe authentication string, stored by the server, is this:\n\n``c\nconcat(''P'', conv(log2(iterations)-10, 10, 62), '':'', base64(salt), '':'', base64(hash))\n`\n\nFor example, it looks like this: P0:WW9sXaaL/o:vubFBzIrapbfHct1/J72dnUryz5VS7lA6XHH8sIx4TI\n\n It consists of colon-separated fields.\n The first field is ''P'' (denotes KDF algorithm = PBKDF2) and the number of iterations, ''0'' means 1024, ''1'' means 2048, etc.\n This is followed by the salt.\n This is followed by the password hash.\n\nThe first two fields together are called _ext-salt_, extended salt.\n\nLogin Process, Packet Exchange\n\n1. The server sends an Authentication Switch Request with a 32-byte random scramble.\n2. The client sends an empty packet to the server to request the ext-salt.\n3. The server sends the ext-salt to the client.\n4. The client sends the random 32-byte scramble, and the concat(server scramble, client scramble) ed25519-signed by a secret key generated from the function PBKDF2(password, ext-salt).\n5. The server replies with "ok" or "access denied".\n\nInstalling\n\nIf you run into the error ERROR 1524 (HY000): Plugin ''parsec'' is not loaded it means you need to install the authentication plugin first. You can do it on a running server with:\n\n`sql\nINSTALL SONAME ''auth_parsec'';\n`\n\nThere is no need to pass additional command-line options or have config files to keep the PARSEC authentication method available. Running the INSTALL SONAME` once is enough and the MariaDB Server will remember it even if server is restarted or upgraded.\n\nExamples\n--------\n\nCREATE USER test1@''%'' IDENTIFIED VIA parsec USING PASSWORD(''pwd'');\n\nURL: https://mariadb.com/docs/server/reference/plugins/authentication-plugins/authentication-plugin-parsec', '', 'https://mariadb.com/docs/server/reference/plugins/authentication-plugins/authentication-plugin-parsec'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (106, 5, 'Authentication Plugin - SHA-256', 'Description\n-----------\n\nBackground\n\nMySQL 5.6 added support for the sha256_password authentication plugin, and MySQL 8.0 also added support for the caching_sha2_password authentication plugin.\n\nThe caching_sha2_password plugin is now the default authentication plugin in MySQL 8.0.4 and above, based on the value of the default_authentication_plugin system variable.\n\nSupport in MariaDB Server\n\nMariaDB Server does not support the sha256_password plugin. A caching_sha2_password authentication plugin was added in MariaDB Community Server 12.1 and Enterprise Server 11.8. See MDEV-9804 for more information.\n\nReasons for not supporting the SHA-256 plugin:\n\n To use the protocol, you have to distribute the server''s public key to all MariaDB users, which can be cumbersome and impractical.\n The server receives the password in clear text, which can cause problems if the user connects to a malicious server.\n\nIf you are migrating from a MySQL instance that is using SHA-256 authentication, you have to change the SHA-256 authentication to mysql_native_authentication :\n\n``sql\nALTER USER user_name IDENTIFIED WITH mysql_native_password BY ''new_password''\n`\n\nSupport in Client Libraries\n\nClient Authentication Plugins\n\nFor clients that use the MariaDB Connector/C library, MariaDB provides client authentication plugins that are compatible with MySQL''s SHA-256 authentication plugins:\n\n sha256_password\n caching_sha256_password\n\nWhen connecting with a client or utility to a server, using a user account that authenticates with the sha256_password or caching_sha256_password authentication plugin, you may need to tell the client where to find the relevant client authentication plugin by specifying the --plugin-dir option:\n\n`bash\nmysql --plugin-dir=/usr/local/mysql/lib64/mysql/plugin --user=alice\n`\n\nFor clients that use MariaDB''s libmysqlclient library instead of MariaDB Connector/C, those authentication plugins are not supported.\n\nsha256_password\n\nThe sha256_password client authentication plugin is compatible with MySQL''s sha256_password authentication plugin, which was added in MySQL 5.6.\n\ncaching_sha256_password\n\nThe caching_sha256_password client authentication plugin is compatible with MySQL''s caching_sha2_password authentication plugin, which was added in MySQL 8.0.\n\nThe caching_sha2_password plugin is now the default authentication plugin in MySQL 8.0.4 and above, based on the value of the default_authentication_plugin system variable.\n\nUsing the Plugin with MariaDB Connector/C\n\nMariaDB Connector/C supports sha256_password and caching_sha2_password authentication using the client authentication plugins mentioned in the previous section.\n\nIt has supported the sha256_password client authentication plugin since MariaDB Connector/C 3.0.2. See CONC-229 for more information.\n\nIt has supported the caching_sha256_password client authentication plugin since MariaDB Connector/C 3.0.8 and MariaDB Connector/C 3.1.0. See CONC-312 for more information.\n\nUsing Plugins with MariaDB Connector/ODBC\n\nMariaDB Connector/ODBC supports sha256_password and caching_sha2_password authentication using the client authentication plugins mentioned in the previous section.\n\nIt has supported sha256_password and caching_sha2_password authentication since MariaDB Connector/ODBC 3.1.4. See ODBC-241 for more information.\n\nUsing Plugins with MariaDB Connector/J\n\nMariaDB Connector/J supports sha256_password and caching_sha2_password authentication since MariaDB Connector/J 2.5.0. See CONJ-327 and CONJ-663 for more information.\n\nnote: The version 3.x being a rewrite of the connector, only caching_sha2_password is implemented, since sha256_password is only implemented on EOL version.\n\nUsing Plugins with MariaDB Connector/Node.js\n\nMariaDB Connector/Node.js supports sha256_password and caching_sha2_password` authentication since MariaDB Connector/Node.js 2.5.0. See CONJS-76 and CONJS-77 for more information.\n\nURL: https://mariadb.com/docs/server/reference/plugins/authentication-plugins/authentication-plugin-sha-256', '', 'https://mariadb.com/docs/server/reference/plugins/authentication-plugins/authentication-plugin-sha-256'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (107, 5, 'Authentication Plugin - Unix Socket', 'Description\n-----------\n\nThe unix_socket authentication plugin is installed by default, and it is used by the ''root''@''localhost'' user account by default. See Authentication for more information.\n\nThe unix_socket authentication plugin allows the user to use operating system credentials when connecting to MariaDB via the local Unix socket file. This Unix socket file is defined by the socket system variable.\n\nThe unix_socket authentication plugin works by calling the getsockopt system call with the SO_PEERCRED socket option, which allows it to retrieve the uid of the process that is connected to the socket. It is then able to get the user name associated with that uid. Once it has the user name, it will authenticate the connecting user as the MariaDB account that has the same user name.\n\nThe unix_socket authentication plugin is not suited to multiple Unix users accessing a single MariaDB user account.\n\nSecurity\n\nA unix_socket authentication plugin is a passwordless security mechanism. Its security lies in the strength of the access to the Unix user, rather than the complexity and the secrecy of the password.\n\nAs security differs from password security, the strengths and weaknesses need to be considered, and those can differ depending on the specific installation.\n\nStrengths\n\n Access is limited to the Unix user so, for example, a www-data user cannot access root with the unix_socket authentication plugin.\n There is no password which can be cracked by brute force.\n There is no password that can be accidentally exposed by user accident, poor security on backups, or poor security on passwords in configuration files.\n Default Unix user security is usually strong on preventing remote access and password brute force attempts.\n\nWeaknesses\n\nThe strength of a unix_socket authentication plugin is effectively the strength of the security of the Unix users on the system. In most cases, the Unix user default installation is sufficiently secure. However, the following is a non-exhaustive list of potential Unix user security issues that may arise.\n\n Common access areas without screen locks, where an unauthorized user accesses the logged in Unix user of an authorized user.\n Extensive sudo access grants that provide users with access to execute commands of a different Unix user.\n Scripts writable by Unix users other than the Unix user that are executed (via cron or directly) by the Unix user.\n Web pages that are susceptible to command injection, where the Unix user running the web page has elevated privileges in the database that weren''t intended to be used.\n Poor Unix user password practices including weak user passwords, password exposure and password reuse accompanied by an access vulnerability/mechanism of an unauthorized user to exploit this weakness.\n Weak remote access mechanisms and network file system privileges.\n Poor user security behavior including running untrusted scripts and software.\n\nIn some of these scenarios a database password may prevent these security exploits, however it will remove all the strengths of the unix_socket authentication plugin previously mentioned.\n\nDisabling the Plugin\n\nThe unix_socket authentication plugin is installed by default.\n\nIf you do not want it to be available by default, you must disable it.\n\nThe unix_socket authentication plugin is also installed by default in new installations that use the .deb packages provided by Debian''s default repositories and Ubuntu''s default repositories. See Differences in MariaDB in Debian (and Ubuntu) for more information.\n\nThe unix_socket authentication plugin can be disabled by starting the server with the unix_socket option set to OFF. This can be specified as a command-line argument to mysqld or it can be specified in a relevant server option group in an option file:\n\n``ini\n[mariadb]\n...\nunix_socket=OFF\n`\n\nAs an alternative, the unix_socket option can also be set to OFF by pairing the option with the disable option prefix:\n\n`ini\n[mariadb]\n...\ndisable_unix_socket\n`\n\nInstalling the Plugin\n\nThe unix_socket authentication plugin is installed by default in almost all MariaDB server versions. If you work with a version that doesn''t have the plugin installed, you can install it as described in one of the following ways.\n\n Install the plugin without restarting the server. You can install the plugin dynamically, by executing INSTALL SONAME or INSTALL PLUGIN:\n\n`sql\nINSTALL SONAME ''auth_socket'';\n`\n\n Instruct the server to load the plugin at startup. The plugin can be installed this way by providing the --plugin-load or the --plugin-load-add options. This can be specified as a command-line argument to mysqld or it can be specified in a relevant server option group in an option file:\n\n`ini\n[mariadb]\n...\nplugin_load_add = auth_socket\n`\n\nUninstalling the Plugin\n\nYou can uninstall the plugin dynamically by executing UNINSTALL SONAME or UNINSTALL PLUGIN:\n\n`sql\nUNINSTALL SONAME ''auth_socket'';\n`\n\nIf you installed the plugin by providing the --plugin-load or the --plugin-load-add options in a server option group in an option file, those options should be removed to prevent the plugin from being loaded the next time the server is restarted.\n\nCreating Users\n\nTo create a user account via CREATE USER, specify the name of the plugin in the IDENTIFIED VIA clause:\n\n`sql\nCREATE USER username@hostname IDENTIFIED VIA unix_socket;\n`\n\nIf SQL_MODE does not have NO_AUTO_CREATE_USER set, then you can also create the user account via GRANT:\n\n`sql\nGRANT SELECT ON db. TO username@hostname IDENTIFIED VIA unix_socket;\n`\n\nThe authentication string (if present) is compared with the socket''s user name. Authentication proceeds if there''s a match. In this case, the external_user system variable contains the OS user.\n\nConsider an OS user named ''bob'' that has been created like this:\n\n`sql\nCREATE USER A identified via unix_socket as ''bob'';\n\n`\n\nThat user can connect like this:\n\n`bash\nmariadb -uA\n`\n\nAlternatively, accessing the sock file directly, the user can connect like this:\n\n`bash\nmariadb -uA -S /var/run/mysqld/mysqld.sock\n`\n\nOnce connected, you can view that user like this:\n\n`sql\nSELECT USER(),@@external_user;\n+-------------+-----------------+\n| user() | @@external_user |\n+-------------+-----------------+\n| A@localhost | bob |\n+-------------+-----------------+\n`\n\nThe plugin only checks whether the OS socket user id matches the MariaDB user name. It ignores the authentication string.\n\nSwitching to Password-Based Authentication\n\nIf Unix socket authentication does not meet your needs, you can switch a user account back to password-based authentication, by telling MariaDB to use a different authentication plugin for the account. The specific authentication plugin is specified with the IDENTIFIED VIA clause. To switch to the mysql_native_password authentication plugin, you need to do this:\n\n`sql\nALTER USER root@localhost IDENTIFIED VIA mysql_native_password;\nSET PASSWORD = PASSWORD(''foo'');\n`\n\nIf you use scripts that require passwordless access to MariaDB, this would cause them to break. You may be able to fix that by setting a password in the [client] option group in your /root/.my.cnf option file.\n\n`ini\n[client]\npassword=foo\n`\n\nClient Authentication Plugins\n\nThe unix_socket authentication plugin does not require any specific client authentication plugins. It should work with all clients.\n\nSupport in Client Libraries\n\nThe unix_socket` authentication plugin does not require any special support in client libraries. It should work with all client libraries.\n\nURL: https://mariadb.com/docs/server/reference/plugins/authentication-plugins/authentication-plugin-unix-socket', '', 'https://mariadb.com/docs/server/reference/plugins/authentication-plugins/authentication-plugin-unix-socket'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (108, 5, 'Authentication Plugin - PAM', 'Description\n-----------\n\nThe pam authentication plugin allows MariaDB to offload user authentication to the system''s Pluggable Authentication Module (PAM) framework. PAM is an authentication framework used by Linux, FreeBSD, Solaris, and other Unix-like operating systems.\n\nNote: Windows does not support PAM, so the pam authentication plugin does not support Windows. However, one can use a MariaDB client on Windows to connect to MariaDB server that is installed on a Unix-like operating system and that is configured to use the pam authentication plugin. For an example of how to do this, see the blog post: MariaDB: Improve Security with Two-Step Verification.\n\nUse Cases\n\nPAM makes it possible to implement various authentication scenarios of different complexity:\n\n Authentication using passwords from /etc/shadow (this is what a default PAM configuration usually does). See the pam_unix PAM module.\n Authentication using LDAP. See the pam_ldap PAM module.\n Authentication using Microsoft''s Active Directory. See the pam_lsass, pam_winbind, and pam_centrifydc PAM modules.\n Authentication using one-time passwords (even with SMS confirmation!). See the pam_google_authenticator and pam_securid PAM modules.\n Authentication using SSH keys. See the pam_ssh PAM module.\n User and group mapping. See the pam_user_map PAM module.\n Combining different authentication modules in interesting ways in a PAM service.\n Password expiration.\n Limiting access by time, date, day of the week, etc. See the pam_time PAM module.\n Logging of every login attempt.\n\nInstalling the Plugin\n\nThe pam authentication plugin''s library is provided in binary packages in all releases on Linux.\n\nAlthough the plugin''s shared library is distributed with MariaDB by default, the plugin is not actually installed by MariaDB by default. There are two methods that can be used to install the plugin with MariaDB.\n\nThe first method can be used to install the plugin without restarting the server. You can install the plugin dynamically by executing INSTALL SONAME or INSTALL PLUGIN:\n\n``sql\nINSTALL SONAME ''auth_pam'';\n`\n\nThe second method can be used to tell the server to load the plugin when it starts up. The plugin can be installed this way by providing the --plugin-load or the --plugin-load-add options. This can be specified as a command-line argument to mysqld or it can be specified in a relevant server option group in an option file:\n\n`ini\n[mariadb]\n...\nplugin_load_add = auth_pam\n`\n\nInstalling the v1 Plugin\n\nThe auth_pam shared library actually refers to version 2.0 of the pam authentication plugin. Version 1.0 of the plugin as the auth_pam_v1 shared library is also available.\n\nIf you need to install version 1.0 of the authentication plugin instead of version 2.0, install it with INSTALL SONAME or INSTALL PLUGIN:\n\n`sql\nINSTALL SONAME ''auth_pam_v1'';\n`\n\nAlternatively, specify it in a relevant server option group in an option file:\n\n`sql\n[mariadb]\n...\nplugin_load_add = auth_pam_v1\n`\n\nUninstalling the Plugin\n\nYou can uninstall the plugin dynamically by executing UNINSTALL SONAME or UNINSTALL PLUGIN:\n\n`sql\nUNINSTALL SONAME ''auth_pam'';\n`\n\nIf you installed the plugin by providing the --plugin-load or the --plugin-load-add options in a relevant server option group in an option file, those options must be removed to prevent the plugin from being loaded the next time the server is restarted.\n\nUninstalling the v1 Plugin\n\nIf you installed version 1.0 of the authentication plugin, you can uninstall it by executing a similar statement for auth_pam_v1:\n\n`sql\nUNINSTALL SONAME ''auth_pam_v1'';\n`\n\nConfiguring PAM\n\nThe pam authentication plugin tells MariaDB to delegate the authentication to the PAM authentication framework. How exactly that authentication is performed depends on how PAM is configured.\n\nConfiguring the PAM Service\n\nPAM is divided into services. PAM services are configured by PAM configuration files. Typically, the global PAM configuration file is located at /etc/pam.conf and PAM directory-based configuration files for individual services are located in /etc/pam.d/.\n\nIf you want to use a PAM service called mariadb for your MariaDB PAM authentication, then the PAM configuration file for that service would also be called mariadb, and it would typically be located at /etc/pam.d/mariadb.\n\nFor example, here is a minimal PAM service configuration file that performs simple password authentication with UNIX passwords:\n\n`\nauth required pam_unix.so audit\naccount required pam_unix.so audit\n`\n\nLet''s breakdown this relatively simple PAM service configuration file.\n\nEach line of a PAM service configuration file has the following general format:\n\n`\ntype control module-path module-arguments\n`\n\nIt instructs the PAM authentication framework that for successful authentication (i.e. type=auth), it is required that the pam_unix.so PAM module returns a success. It also instructs the PAM authentication framework that for an account (i.e. type=account) to be valid, it is required that the pam_unix.so PAM module returns a success.\n\nPAM also supports session and password types, but MariaDB''s pam authentication plugin does not support those.\n\nThe above PAM service configuration file also provides the audit module argument to the pam_unix PAM module. The pam_unix manual says that this module argument enables extreme debug logging to the syslog.\n\nOn most systems, you can find many other examples of PAM service configuration files in your /etc/pam.d/ directory.\n\nConfiguring the pam_unix PAM Module\n\nIf you configure PAM to use the pam_unix PAM module (as in the above example), then you might notice on some systems that this will fail by default with errors like the following:\n\n`\nApr 14 12:56:23 localhost unix_chkpwd[3332]: check pass; user unknown\nApr 14 12:56:23 localhost unix_chkpwd[3332]: password check failed for user (alice)\nApr 14 12:56:23 localhost mysqld: pam_unix(mysql:auth): authentication failure; logname= uid=991 euid=991 tty= ruser= rhost= user=alice\n`\n\nThe problem is that on some systems, the pam_unix PAM module needs access to /etc/shadow in order to function, and most systems only allow root to access that file by default.\n\nNewer versions of PAM do not have this limitation, so you may want to try upgrading your version of PAM to see if that fixes the issue.\n\nIf that does not work, then you can work around this problem by giving the user that runs mysqld access to /etc/shadow. For example, if the mysql user runs mysqld, then you could do the following:\n\n`bash\nsudo groupadd shadow\nsudo usermod -a -G shadow mysql\nsudo chown root:shadow /etc/shadow\nsudo chmod g+r /etc/shadow\n`\n\nAfter configuring, you have to restart the server. The server should now be able to read /etc/shadow.\n\nThe pam authentication plugin uses a setuid wrapper to perform its PAM checks, so it should not need any special workarounds to perform privileged operations, such as reading /etc/shadow when using the pam_unix PAM module. See MDEV-7032 for more information.\n\nCreating Users\n\nTo create a user in MariaDB which uses the pam authentication plugin, execute CREATE USER while specifying the name of the plugin in the IDENTIFIED VIA clause:\n\n`sql\nCREATE USER username@hostname IDENTIFIED VIA pam;\n`\n\nIf SQL_MODE does not have NO_AUTO_CREATE_USER set, then you can also create the user this way with GRANT:\n\n`sql\nGRANT SELECT ON db. TO username@hostname IDENTIFIED VIA pam;\n`\n\nYou can also specify a PAM service name for MariaDB to use by providing it with the USING clause:\n\n`sql\nCREATE USER username@hostname IDENTIFIED VIA pam USING ''mariadb'';\n`\n\nThis line creates a user that needs to be authenticated via the pam authentication plugin using the PAM service name mariadb. As mentioned in a previous section, this service''s configuration file will typically be present in /etc/pam.d/mariadb.\n\nIf no service name is specified, then the plugin will use mysql as the default PAM service name.\n\nClient Authentication Plugins\n\nFor clients that use the libmysqlclient or MariaDB Connector/C libraries, MariaDB provides two client authentication plugins that are compatible with the pam authentication plugin:\n\n dialog\n mysql_clear_password\n\nWhen connecting with a client or utility to a server as a user account that authenticates with the pam authentication plugin, you may need to tell the client where to find the relevant client authentication plugin by specifying the --plugin-dir option:\n\n`bash\nmariadb --plugin-dir=/usr/local/mysql/lib64/mysql/plugin --user=alice\n`\n\nBoth the dialog and the mysql_clear_password client authentication plugins transmit the password to the server in clear text. Therefore, when you use the pam authentication plugin, it is very important to encrypt client connections using TLS to prevent the clear-text passwords from being seen by unauthorized users.\n\ndialog\n\nUsually the pam authentication plugin uses the dialog client authentication plugin to communicate with the user. This client authentication plugin allows MariaDB to support arbitrarily complex PAM configurations with regular or one-time passwords, challenge-response, multiple questions, or just about anything else. When using a MariaDB client library, there is no need to install or enable anything — the dialog client authentication plugin is loaded by the client library completely automatically and transparently for the application.\n\nThe dialog client authentication plugin was developed by MariaDB, so MySQL''s clients and client libraries as well as third party applications that bundle MySQL''s client libraries do not support the dialog client authentication plugin out of the box. If the server tells an unsupported client to use the dialog client authentication plugin, then the client is likely to throw an error like the following:\n\n`\nERROR 2059 (HY000): Authentication plugin ''dialog'' cannot be loaded: /usr/lib/mysql/plugin/dialog.so: cannot open shared object file: No such file or directory\n`\n\nFor some libraries or applications, this problem can be fixed by copying dialog.so or dialog.dll from a MariaDB client installation that is compatible with the system into the system''s MySQL client authentication plugin directory. However, not all clients are compatible with the dialog client authentication plugin, so this may not work for every client.\n\nIf your client does not support the dialog client authentication plugin, then you may need to use the mysql_clear_password client authentication plugin instead.\n\nThe dialog client authentication plugin transmits the password to the server in clear text. Therefore, when you use the pam authentication plugin, it is incredibly important to encrypt client connections using TLS to prevent the clear-text passwords from being seen by unauthorized users.\n\nmysql_clear_password\n\nUsers can instruct the pam authentication plugin to use the mysql_clear_password client authentication plugin instead of the dialog client authentication plugin by configuring the pam_use_cleartext_plugin system variable on the server. It can be set in a relevant server option group in an option file:\n\n`ini\n[mariadb]\n...\npam_use_cleartext_plugin\n`\n\nIt is important to note that the mysql_clear_password plugin has very limited functionality.\n\n The mysql_clear_password client authentication plugin only supports PAM services that require password-based authentication.\n The mysql_clear_password client authentication plugin also only supports PAM services that ask the user a single question.\n If the PAM service requires challenge-responses, multiple questions, or other similar complicated authentication schemes, then the PAM service is not compatible with mysql_clear_password client authentication plugin. In that case, the dialog client authentication plugin will have to be used instead.\n\nThe mysql_clear_password client authentication plugin transmits the password to the server in clear text. Therefore, when you use the pam authentication plugin, it is incredibly important to encrypt client connections using TLS to prevent the clear-text passwords from being seen by unauthorized users.\n\nCompatiblity with MySQL Clients and Client Libraries\n\nThe mysql_clear_password client authentication plugin is similar to MySQL''s mysql_clear_password client authentication plugin.\n\nThe mysql_clear_password client authentication plugin is compatible with MySQL clients and most MySQL client libraries, while the dialog client authentication plugin is not always compatible with them. Therefore, the mysql_clear_password client authentication plugin is most useful if you need some kind of MySQL compatibility in your environment, but you still want to use the pam authentication plugin.\n\nEven though the mysql_clear_password client authentication plugin is compatible with MySQL clients and most MySQL client libraries, the mysql_clear_password client authentication plugin may be disabled by default by these clients and client libraries. For example, MySQL''s version of the mysql command-line client has the --enable-cleartext-plugin option that must be set in order to use the mysql_clear_password client authentication plugin:\n\n`bash\nmysql --enable-cleartext-plugin --user=alice -p\n`\n\nOther clients may require other methods to enable the authentication plugin. For example, MySQL Workbench has a checkbox titled Enable Cleartext Authentication Plugin under the Advanced tab on the connection configuration screen.\n\nFor applications that use MySQL''s libmysqlclient, the authentication plugin can be enabled by setting the MYSQL_ENABLE_CLEARTEXT_PLUGIN option with the mysql_options() function:\n\n`ini\nmysql_options(mysql, MYSQL_ENABLE_CLEARTEXT_PLUGIN, 1);\n`\n\nFor MySQL compatibility, MariaDB Connector/C also allows applications to set the MYSQL_ENABLE_CLEARTEXT_PLUGIN option with the mysql_optionsv function. However, this option does not actually do anything in MariaDB Connector/C, because the mysql_clear_password client authentication plugin is always enabled for MariaDB clients and client libraries.\n\nSupport in Client Libraries\n\nUsing the Plugin with MariaDB Connector/C\n\nMariaDB Connector/C supports pam authentication using the client authentication plugins, regardless of the value of the pam_use_cleartext_plugin system variable.\n\nUsing the Plugin with MariaDB Connector/ODBC\n\nMariaDB Connector/ODBC supports pam authentication using the client authentication plugins, regardless of the value of the pam_use_cleartext_plugin system variable.\n\nUsing the Plugin with MariaDB Connector/J\n\nMariaDB Connector/J supports pam v1 authentication, regardless of the value of the pam_use_cleartext_plugin system variable.\n\nMariaDB Connector/J supports pam v2 authentication, regardless of the value of the pam_use_cleartext_plugin system variable.\n\nUsing the Plugin with MariaDB Connector/Node.js\n\nMariaDB Connector/Node.js supports pam authentication, regardless of the value of the pam_use_cleartext_plugin system variable.\n\nUsing the Plugin with MySqlConnector for .NET\n\nMySqlConnector for ADO.NET supports pam authentication, but on\n\n[Truncated — full content at mariadb.com/docs]', '', 'https://mariadb.com/docs/server/reference/plugins/authentication-plugins/authentication-with-pluggable-authentication-modules-pam/authentication-plugin-pam'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (109, 5, 'Authentication with JWT, OIDC, and OAuth 2.0 via PAM', 'Description\n-----------\n\nThis draft, intended for technical review under DOCS-5715, requires validation for technical accuracy. It includes generated text and code blocks and needs evaluation by a subject matter expert (SME) in this format. Please refrain from relying on any information on the page.\n\nMariaDB Server supports modern authentication standards—including JSON Web Tokens (JWT), OpenID Connect (OIDC), and OAuth 2.0—through its pluggable authentication architecture.\n\nBy leveraging the operating system''s PAM (Pluggable Authentication Modules) subsystem, MariaDB can integrate with external Identity Providers (IdPs) like AWS Cognito, Google Cloud Identity, and Azure AD without requiring proprietary database plugins. The database delegates the validation of tokens to the underlying OS security layer.\n\nPrerequisites\n\nBefore proceeding, ensure the following components are available:\n\n MariaDB Server (Active and running).\n PAM Module: You must install a third-party PAM module corresponding to your desired authentication method (e.g., pam_oidc.so, pam_oauth2.so, or pam_jwt.so).\n _Note: These are system-level libraries installed into /lib/security or /lib64/security. Ensure the module you choose is actively maintained and compatible with your OS._\n Identity Provider (IdP): You must have your Issuer URL, Client ID, and Audience values ready from your provider (e.g., Google, Okta, Azure).\n\nConfiguration and Connection Workflow\n\n_How to bridge the operating system''s authentication layer with MariaDB user management._\n\nHow Authentication Works\n\nBefore configuring the system, it is helpful to understand the handshake between the Client, the Database, and the Operating System.\n\n``mermaid\nsequenceDiagram\n participant Client as Client (User/App)\n participant DB as MariaDB Server\n participant Plugin as auth_pam Plugin\n participant OS as OS PAM Subsystem\n participant Module as PAM Module (pam_oidc.so)\n\n Note over Client, DB: Step 3: Connect via Client\n Client->>DB: Connect(Username, Password=Token)\n \n Note over DB, Plugin: Step 2: Configure MariaDB Server\n DB->>DB: Check User Definition\n DB->>Plugin: Delegate Auth (User is IDENTIFIED VIA PAM)\n \n Note over Plugin, OS: Step 1: Configure PAM Service\n Plugin->>OS: Authenticate using Service "mariadb"\n OS->>OS: Read /etc/pam.d/mariadb\n \n Note right of OS: This file tells OS to load pam_oidc.so\n OS->>Module: Invoke pam_oidc.so with Token\n \n Module->>Module: Validate Token (Issuer/Audience)\n Module-->>OS: Return Success/Failure\n OS-->>Plugin: Return Success/Failure\n Plugin-->>DB: Return Auth Result\n DB-->>Client: Connection Accepted/Rejected\n`\n\nConfigure the PAM Service\n\nYou must define a PAM service that loads your chosen module. This file tells the operating system how to validate the credentials passed by MariaDB.\n\nFile: /etc/pam.d/mariadb\n\n_The specific flags below (like issuer or aud) are standard OIDC parameters. Consult your specific PAM module''s documentation for exact flag syntax._\n\n`bash\n/etc/pam.d/mariadb\nGeneric OIDC Configuration Example\n\n1. ''auth'' checks the validity of the token\nauth required pam_oidc.so issuer=https://accounts.google.com aud=YOUR_CLIENT_ID\n\n2. ''account'' checks if the user is allowed to login (often required by PAM)\naccount required pam_oidc.so\n`\n\nEnsure strict validation of the aud (Audience) parameter to confirm that tokens are issued exclusively for your database application, preventing the use of tokens intended for different applications.\n\nConfigure MariaDB Server\n\nOnce the OS is configured, you must enable the PAM plugin in MariaDB and create a user that utilizes it.\n\n1. Log in to MariaDB as root.\n2. Install the PAM Plugin:\n\n `sql\n INSTALL SONAME ''auth_pam'';\n `\n3. Create the User: The USING clause specifies the service name (filename) in /etc/pam.d/.\n\n `sql\n -- Create a user that maps to the ''sub'' (Subject) claim in the token\n CREATE USER ''jdoe''@''%'' IDENTIFIED VIA pam USING ''mariadb'';\n `\n\nConnect via Client\n\nWhen connecting, the "Password" field is used to transmit the JWT or OIDC Token.\n\n`bash\n1. Obtain your token (e.g., via gcloud or your IdP''s CLI)\nexport DB_TOKEN="eyJhbGciOiJSUzI1NiIsImtpZ..."\n\n2. Connect to MariaDB, passing the token as the password\nmariadb --user="jdoe" --password="$DB_TOKEN"\n`\n\nTroubleshooting\n\n Authentication Failure: Check the system authentication logs.\n\n `bash\n sudo tail -f /var/log/auth.log\n `\n\n _Look for errors regarding "invalid audience," "expired token," or "issuer mismatch."_\n SELinux/AppArmor: If the database cannot access the PAM configuration, ensure your security context allows mysqld to read from /etc/pam.d/.\n* Username Mapping: By default, the MariaDB username must match the identity in the token (often the sub or emailclaim). Some PAM modules allow you to map these (e.g., mapping user@example.com to user); check your module''s user_template` or mapping documentation.\n\nURL: https://mariadb.com/docs/server/reference/plugins/authentication-plugins/authentication-with-pluggable-authentication-modules-pam/authentication-with-jwt-oidc-and-oauth-2.0-via-pam', '', 'https://mariadb.com/docs/server/reference/plugins/authentication-plugins/authentication-with-pluggable-authentication-modules-pam/authentication-with-jwt-oidc-and-oauth-2.0-via-pam'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (110, 5, 'Configuring PAM Authentication and User Mapping with LDAP Authen', 'Description\n-----------\n\nIn this article, we will walk through the configuration of PAM authentication using the pam authentication plugin and user and group mapping with the pam_user_map PAM module. The primary authentication will be handled by the pam_ldap PAM module, which performs LDAP authentication. We will also set up an OpenLDAP server.\n\nHypothetical Requirements\n\nIn this walkthrough, we are going to assume the following hypothetical requirements:\n\n The LDAP user foo should be mapped to the MariaDB user bar. (foo: bar)\n Any LDAP user in the LDAP group dba should be mapped to the MariaDB user dba. (@dba: dba)\n\nSetting up the OpenLDAP Server\n\nBefore we can use LDAP authentication, we first need to set up our OpenLDAP Server. This is usually done on a server that is completely separate from the database server.\n\nInstalling the OpenLDAP Server and Client Components\n\nOn the server acting as the OpenLDAP Server, first, we need to install the OpenLDAP components.\n\nOn RHEL, CentOS, and other similar Linux distributions that use RPM packages, that would go like this:\n\n``bash\nsudo yum install openldap openldap-servers openldap-clients nss-pam-ldapd\n`\n\nConfiguring the OpenLDAP Server\n\nNext, let''s to configure the OpenLDAP Server. The easiest way to do that is to copy the template configuration file that is included with the installation. In many installations, that will be at /usr/share/openldap-servers/DB_CONFIG.example:\n\n`bash\nsudo cp /usr/share/openldap-servers/DB_CONFIG.example /var/lib/ldap/DB_CONFIG\nsudo chown ldap. /var/lib/ldap/DB_CONFIG\n`\n\nConfiguring the OpenLDAP Port\n\nSometimes it is useful to change the port used by OpenLDAP. For example, some cloud environments block well-known authentication services, so they block the default LDAP port.\n\nOn some systems, the port can be changed by setting SLAPD_URLS in /etc/sysconfig/slapd:\n\n`ini\nSLAPD_URLS="ldapi:/// ldap://0.0.0.0:3306/"\n`\n\nI used 3306 because that is the port that is usually used by mysqld, so I know that it is not blocked.\n\nStarting the OpenLDAP Server\n\nNext, let''s start the OpenLDAP Server and configure it to start on reboot. On systemd systems, that would go like this:\n\n`bash\nsudo systemctl start slapd\nsudo systemctl enable slapd\n`\n\nInstalling the Standard LDAP objectClasses\n\nIn order to use LDAP for authentication, we also need to install some standard objectClasses, such as posixAccount and posixGroup. In LDAP, things like objectClasses are defined in LDIF files. In many installations, these specific objectClasses are defined in /etc/openldap/schema/nis.ldif. nis.ldif also depends on core.ldif and cosine.ldif. However, core.ldif is usually installed by default.\n\nWe can install them with ldapmodify:\n\n`bash\nsudo ldapmodify -a -Y EXTERNAL -H ldapi:/// -f /etc/openldap/schema/cosine.ldif\nsudo ldapmodify -a -Y EXTERNAL -H ldapi:/// -f /etc/openldap/schema/nis.ldif\n`\n\nCreating the LDAP Directory Manager User\n\nNext, let’s create a directory manager user. We can do this by using OpenLDAP''s olc configuration system to change the olcRootDN directive to the DN of the directory manager user, which means that the user will be a privileged LDAP user that is not subject to access controls. We will also set the root password for the user by changing the olcRootPW directive.\n\nWe will also set the DN suffix for our backend LDAP database by changing the olcSuffix directive.\n\nLet’s use the slappasswd utility to generate a password hash from a clear-text password. Simply execute:\n\n`bash\nslappasswd\n`\n\nThis utility provides a password hash that looks like this: {SSHA}AwT4jrvmokeCkbDrFAnGvzzjCMb7bvEl\n\nOpenLDAP''s olc configuration system also uses LDIF files. Now that we have the password hash, let’s create an LDIF file to create the directory manager user:\n\n`bash\ntee ~/setupDirectoryManager.ldif < SELECT USER(), CURRENT_USER();\n+------------------------------------------------+----------------+\n| USER() | CURRENT_USER() |\n+------------------------------------------------+----------------+\n| foo@ip-172-30-0-198.us-west-2.compute.internal | bar@% |\n+------------------------------------------------+----------------+\n1 row in set (0.000 sec)\n`\n\nWe can verify that our foo Unix user was properly mapped to the bar MariaDB user by looking at the return value of CURRENT_USER().\n\nNext, let''s test our alice user in the dba group:\n\n`bash\n$ mysql -u alice -h 172.30.0.198\n[mariadb] Password:\nWelcome to the MariaDB monitor. Commands end with ; or \\g.\nYour MariaDB connection id is 19\nServer version: 10.3.10-MariaDB MariaDB Server\n\nCopyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.\n\nType ''help;'' or ''\\h'' for help. Type ''\\c'' to clear the current input statement.\n\nMariaDB [(none)]> SELECT USER(), CURRENT_USER();\n+--------------------------------------------------+----------------+\n| USER() | CURRENT_USER() |\n+--------------------------------------------------+----------------+\n| alice@ip-172-30-0-198.us-west-2.compute.internal | dba@% |\n+--------------------------------------------------+----------------+\n1 row in set (0.000 sec)\n`\n\nFinally, let''s test our bob user in the dba group:\n\n`bash\n$ mysql -u bob -h 172.30.0.198\n[mariadb] Password:\nWelcome to the MariaDB monitor. Commands end with ; or \\g.\nYour MariaDB connection id is 20\nServer version: 10.3.10-MariaDB MariaDB Server\n\nCopyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.\n\nType ''help;'' or ''\\h'' for help. Type ''\\c'' to clear the current input statement.\n\nMariaDB [(none)]> SELECT USER(), CURRENT_USER();\n+------------------------------------------------+----------------+\n| USER() | CURRENT_USER() |\n+------------------------------------------------+----------------+\n| bob@ip-172-30-0-198.us-west-2.compute.internal | dba@% |\n+------------------------------------------------+----------------+\n1 row in set (0.000 sec)\n`\n\nWe can verify that our alice and bob Unix users in the dba Unix group were properly mapped to the dba MariaDB user by looking at the return values of CURRENT_USER()`.\n\nURL: https://mariadb.com/docs/server/reference/plugins/authentication-plugins/authentication-with-pluggable-authentication-modules-pam/configuring-pam-authentication-and-user-mapping-with-unix-authentication', '', 'https://mariadb.com/docs/server/reference/plugins/authentication-plugins/authentication-with-pluggable-authentication-modules-pam/configuring-pam-authentication-and-user-mapping-with-unix-authentication'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (112, 5, 'User and Group Mapping with PAM', 'Description\n-----------\n\nEven when using the pam authentication plugin, the authenticating PAM user account still needs to exist in MariaDB, and the account needs to have privileges in the database. Creating these MariaDB accounts and making sure the privileges are correct can be a lot of work. To decrease the amount of work involved, some users would like to be able to map a PAM user to a different MariaDB user. For example, let’s say that alice and bob are both DBAs. It would be nice if each of them could log into MariaDB with their own PAM username and password, while MariaDB sees both of them as the same dba user. That way, there is only one MariaDB account to keep track of.\n\nAlthough most PAM modules usually do not do things like this, PAM supports the ability to change the user name in the process of authentication.The MariaDB pam authentication plugin fully supports this feature of PAM.\n\nThe pam_user_map PAM Module\n\nRather than building user and group mapping into the pam authentication plugin, MariaDB thought that it would cover the most use cases and offer the most flexibility to offload this functionality to an external PAM module. The pam_user_map PAM module was implemented by MariaDB to facilitate this. This PAM module can be configured in the PAM service used by the pam authentication plugin, just like other PAM modules.\n\nLack of Support for MySQL/Percona Group Mapping Syntax\n\nUnlike MariaDB, MySQL and Percona implemented group mapping in their PAM authentication plugins. If you''ve read through MySQL''s PAM authentication documentation on group mapping or Percona''s PAM authentication documentation on group mapping, you''ve probably seen syntax where the group mappings are provided in the CREATE USER statement like this:\n\n``sql\nCREATE USER ''''@''''\n IDENTIFIED WITH authentication_pam\n AS ''mysql, root=developer, users=data_entry'';\n`\n\nSince MariaDB''s user and group mapping is performed by an external PAM module, MariaDB''s pam authentication plugin does not support this syntax. Instead, the user and group mappings for the pam_user_map PAM module are configured in an external configuration file. This is discussed in a later section.\n\nInstalling the pam_user_map PAM Module\n\nThe pam_user_map PAM module gets installed as part of all our MariaDB server packages.\n\nSome Linux distributions have not picked up this change in their own packages yet. When using such an installation, it may be necessary to compile the PAM module from source as described in the next section, or to manually extract it from one of our server packages and copy it to the target system.\n\nInstalling the pam_user_map PAM Module from Source\n\nInstalling Compilation Dependencies\n\nBefore the module can be compiled from source, you may need to install some dependencies.\n\nOn RHEL, CentOS, and other similar Linux distributions that use RPM packages, you need to install gcc, pam-devel and MariaDB-devel:\n\n`bash\nsudo yum install gcc pam-devel MariaDB-devel\n`\n\nOn Debian, Ubuntu, and other similar Linux distributions that use DEB packages, you need to install gcc, libpam0g-dev:\n\n`bash\nsudo apt-get install gcc libpam0g-dev libmariadb-dev\n`\n\nCompiling and Installing the pam_user_map PAM Module\n\nThe pam_user_map PAM module can be built by downloading plugin/auth_pam/mapper/pam_user_map.c file from the MariaDB source tree and compiling it after minor adjustments. Once it is built, it can be installed to the system''s PAM module directory, which is typically /lib64/security/:\n\n`bash\nwget https://raw.githubusercontent.com/MariaDB/server/10.4/plugin/auth_pam/mapper/pam_user_map.c\nsed -ie ''s/config_auth_pam/plugin_auth_common/'' pam_user_map.c\ngcc -I/usr/include/mysql/ pam_user_map.c -shared -lpam -fPIC -o pam_user_map.so\nsudo install --mode=0755 pam_user_map.so /lib64/security/\n`\n\nYou also need to adjust the major version number in the URL on the first line to match your installed MariaDB version, and the #-I include path argument on the gcc line, as depending on operating system and MariaDB server version, the plugin_auth_common.h file may be installed in a directory other than /usr/include/mysql/ .\n\nConfiguring the pam_user_map PAM Module\n\nThe pam_user_map PAM module uses the configuration file at the path /etc/security/user_map.conf to determine its user and group mappings. The file''s format is described below.\n\nTo map a specific PAM user to a specific MariaDB user:\n\n`\norig_pam_user_name: mapped_mariadb_user_name\n`\n\nOr to map any PAM user in a specific PAM group to a specific MariaDB user, the group name is prefixed with @:\n\n`\n@orig_pam_group_name: mapped_mariadb_user_name\n`\n\nFor example, here is an example /etc/security/user_map.conf:\n\n`\n=========================================================\n#comments and empty lines are ignored\njohn: jack\nbob: admin\ntop: accounting\n@group_ro: readonly\n`\n\nConfiguring PAM\n\nWith user and group mapping, configuring PAM is done similar to how it is normally done with the pam authentication plugin. However, when configuring the PAM service, you will have to add an auth line for the pam_user_map PAM module to the service''s PAM configuration file:\n\n`\nauth required pam_unix.so audit\nauth required pam_user_map.so\naccount required pam_unix.so audit\n`\n\nCreating Users\n\nWith user and group mapping, creating users is done similar to how it is normally done with the pam authentication plugin. However, one major difference is that you will need to GRANT the PROXY privilege on the mapped user to the original user.\n\nConsider having the following configured in /etc/security/user_map.conf:\n\n`\nfoo: bar\n@dba:dba\n`\n\nThen you could execute the following to grant the relevant privileges:\n\n`sql\nCREATE USER ''bar''@''%'' IDENTIFIED BY ''strongpassword'';\nGRANT ALL PRIVILEGES ON . TO ''bar''@''%'' ;\n\nCREATE USER ''dba''@''%'' IDENTIFIED BY ''strongpassword'';\nGRANT ALL PRIVILEGES ON . TO ''dba''@''%'' ;\n\nCREATE USER ''''@''%'' IDENTIFIED VIA pam USING ''mariadb'';\nGRANT PROXY ON ''bar''@''%'' TO ''''@''%'';\nGRANT PROXY ON ''dba''@''%'' TO ''''@''%'';\n`\n\nNote that the ''''@''%'' account is a special catch-all anonymous account. Any login by a user that has no more specific account match in the system will be matched by this anonymous account.\n\nAlso note that you might not be able to create the ''''@''%'' anonymous account by default on some systems without doing some extra steps first. See Fixing a Legacy Default Anonymous Account for more information.\n\nVerifying that Mapping is Occurring\n\nIn case any user mapping is performed, the original user name is returned by the SQL function USER(), while the authenticated user name is returned by the SQL function CURRENT_USER(). The latter actually defines what privileges are available to a connected user.\n\nConsider having the following configured:\n\n`\nfoo: bar\n`\n\nThen the following output would verify that it is working properly:\n\n`bash\n$ mysql -u foo -h 172.30.0.198\n[mariadb] Password:\nWelcome to the MariaDB monitor. Commands end with ; or \\g.\nYour MariaDB connection id is 22\nServer version: 10.3.10-MariaDB MariaDB Server\n\nCopyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.\n\nType ''help;'' or ''\\h'' for help. Type ''\\c'' to clear the current input statement.\n\nMariaDB [(none)]> SELECT USER(), CURRENT_USER();\n+------------------------------------------------+----------------+\n| USER() | CURRENT_USER() |\n+------------------------------------------------+----------------+\n| foo@ip-172-30-0-198.us-west-2.compute.internal | bar@% |\n+------------------------------------------------+----------------+\n1 row in set (0.000 sec)\n`\n\nWe can verify that our foo PAM user was properly mapped to the bar MariaDB user by looking at the return value of CURRENT_USER().\n\nLogging\n\nBy default, the pam_user_map PAM module does not perform any logging. However, if you want to enable debug logging, then you can add the debug module argument to the service''s PAM configuration file:\n\n`\nauth required pam_unix.so audit\nauth required pam_user_map.so debug\naccount required pam_unix.so audit\n`\n\nWhen debug logging is enabled, the pam_user_map PAM module will write log entries to the same syslog location as other PAM modules, which is typically /var/log/secure on many systems.\n\nFor example, this debug log output can look like the following:\n\n`\nJan 9 05:42:13 ip-172-30-0-198 mysqld: pam_user_map(mariadb:auth): Opening file ''/etc/security/user_map.conf''.\nJan 9 05:42:13 ip-172-30-0-198 mysqld: pam_user_map(mariadb:auth): Incoming username ''alice''.\nJan 9 05:42:13 ip-172-30-0-198 mysqld: pam_user_map(mariadb:auth): User belongs to 2 groups [alice,dba].\nJan 9 05:42:13 ip-172-30-0-198 mysqld: pam_user_map(mariadb:auth): Check if user is in group ''dba'': YES\nJan 9 05:42:13 ip-172-30-0-198 mysqld: pam_user_map(mariadb:auth): User mapped as ''dba''\nJan 9 05:43:36 ip-172-30-0-198 mysqld: pam_user_map(mariadb:auth): Opening file ''/etc/security/user_map.conf''.\nJan 9 05:43:36 ip-172-30-0-198 mysqld: pam_user_map(mariadb:auth): Incoming username ''bob''.\nJan 9 05:43:36 ip-172-30-0-198 mysqld: pam_user_map(mariadb:auth): User belongs to 2 groups [bob,dba].\nJan 9 05:43:36 ip-172-30-0-198 mysqld: pam_user_map(mariadb:auth): Check if user is in group ''dba'': YES\nJan 9 05:43:36 ip-172-30-0-198 mysqld: pam_user_map(mariadb:auth): User mapped as ''dba''\nJan 9 06:08:36 ip-172-30-0-198 mysqld: pam_user_map(mariadb:auth): Opening file ''/etc/security/user_map.conf''.\nJan 9 06:08:36 ip-172-30-0-198 mysqld: pam_user_map(mariadb:auth): Incoming username ''foo''.\nJan 9 06:08:36 ip-172-30-0-198 mysqld: pam_user_map(mariadb:auth): User belongs to 1 group [foo].\nJan 9 06:08:36 ip-172-30-0-198 mysqld: pam_user_map(mariadb:auth): Check if user is in group ''dba'': NO\nJan 9 06:08:36 ip-172-30-0-198 mysqld: pam_user_map(mariadb:auth): Check if username ''foo'': YES\nJan 9 06:08:36 ip-172-30-0-198 mysqld: pam_user_map(mariadb:auth): User mapped as ''bar''\n`\n\nKnown Issues\n\nPAM User with Same Name as Mapped MariaDB User Must Exist\n\nWith user and group mapping, any PAM user or any PAM user in a given PAM group can be mapped to a specific MariaDB user account. However, due to the way PAM works, a PAM user with the same name as the mapped MariaDB user account must exist.\n\nConsider the configuration file for the PAM service file containing the following:\n\n`\nauth required pam_sss.so\nauth required pam_user_map.so debug\naccount sufficient pam_unix.so\naccount sufficient pam_sss.so\n`\n\nConsider etc/security/user_map.conf containing the following:\n\n`\n@dba: dba\n`\n\nIn that case, any PAM user in the PAM group dba are mapped to the MariaDB user account dba. But if a PAM user with the name dba doesn''t exist, the pam_user_map PAM module''s debug logging writes errors to the syslog, like the following:\n\n`\nSep 27 17:17:05 dbserver1 mysqld: pam_user_map(mysql:auth): Opening file ''/etc/security/user_map.conf''.\nSep 27 17:17:05 dbserver1 mysqld: pam_user_map(mysql:auth): Incoming username ''alice''.\nSep 27 17:17:05 dbserver1 mysqld: pam_user_map(mysql:auth): User belongs to 4 groups [dba,mongod,mongodba,mysql].\nSep 27 17:17:05 dbserver1 mysqld: pam_user_map(mysql:auth): Check if user is in group ''mysql'': YES\nSep 27 17:17:05 dbserver1 mysqld: pam_user_map(mysql:auth): User mapped as ''dba''\nSep 27 17:17:05 dbserver1 mysqld: pam_unix(mysql:account): could not identify user (from getpwnam(dba))\nSep 27 17:17:05 dbserver1 mysqld: pam_sss(mysql:account): Access denied for user dba: 10 (User not known to the underlying authentication module)\nSep 27 17:17:05 dbserver1 mysqld: 2018-09-27 17:17:05 72 [Warning] Access denied for user ''alice''@''localhost'' (using password: NO)\n`\n\nIn the above log snippet, notice that both the pam_unix and the pam_sss PAM modules are complaining that the dba PAM user does not appear to exist, and that these complaints cause the PAM authentication process to fail, which causes the MariaDB authentication process to fail as well.\n\nThis can be fixed by creating a PAM user with the same name as the mapped MariaDB user account, which is dba in this case.\n\nYou may also be able to work around this problem by essentially disabling PAM''s account verification for the service with the pam_permit PAM module. For example, in the above case, that would be:\n\n`\nauth required pam_sss.so\nauth required pam_user_map.so debug\naccount required pam_permit.so\n``\n\nSee MDEV-17315 for more information.\n\nTutorials\n\nYou may find the following PAM and user mapping-related tutorials helpful:\n\n Configuring PAM Authentication and User Mapping with Unix Authentication\n Configuring PAM Authentication and User Mapping with LDAP Authentication\n\nURL: https://mariadb.com/docs/server/reference/plugins/authentication-plugins/authentication-with-pluggable-authentication-modules-pam/user-and-group-mapping-with-pam', '', 'https://mariadb.com/docs/server/reference/plugins/authentication-plugins/authentication-with-pluggable-authentication-modules-pam/user-and-group-mapping-with-pam'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (113, 5, 'Pluggable Authentication Overview', 'Description\n-----------\n\nWhen a user attempts to log in, the authentication plugin controls how MariaDB Server determines whether the connection is from a legitimate user.\n\nWhen creating or altering a user account with the GRANT, CREATE USER or ALTER USER statements, you can specify the authentication plugin you want the user account to use, by providing the IDENTIFIED VIA clause. By default, when you create a user account without specifying an authentication plugin, MariaDB uses the mysql_native_password plugin.\n\nYou can specify multiple authentication plugins for each user account.\n\nThe root@localhost user created by mariadb-install-db has the ability to use two authentication plugins:\n\n1. It is configured to try to use the unix_socket authentication plugin. This allows the root@localhost user to log in without a password via the local Unix socket file defined by the socket system variable, as long as the login is attempted from a process owned by the operating system root user account.\n2. If authentication fails with the unix_socket authentication plugin, it is configured to try to use the mysql_native_password authentication plugin. However, an invalid password is initially set, so in order to authenticate this way, a password must be set with SET PASSWORD.\n\nSupported Authentication Plugins\n\nThe authentication process is a conversation between the server and a client. MariaDB implements both server-side and client-side authentication plugins.\n\nSupported Server Authentication Plugins\n\nMariaDB provides seven server-side authentication plugins:\n\n mysql_native_password\n mysql_old_password\n ed25519\n gssapi\n pam (Unix only)\n unix_socket (Unix only)\n named_pipe (Windows only)\n\nSupported Client Authentication Plugins\n\nMariaDB provides eight client-side authentication plugins:\n\n mysql_native_password\n mysql_old_password\n client_ed25519\n auth_gssapi_client\n dialog\n mysql_clear_password\n sha256_password\n caching_sha256_password\n\nOptions Related to Authentication Plugins\n\nServer Options Related to Authentication Plugins\n\nMariaDB supports the following server options related to authentication plugins:\n\n| Server Option | Description |\n| ----------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |\n| old_passwords={1 \\| 0} | If set to 1 (0 is default), MariaDB reverts to using the mysql_old_password authentication plugin by default for newly created users and passwords, instead of the mysql_native_password authentication plugin. |\n| plugin_dir=path | Path to the plugin directory. For security reasons, either make sure this directory can only be read by the server, or set secure_file_priv. |\n| plugin_maturity=level | The lowest acceptable plugin maturity. MariaDB will not load plugins less mature than the specified level. |\n| secure_auth | Connections will be blocked if they use the mysql_old_password authentication plugin. |\n\nClient Options Related to Authentication Plugins\n\nMost clients and utilities support command-line arguments related to client authentication plugins:\n\n| Client Option | Description |\n| -------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| --connect-expired-password | Notify the server that this client is prepared to handle expired password sandbox mode even if --batch was specified. |\n| --default-auth=name | Default authentication client-side plugin to use. |\n| --plugin-dir=path | Directory for client-side plugins. |\n| --secure-auth | Refuse to connect to the server if the server uses the mysql_old_password authentication plugin. This mode is off by default, which is different from MySQL. |\n\nDevelopers who are using MariaDB Connector/C can implement similar functionality in their application by setting the following options with the mysql_optionsv function:\n\n MYSQL_OPT_CAN_HANDLE_EXPIRED_PASSWORDS\n MYSQL_PLUGIN_DIR\n MYSQL_DEFAULT_AUTH\n MYSQL_SECURE_AUTH\n\nFor example:\n\n``ini\nmysql_optionsv(mysql, MYSQL_OPT_CAN_HANDLE_EXPIRED_PASSWORDS, 1);\nmysql_optionsv(mysql, MYSQL_DEFAULT_AUTH, "name");\nmysql_optionsv(mysql, MYSQL_PLUGIN_DIR, "path");\nmysql_optionsv(mysql, MYSQL_SECURE_AUTH, 1);\n`\n\nInstallation Options Related to Authentication Plugins\n\nmariadb-install-db supports the following installation options related to authentication plugins:\n\n| Installation Option | Description |\n| ---------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| --auth-root-authentication-method={normal \\| socket} | If set to normal (the default), it creates a root@localhost account that authenticates with the mysql_native_password authentication plugin and that has no initial password set, which can be insecure. If set to socket, it creates a root@localhost account that authenticates with the unix_socket authentication plugin. Set to normal by default. |\n| --auth-root-socket-user=USER | Used with --auth-root-authentication-method=socket. It specifies the name of the second account to create with SUPER privileges in addition to root, as well as of the system account allowed to access it. Defaults to the value of --user. |\n\nExtended SQL Syntax\n\nMariaDB has extended the SQL standard GRANT, CREATE USER, and ALTER USER statements, so that they support specifying different authentication plugins for specific users. An authentication plugin can be specified with these statements by providing the IDENTIFIED VIA clause. Examples:\n\n`sql\nGRANT ON TO \n IDENTIFIED VIA [ USING ]\n`\n\n`sql\nCREATE USER \n IDENTIFIED VIA [ USING ]\n`\n\n`sql\nALTER USER \n IDENTIFIED VIA [ USING ]\n`\n\nThe optional USING clause allows users to provide an authentication string to a plugin. The authentication string''s format and meaning is completely defined by the plugin.\n\nFor example, for the mysql_native_password authentication plugin, the authentication string should be a password hash:\n\n`sql\nCREATE USER mysqltest_up1 \n IDENTIFIED VIA mysql_native_password USING ''E8D46CE25265E545D225A8A6F1BAF642FEBEE5CB'';\n`\n\nSince mysql_native_password is the default authentication plugin, the above is just another way of saying the following:\n\n`\nCREATE USER mysqltest_up1 \n IDENTIFIED BY PASSWORD ''E8D46CE25265E545D225A8A6F1BAF642FEBEE5CB'';\n`\n\nIn contrast, for the pam authentication plugin, the authentication string should refer to a PAM service name:\n\n`sql\nCREATE USER mysqltest_up1 \n IDENTIFIED VIA pam USING ''mariadb'';\n`\n\nA user account can be associated with multiple authentication plugins.\n\nTo configure the root@localhost user account to try the unix_socket authentication plugin, followed by the mysql_native_password authentication plugin as a backup, execute the following query:\n\n`sql\nCREATE USER root@localhost \n IDENTIFIED VIA unix_socket \n OR mysql_native_password USING PASSWORD("verysecret");\n`\n\nSee Authentication for more information.\n\nAuthentication Plugins Installed by Default\n\nServer Authentication Plugins Installed by Default\n\nNot all server-side authentication plugins are installed by default. If a specific server-side authentication plugin is not installed by default, then you can find the installation procedure on the documentation page for the specific authentication plugin.\n\nThe following server-side authentication plugins are installed by default:\n\n The mysql_native_password and mysql_old_password authentication plugins authentication plugins are installed by default in all builds.\n The unix_socket authentication plugin is installed by default in all builds on Unix and Linux.\n The named_pipe authentication plugin is installed by default in all builds on Windows.\n\nThe following server-side authentication plugins are installed by default:\n\n The mysql_native_password and mysql_old_password authentication plugins are installed by default in all builds.\n The unix_socket authentication plugin is installed by default in new installations that use the .deb packages provided by Debian''s default repositories and Ubuntu''s default repositories in Ubuntu. See Differences in MariaDB in Debian (and Ubuntu) for more information.\n The named_pipe authentication plugin is installed by default in all builds on Windows.\n\nClient Authentication Plugins Installed by Default\n\nClient-side authentication plugins do not need to be _installed_ in the same way that server-side authentication plugins do. If the client uses either the libmysqlclient or MariaDB Connector/C library, then the library automatically loads client-side authentication plugins from the library''s plugin directory whenever they are needed.\n\nMost clients and utilities support the --plugin-dir command line argument that can be used to set the path to the library''s plugin directory:\n\n| Client Option | Description |\n| ----------------- | ---------------------------------- |\n| --plugin-dir=path | Directory for client-side plugins. |\n\nDevelopers who are using MariaDB Connector/C can implement similar functionality in their application by setting the MYSQL_PLUGIN_DIR option with the mysql_optionsv function. Example:\n\n`c\nmysql_optionsv(mysql, MYSQL_PLUGIN_DIR, "path");\n`\n\nIf your client encounters errors similar to the following error, you may need to set the path to the library''s plugin directory:\n\n`\nERROR 2059 (HY000): Authentication plugin ''dialog'' cannot be loaded: /usr/lib/mysql/plugin/dialog.so: cannot open shared object file: No such file or directory\n`\n\nIf the client does not use either the libmysqlclient or MariaDB Connector/C library, then you will have to determine which authentication plugins are supported by the specific client library used by the client.\n\nIf the client uses either the libmysqlclient or MariaDB Connector/C library, but the client is not bundled with either library''s _optional_ client authentication plugins, then you can only use the conventional authentication plugins (like mysql_native_password and mysql_old_password) and the non-conventional authentication plugins that don''t require special client-side authentication plugins (like unix_socket and named_pipe).\n\nDefault Authentication Plugin\n\nDefault Server Authentication Plugin\n\nThe mysql_native_password authentication plugin is currently the default authentication plugin in all versions of MariaDB if the old_passwords system variable is set to 0, which is the default.\n\nOn a system with the old_passwords system variable set to 0, this means that if you create a user account with either the GRANT or CREATE USERstatements, and if you do not specify an authentication plugin with theIDENTIFIED VIAclause, then MariaDB will use the mysql_native_password authentication plugin for the user account.\n\nCreating a user account like this, it uses the mysql_native_password authentication plugin:\n\n`sql\nCREATE USER username@hostname;\n`\n\nThe same is true for this user account:\n\n`sql\nCREATE USER username@hostname IDENTIFIED BY ''notagoodpassword'';\n`\n\nThe mysql_old_password authentication plugin becomes the default authentication plugin in all versions of MariaDB, if the old_passwords system variable is explicitly set to 1.\n\nThe mysql_old_password authentication plugin is not considered secure. It is recommended to avoid using this authentication plugin. To help prevent undesired use of the mysql_old_password authentication plugin, the server supports the secure_auth system variable that configures the server to refuse connections trying to use the mysql_old_password authentication plugin.\n\nMost clients and utilities support secure_auth.\n\n| Server Option | Description |\n| -----------------\n\n[Truncated — full content at mariadb.com/docs]', '', 'https://mariadb.com/docs/server/reference/plugins/authentication-plugins/pluggable-authentication-overview'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (114, 5, 'Plugin Maturity', 'Description\n-----------\n\nThe following table lists the various plugins included in MariaDB ordered by their maturity. Note that maturity will differ across MariaDB versions - see below for an easy way to get a complete list of plugins and their maturity in your version of MariaDB:\n\n| Plugin | Version | Maturity |\n| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- | ------------------------------------------------------------ |\n| Archive | 3.0 | Stable |\n| Aria | 1.6 | Stable |\n| Audit Plugin | 1.4 | Stable |\n| aws_key_management | 1.0 | Stable |\n| binlog | 2.0 | Stable |\n| Blackhole | 1.0 | Stable |\n| Connect | 1.7 | Stable |\n| CLIENT_STATISTICS | 2.0 | Stable |\n| cracklib_password_check | 1.0 | Stable |\n| CSV | 1.0 | Stable |\n| DECLARE BY / associative array | 1.0 | Gamma |\n| DISKS | 1.1 | Stable |\n| ed25519 | 1.1 | Stable |\n| FederatedX | 2.1 | Stable |\n| Feedback | 1.1 | Stable |\n| file_key_management | 2.0 | Gamma |\n| gssapi | 1.0 | Stable |\n| INDEX_STATISTICS | 2.0 | Stable |\n| INET4 | 1.0 | Gamma |\n| INET6 | 1.0 | Stable |\n| InnoDB | 10.\\* | Stable |\n| LOCALES | 1.0 | Stable |\n| Memory | 1.0 | Stable |\n| METADATA_LOCK_INFO | 0.1 | Stable |\n| mhnsw | 1.0 | Stable |\n| MRG_MyISAM | 1.0 | Stable |\n| Mroonga | 7.7 | Stable |\n| MyISAM | 1.0 | Stable |\n| MyRocks | 1.0 | Stable |\n| mysql_json | 0.1 | Stable |\n| mysql_native_password | 1.0 | Stable |\n| mysql_old_password | 1.0 | Stable |\n| named_pipe | 1.0 | Stable |\n| online_alter_log | 2.0 | Stable |\n| pam | 1.0 | Stable |\n| password_reuse_check | 2.0 |

Stable
(introduced in 10.10.2, 10.9.5, and 10.8.7)

|\n| partition | 1.0 | Stable |\n| Performance_Schema | 0.1 | Stable |\n| QUERY_CACHE_INFO | 1.1 | Stable |\n| query_response_time | 1.0 | Stable |\n| S3 | 1.0 | Stable |\n| semisync | 1.0 | Stable |\n| Sequence | 1.0 | Stable |\n| SERVER_AUDIT | 2.6 | Stable |\n| simple_password_check | 1.0 | Stable |\n| Spider | 3.3 | Stable |\n| SQL_ERROR_LOG | 1.0 | Stable |\n| SYS_REFCURSOR | 1.0 | Gamma |\n| TABLE_STATISTICS | 2.0 | Stable |\n| USER_STATISTICS | 2.0 | Stable |\n| user_variables | 1.0 | Stable |\n| TokuDB | 4.0 |

Stable
(removed in 10.6)

|\n| unix_socket | 1.1 | Stable |\n| UUID | 1.0 |

Stable
(introduced in 10.9.1)

|\n| uuid_v4 | 1.0 | Stable |\n| uuid_v7 | 1.0 | Stable |\n| wsrep | 1.0 | Stable |\n| wsrep_connections | 1.0 | Stable |\n| WSREP_INFO | 1.0 | Stable |\n| wsrep_provider | 1.0 | Stable |\n| wsrep_thd_info | 1.0 | Stable |\n| OQGraph | 3.0 | Gamma |\n| Sphinx | 2.0 | Gamma |\n| Columnstore | 1.0 | Beta |\n| handlersocket | 1.0 | Beta |\n| Cassandra | 0.1 |\n\n[Truncated — full content at mariadb.com/docs]', '', 'https://mariadb.com/docs/server/reference/plugins/information-on-plugins/list-of-plugins'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (115, 5, 'Audit Plugin Configuration', 'Description\n-----------\n\nAfter the audit plugin has been installed and loaded, there will be some new global variables within MariaDB. These can be used to configure many components, limits, and methods related to auditing the server. You may set these variables related to the logs, such as their location, size limits, rotation parameters, and method of logging information. You may also set what information is logged, such connects, disconnects, and failed attempts to connect. You can also have the audit plugin log queries, read and write access to tables. So as not to overload your logs, the audit plugin can be configured based on lists of users. You can include or exclude the activities of specific users in the logs.\n\nTo see a list of audit plugin-related variables on the server and their values, execute the follow while connected to the server:\n\n``sql\nSHOW GLOBAL VARIABLES LIKE ''server_audit%'';\n+-------------------------------+-----------------------+\n| Variable_name | Value |\n+-------------------------------+-----------------------+\n| server_audit_events | |\n| server_audit_excl_users | |\n| server_audit_file_buffer_size | 0 |\n| server_audit_file_path | server_audit.log |\n| server_audit_file_rotate_now | OFF |\n| server_audit_file_rotate_size | 1000000 |\n| server_audit_file_rotations | 9 |\n| server_audit_incl_users | |\n| server_audit_logging | OFF |\n| server_audit_mode | 0 |\n| server_audit_output_type | file |\n| server_audit_query_log_limit | 1024 |\n| server_audit_sync_log_file | OFF |\n| server_audit_syslog_facility | LOG_USER |\n| server_audit_syslog_ident | mysql-server_auditing |\n| server_audit_syslog_info | |\n| server_audit_syslog_priority | LOG_INFO |\n+-------------------------------+-----------------------+\n17 rows in set (0.003 sec)\n`\n\n`sql\nSHOW GLOBAL VARIABLES LIKE ''server_audit%'';\n\n+-------------------------------+-----------------------+\n| Variable_name | Value |\n+-------------------------------+-----------------------+\n| server_audit_events | CONNECT,QUERY,TABLE |\n| server_audit_excl_users | |\n| server_audit_file_path | server_audit.log |\n| server_audit_file_rotate_now | OFF |\n| server_audit_file_rotate_size | 1000000 |\n| server_audit_file_rotations | 9 |\n| server_audit_incl_users | |\n| server_audit_logging | ON |\n| server_audit_mode | 0 |\n| server_audit_output_type | file |\n| server_audit_query_log_limit | 1024 |\n| server_audit_syslog_facility | LOG_USER |\n| server_audit_syslog_ident | mysql-server_auditing |\n| server_audit_syslog_info | |\n| server_audit_syslog_priority | LOG_INFO |\n+-------------------------------+-----------------------+\n`\n\nThe values of these variables can be changed by an administrator with the SUPER privilege, using the SET statement. Below is an example of how to disable audit logging:\n\n`sql\nSET GLOBAL server_audit_logging=OFF;\n`\n\nAlthough it is possible to change all of the variables shown above, some of them may be reset when the server restarts. Therefore, you may want set them in the configuration file (e.g., /etc/my.cnf.d/server.cnf) to ensure the values are the same after a restart:\n\n`ini\n[server]\n... \nserver_audit_logging=OFF \n…\n`\n\nFor the reason given in the paragraph above, you would not generally set variables related to the auditing plugin using the SET statement. However, you might do so to test settings before making them more permanent. Since one cannot always restart the server, you would use the SET` statement to change immediately the variables and then include the same settings in the configuration file so that the variables are set again as you prefer when the server is restarted.\n\nConfiguring Logs and Setting Other Variables\n\nOf all of the server variables you can set, you may want to set initially the server_audit_events variable to tell the Audit Plugin which events to log. The Log Settings documentation page describes in detail the choices you have and provides examples of log entries related to them.\n\nYou can see a detailed list of system variables related to the MariaDB Audit Plugin on the System Variables documentation page. Status variables related to the Audit Plugin are listed and explained on the Status Variables documentation page.\n\nURL: https://mariadb.com/docs/server/reference/plugins/mariadb-audit-plugin/mariadb-audit-plugin-configuration', '', 'https://mariadb.com/docs/server/reference/plugins/mariadb-audit-plugin/mariadb-audit-plugin-configuration'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (116, 5, 'Audit Plugin Installation', 'Description\n-----------\n\nThe server_audit plugin logs the server''s activity. For each client session, it records who connected to the server (i.e., user name and host), what queries were executed, and which tables were accessed and server variables that were changed. This information is stored in a rotating log file or it may be sent to the local syslogd.\n\nLocating the Plugin\n\nThe server_audit plugin''s shared library is included in MariaDB packages as the server_audit.so or server_audit.dll shared library on systems where it can be built.\n\nThe plugin must be located in the plugin directory, the directory containing all plugin libraries for MariaDB. The path to this directory is configured by the plugin_dir system variable. To see the value of this variable and thereby determine the file path of the plugin library, execute the following SQL statement:\n\n``sql\nSHOW GLOBAL VARIABLES LIKE ''plugin_dir'';\n\n+---------------+--------------------------+\n| Variable_name | Value |\n+---------------+--------------------------+\n| plugin_dir | /usr/lib64/mysql/plugin/ |\n+---------------+--------------------------+\n`\n\nCheck the directory returned at the filesystem level to make sure that you have a copy of the plugin library, server_audit.so or server_audit.dll, depending on your system. It''s included in recent installations of MariaDB. If you do not have it, you should upgrade MariaDB.\n\nInstalling the Plugin\n\nAlthough the plugin''s shared library is distributed with MariaDB by default, the plugin is not actually installed by MariaDB by default. There are two methods that can be used to install the plugin with MariaDB.\n\nThe first method can be used to install the plugin without restarting the server. You can install the plugin dynamically by executing INSTALL SONAME or INSTALL PLUGIN:\n\n`sql\nINSTALL SONAME ''server_audit'';\n`\n\nThe second method can be used to tell the server to load the plugin when it starts up. The plugin can be installed this way by providing the --plugin-load or the --plugin-load-add options. This can be specified as a command-line argument to mariadbd , or it can be specified in a relevant server option group in an option file:\n\n`ini\n[mariadb]\n...\nplugin_load_add = server_audit\n`\n\nUninstalling the Plugin\n\nYou can uninstall the plugin dynamically by executing UNINSTALL SONAME or UNINSTALL PLUGIN:\n\n`sql\nUNINSTALL SONAME ''server_audit'';\n`\n\nIf you installed the plugin by providing the --plugin-load or the --plugin-load-add options in a relevant server option group in an option file, then those options should be removed to prevent the plugin from being loaded the next time the server is restarted.\n\nProhibiting Uninstallation\n\nThe UNINSTALL SONAME or UNINSTALL PLUGIN statements may be used to uninstall plugins. For the server_audit plugin, you might want to disable this capability. To prevent the plugin from being uninstalled, you could set the server_audit option to FORCE_PLUS_PERMANENT in a relevant server option group in an option file after the plugin is loaded once:\n\n`ini\n[mariadb]\n...\nplugin_load_add = server_audit\nserver_audit=FORCE_PLUS_PERMANENT\n`\n\nOnce you''ve added the option to the server''s option file and restarted the server, the plugin can''t be uninstalled. If someone tries to uninstall the audit plugin, then an error message will be returned. Below is an example of the error message:\n\n`sql\nUNINSTALL PLUGIN server_audit;\n\nERROR 1702 (HY000):\nPlugin ''server_audit'' is force_plus_permanent and can not be unloaded\n`\n\nFor more information on FORCE_PLUS_PERMANENT` and other option values for the server_audit option, see Plugin Overview: Configuring Plugin Activation at Server Startup for more information.\n\nURL: https://mariadb.com/docs/server/reference/plugins/mariadb-audit-plugin/mariadb-audit-plugin-installation', '', 'https://mariadb.com/docs/server/reference/plugins/mariadb-audit-plugin/mariadb-audit-plugin-installation'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (117, 5, 'Audit Plugin Location and Rotation of Logs', 'Description\n-----------\n\nLogs can be written to a separate file or to the system logs. If you prefer to have the logging separated from other system information, the value of the variable server_audit_output_type should be set to file. Incidentally, file is the only option on Windows systems.\n\nYou can force a rotation by enabling the server_audit_file_rotate_now variable like so:\n\n``sql\nSET GLOBAL server_audit_file_rotate_now = ON;\n`\n\nSeparate log files\n\nIn addition to setting server_audit_output_type, you will have to provide the file path and name of the audit file. This is set in the variable server_audit_file_path. You can set the file size limit of the log file with the variable server_audit_file_rotate_size.\n\nSo, if rotation is on and the log file has reached the size limit you set, a copy is created with a consecutive number as extension the original file will be truncated to be used for the auditing again. To limit the number of log files created, set the variable server_audit_file_rotations. You can force log file rotation by setting the variable server_audit_file_rotate_now to a value of ON. When the number of files permitted is reached, the oldest file will be overwritten. Here is how those variables might be set in a server configuration file:\n\n`ini\n[mysqld]\n...\nserver_audit_file_rotate_now=ON \nserver_audit_file_rotate_size=1000000 \nserver_audit_file_rotations=5\n...\n`\n\nSystem logs\n\nFor security reasons, it''s better sometimes to use the system logs instead of a local file owned by the mysql user. To do this, the value of server_audit_output_type needs to be set to syslog. Advanced configurations, such as using a remote syslogd service, are part of the syslogd configuration.\n\nThe variables, server_audit_syslog_ident and server_audit_syslog_info can be used to identify a system log entry made by the audit plugin. If a remote syslogd service is used for several MariaDB servers, these same variables are also used to identify the MariaDB server.\n\nHere is a system log entry taken from a server which had server_audit_syslog_ident set to the default value of mysql­-server_auditing, and server_audit_syslog_info set to .\n\n`sql\nAug 717:19:58localhostmysql-­server_auditing: \n localhost.localdomain,root,localhost,1,7, \nQUERY, mysql, ''SELECT * FROM user'',0\n`\n\nAlthough the default values for server_audit_syslog_facility and server_audit_syslog_priority should be sufficient in most cases. They can be changed based on the definition in syslog.h for the functions openlog() and syslog()`.\n\nURL: https://mariadb.com/docs/server/reference/plugins/mariadb-audit-plugin/mariadb-audit-plugin-location-and-rotation-of-logs', '', 'https://mariadb.com/docs/server/reference/plugins/mariadb-audit-plugin/mariadb-audit-plugin-location-and-rotation-of-logs'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (118, 5, 'Audit Plugin Log Format', 'Description\n-----------\n\nThe audit plugin logs user access to MariaDB and its objects. The audit trail (that is, the audit log) is a set of records, written as a list of fields to a file in a plain‐text format. The fields in the log are separated by commas. The format used for the plugin''s own log file is slightly different from the format used if it logs to the system log because it has its own standard format. \n\nFormal Specification\n\nWhen the MariaDB Audit Plugin (v1) writes to a dedicated file, it uses a comma-separated (CSV) format. For tool developers, it is essential to map the connectionid to the server''s global connection identifier to enable cross-log analysis.\n\nTemplate: ,,,,,,,,,\n\n| Field | Component | Data Type | Standardized Name / Description |\n| ----- | -------------- | -------------- | -------------------------------------------------------------------------------------------------------------------------------------------- |\n| 1 | timestamp | DateTime | Formatted as %Y%m%d %H:%i:%s (the default), or as specified in server_audit_timestamp_format. |\n| 2 | serverhost | String | Hostname of the originating server. |\n| 5 | connectionid | Unsigned Int | Standardized: Thread ID. Matches the Thread ID in Error, General, and Slow logs. |\n| 6 | queryid | Unsigned Int | A unique identifier for the specific query, used to correlate QUERY and TABLE events. |\n| 7 | operation | String | Action type (e.g., CONNECT, QUERY, READ, WRITE). |\n| 10 | retcode | Integer | Result code (0 for success). |\n\nAudit Log Format with Syslog\n\nIf server_audit_output_type is set to SYSLOG, the standard CSV line is prefixed with syslog metadata: : [Standard CSV Fields]\n\nVarious events result in different audit records. Some events do not return a value for some fields (for instance, when the active database is not set when connecting to the server).\n\nBelow is a generic example of the output for connect events, with placeholders representing data. These are events in which a user connected, disconnected, or tried unsuccessfully to connect to the server.\n\n``ini\n[timestamp],[serverhost],[username],[host],[connectionid],0,CONNECT,[database],,0 \n[timestamp],[serverhost],[username],[host],[connectionid],0,DISCONNECT,,,0 \n[timestamp],[serverhost],[username],[host],[connectionid],0,FAILED_CONNECT,,,[retcode]\n`\n\nHere is the one audit record generated for each query event:\n\n`ini\n[timestamp],[serverhost],[username],[host],[connectionid],[queryid],QUERY,[database],[object], [retcode]\n`\n\nBelow are generic examples of records that are entered in the audit log for each type of table event:\n\n`ini\n[timestamp],[serverhost],[username],[host],[connectionid],[queryid],CREATE,[database],[object], \n[timestamp],[serverhost],[username],[host],[connectionid],[queryid],READ,[database],[object], \n[timestamp],[serverhost],[username],[host],[connectionid],[queryid],WRITE,[database],[object], \n[timestamp],[serverhost],[username],[host],[connectionid],[queryid],ALTER,[database],[object], \n[timestamp],[serverhost],[username],[host],[connectionid],[queryid],RENAME,[database], \n[object_old]|[database_new].[object_new], \n[timestamp],[serverhost],[username],[host],[connectionid],[queryid],DROP,[database],[object],\n`\n\nPasswords are hidden in the log for certain types of queries. They are replaced with asterisks for GRANT, CREATE USER, CREATE MASTER, CREATE SERVER, and ALTER SERVER statements. Passwords, however, are not replaced for the PASSWORD() and OLD_PASSWORD() functions when they are used inside other SQL statements (i.e., SET PASSWORD).\n\nFor Galera Cluster replication applier operations, audit log plugin logs events with a generic name of ` .\n\nThis addresses an issue where the user was logged on the primary node, but stripped from other cluster nodes. See MDEV-35511 for details.\n\nFor Galera Cluster replication applier operations, audit log plugin logs events without indicating what user initiates them.\n\nURL: https://mariadb.com/docs/server/reference/plugins/mariadb-audit-plugin/mariadb-audit-plugin-log-format', '', 'https://mariadb.com/docs/server/reference/plugins/mariadb-audit-plugin/mariadb-audit-plugin-log-format'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (119, 5, 'Audit Plugin Log Settings', 'Description\n-----------\n\nEvents that are logged by the MariaDB Audit Plugin are grouped generally into different types: connect, query, and table events. To log based on these types of events, set the variable, server_audit_events to CONNECT, QUERY, or TABLE. To have the Audit Plugin log more than one type of event, put them in a comma-separated list like so:\n\n``sql\nSET GLOBAL server_audit_events = ''CONNECT,QUERY,TABLE'';\n`\n\nYou can put the equivalent of this in the configuration file like so:\n\n`ini\n[mysqld]\n...\nserver_audit_events=connect,query\n`\n\nBy default, logging is set to OFF. To enable it, set the server_audit_logging variable to ON. Note that if the query cache is enabled, and a query is returned from the query cache, no TABLE records will appear in the log since the server didn''t open or access any tables and instead relied on the cached results. So you may want to disable query caching.\n\nThere are a few types of events that may be logged, not just the three common ones mentioned above. A full list of related system variables is detailed on the Server_Audit System Variables page, and status variables on the Server_Audit System Variables page of this documentation. Some of the major ones are highlighted below:\n\n| Type | Description |\n| ---------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| CONNECT | Connects, disconnects and failed connects—including the error code. |\n| QUERY | Queries executed and their results in plain text, including failed queries due to syntax or permission errors. |\n| TABLE | Tables affected by query execution. |\n| QUERY_DDL | Similar to QUERY, but filters only DDL-type queries (CREATE, ALTER, DROP, RENAME and TRUNCATE). There are some exceptions however. RENAME USER is not logged, while CREATE/DROP [PROCEDURE / FUNCTION / USER] are logged. |\n| QUERY_DML | Similar to QUERY, but filters only DML-type queries (DO, CALL, LOAD DATA/XML, DELETE, INSERT, SELECT, UPDATE, HANDLER , and REPLACE statements). |\n| QUERY_DML_NO_SELECT | Similar to QUERY_DML, but doesn''t log SELECT queries. |\n| QUERY_DCL | Similar to QUERY, but filters only DCL-type queries (CREATE USER, DROP USER, RENAME USER, GRANT, REVOKE and SET PASSWORD statements). |\n\nSince there are other types of queries besides DDL and DML, using the QUERY_DDL and QUERY_DML options together is not equivalent to using QUERY. There is the QUERY_DCL option for logging DCL types of queries (e.g., and GRANT`REVOKEstatements). In the same version, the server_audit_query_log_limit variable was added to be able to set the length of a log record. Previously, a log entry would be truncated due to long query strings.\n\nLogging Connect Events\n\nIf the Audit Plugin has been configured to log connect events, it will log connects, disconnects, and failed connects. For a failed connection, the log includes the error code.\n\nIt''s possible to define a list of users for which events can be excluded or included for tracing their database activities. This list will be ignored, though, for the logging of connect events. This is because auditing standards distinguish between technical and physical users. Connects need to be logged for all types of users; access to objects needs to be logged only for physical users.\n\nLogging Query Events\n\nIf QUERY, QUERY_DDL, QUERY_DML, QUERY_DML_NO_SELECT, and/or QUERY_DCL event types are enabled, then the corresponding types of queries that are executed will be logged for defined users. The queries will be logged exactly as they are executed, in plain text. This is a security vulnerability: anyone who has access to the log files will be able to read the queries. So make sure that only trusted users have access to the log files and that the files are in a protected location. An alternative is to use the⁣TABLE event type instead of the query-related event types.\n\nQueries are also logged if they cannot be executed or if they''re unsuccessful. For example, a query will be logged because of a syntax error or because the user doesn''t have the privileges necessary to access an object. These queries can be parsed by the error code that''s provided in the log.\n\nYou may find failed queries to be more interesting: They can reveal problems with applications (e.g., an SQL statement in an application that doesn''t match the current schema). They can also reveal if a malicious user is guessing at the names of tables and columns to try to get access to data.\n\nBelow is an example in which a user attempts to execute an UPDATE statement on a table for which he does not have permission:\n\n``sql\nUPDATE employees \nSET salary = salary 1.2 \nWHERE emp_id = 18236;\n\nERROR 1142 (42000): \nUPDATE command denied to user ''bob''@''localhost'' for table ''employees''\n`\n\nLooking in the Audit Plugin log (server_audit.log) for this entry, you can see the following entry:\n\n`sql\n20170817 11:07:18,ip-172-30-0-38,bob,localhost,15,46,QUERY,company,''UPDATE employees SET salary = salary 1.2 WHERE emp_id = 18236'',1142\n`\n\nThis log entry contains the date and time of the query, followed by the server host, and the user and host for the account.\n\nFrom MariaDB 12.0, in addition to the host, the audit log also contains the port, where applicable (for instance, connecting via a Unix socket doesn''t use a port).\n\nNext is the connection and query identification numbers (i.e., 15 and 46). After the log event type (i.e., QUERY), the database name (i.e., company), the query, and the error number are recorded.\n\nNotice that the last value in the log entry is 1142. That''s the error number for the query. To find failed queries, you would look for two elements: the notation indicating that it''s an entry QUERY and the last value for the entry. If the query is successful, the value will be0 .\n\nQueries Not Included in Subordinate Query Event Types\n\nNote that the QUERY event type will log queries that are not included in any of the subordinate QUERY_ event types, such as:\n\n CREATE FUNCTION\n DROP FUNCTION\n CREATE PROCEDURE\n DROP PROCEDURE\n SET\n CHANGE MASTER TO\n FLUSH\n KILL\n CHECK\n OPTIMIZE\n LOCK\n UNLOCK\n ANALYZE\n INSTALL PLUGIN\n UNINSTALL PLUGIN\n INSTALL SONAME\n UNINSTALL SONAME\n EXPLAIN\n\nLogging Table Events\n\nMariaDB has the ability to record table events in the logs—this is not a feature of MySQL. This feature is the only way to log which tables have been accessed through a view, a stored procedure, a stored function, or a trigger. Without this feature, a log entry for a query shows only the view, stored procedure or function used, not the underlying tables. Of course, you could create a custom application to parse each query executed to find the SQL statements used and the tables accessed, but that would be a drain on system resources. Table event logging is much simpler: it adds a line to the log for each table accessed, without any parsing. It includes notes as to whether it was a read or a write.\n\nIf you want to monitor user access to specific databases or tables (e.g., mysql.user), you can search the log for them. Then if you want to see a query which accessed a certain table, the audit log entry will include the query identification number. You can use it to search the same log for the query entry. This can be useful when searching a log containing tens of thousands of entries.\n\nBecause of the TABLE option, you may disable query logging and still know who accessed which tables. You might want to disable QUERY event logging to prevent sensitive data from being logged. Since _table_ event logging will log who accessed which table, you can still watch for malicious activities with the log. This is often enough to fulfill auditing requirements.\n\nBelow is an example with both TABLE and QUERY events logging. For this scenario, suppose there is a VIEW in which columns are selected from a few tables in a company database. The underlying tables are related to sensitive employee information, in particular salaries. Although we may have taken precautions to ensure that only certain user accounts have access to those tables, we will monitor the Audit Plugin logs for anyone who queries them—directly or indirectly through a view.\n\n`\n20170817 16:04:33,ip-172-30-0-38,root,localhost,29,913,READ,company,employees,\n20170817 16:04:33,ip-172-30-0-38,root,localhost,29,913,READ,company,employees_salaries,\n20170817 16:04:33,ip-172-30-0-38,root,localhost,29,913,READ,company,ref_job_titles,\n20170817 16:04:33,ip-172-30-0-38,root,localhost,29,913,READ,company,org_departments,\n20170817 16:04:33,ip-172-30-0-38,root,localhost,29,913,QUERY,company,\n''SELECT FROM employee_pay WHERE title LIKE \\''%Executive%\\'' OR title LIKE \\''%Manager%\\'''',0\n`\n\nAlthough the user executed only one SELECT statement, there are multiple entries to the log: one for each table accessed and one entry for the query on the view, (i.e., employee_pay). We know primarily this is all for one query because they all have the same connection and query identification numbers (i.e., 29 and 913).\n\nLogging User Activities\n\nThe Audit Plugin will log the database activities of all users, or only the users that you specify. A database activity is defined as a _query_ event or a _table_ event. _Connect_ events are logged for all users.\n\nYou may specify users to include in the log with the server_audit_incl_users variable or exclude users with the server_audit_excl_users variable. This can be useful if you would like to log entries, but are not interested in entries from trusted applications and would like to exclude them from the logs.\n\nYou would typically use either the server_audit_incl_users variable or the server_audit_excl_users variable. You may, though, use both variables. If a username is inadvertently listed in both variables, database activities for that user will be logged because server_audit_incl_users takes priority.\n\nAlthough MariaDB considers a user as the combination of the username and hostname, the Audit Plugin logs only based on the username. MariaDB uses both the username and hostname so as to grant privileges relevant to the location of the user. Privileges are not relevant though for tracing the access to database objects. The host name is still recorded in the log, but logging is not determined based on that information.\n\nThe following example shows how to add a new username to the server_audit_incl_users variable without removing previous usernames:\n\n`sql\nSET GLOBAL server_audit_incl_users = CONCAT(@@global.server_audit_incl_users, '',Maria'');\n`\n\nRemember to add also any new users to be included in the logs to the same variable in MariaDB configuration file. Otherwise, when the server restarts it will discard the setting.\n\nExcluding or Including Users\n\nBy default events from all users are logged, but certain users can be excluded from logging by using the server_audit_excl_users variable. For example, to exclude users _valerianus_ and _rocky_ from having their events logged:\n\n`ini\nserver_audit_excl_users=valerianus,rocky\n`\n\nThis option is primarily used to exclude the activities of trusted applications.\n\nAlternatively, server_audit_incl_users can be used to specifically include users. Both variables can be used, but if a user appears on both lists, server_audit_incl_users has a higher priority, and their activities will be logged.\n\nNote that CONNECT` events are always logged for all users, regardless of these two settings. Logging is also based on username only, not the username and hostname combination that MariaDB uses to determine privileges.\n\nURL: https://mariadb.com/docs/server/reference/plugins/mariadb-audit-plugin/mariadb-audit-plugin-log-settings', '', 'https://mariadb.com/docs/server/reference/plugins/mariadb-audit-plugin/mariadb-audit-plugin-log-settings'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (120, 5, 'Audit Plugin Options and System Variables', 'Description\n-----------\n\nThere are a several options and system variables related to the MariaDB Audit Plugin, once it has been installed. System variables can be displayed using the SHOW VARIABLES statement like so:\n\n``sql\nSHOW GLOBAL VARIABLES LIKE ''server_audit%'';\n+-------------------------------+-----------------------+\n| Variable_name | Value |\n+-------------------------------+-----------------------+\n| server_audit_events | |\n| server_audit_excl_users | |\n| server_audit_file_buffer_size | 0 |\n| ... | ... |\n| server_audit_syslog_priority | LOG_INFO |\n| server_audit_timestamp_format | %Y%m%d %H:%i:%s |\n+-------------------------------+-----------------------+\n`\n\nTo change the value of one of these variables, you can use the SET statement, or set them at the command-line when starting MariaDB. It''s recommended that you set them in the MariaDB configuration for the server like so:\n\n`ini\n[mariadb]\n...\nserver_audit_excl_users=''bob,ted''\n...\n`\n\nSystem Variables\n\nBelow is a list of all system variables related to the Audit Plugin. See Server System Variables for a complete list of system variables and instructions on setting them. See also the full list of MariaDB options, system and status variables.\n\nserver_audit_events\n\n Description: If set, this restricts audit logging to certain event types. If not set, every event type is logged to the audit log.\n Command line: --server-audit-events=value\n Scope: Global\n Dynamic: Yes\n Data type: string\n Default value: Empty string\n Valid values:\n CONNECT, QUERY, TABLE (MariaDB Audit Plugin < 1.2.0)\n CONNECT, QUERY, TABLE, QUERY_DDL, QUERY_DML (MariaDB Audit Plugin >= 1.2.0)\n CONNECT, QUERY, TABLE, QUERY_DDL, QUERY_DML, QUERY_DCL (MariaDB Audit Plugin >=1.3.0)\n CONNECT, QUERY, TABLE, QUERY_DDL, QUERY_DML, QUERY_DCL, QUERY_DML_NO_SELECT (MariaDB Audit Plugin >= 1.4.4)\n Consult MariaDB Audit Plugin - Versions for a list of MariaDB releases and their corresponding Audit Plugin versions.\n\nserver_audit_excl_users\n\n Description: If not empty, it contains the list of users whose activity will NOT be logged: SET GLOBAL server_audit_excl_users=''user_foo, user_bar''. CONNECT records aren''t affected by this variable - they are always logged. The user is still logged if it''s specified in server_audit_incl_users.\n Command line: --server-audit-excl-users=_value_\n Scope: Global\n Dynamic: Yes\n Data type: string\n Default value: Empty string\n Size limit: 1024 characters\n\nserver_audit_file_buffer_size\n\n Description: Size (in bytes) of file buffer to make logging faster. Values > 0 are adjusted in increments of 8192. (For instance, a value of 100 would be adjusted to 8192.)\n Command line: --server-audit-file-buffer-size=_#_\n Scope: Global\n Dynamic: Yes\n Data type: numeric\n Value range: 0 to 65536\n Default value: 0 (no buffering)\n Introduced: MariaDB 12.1\n Usage: See description\n\nserver_audit_file_path\n\n Description: When server_audit_output_type=file, sets the path and the filename to the log file. If the specified path exists as a directory, then the log will be created inside that directory with the name ''server_audit.log''. Otherwise the value is treated as a filename. The default value is ''server_audit.log'', which means this file will be created in the database directory.\n Command line: --server-audit-file-path=value\n Scope: Global\n Dynamic: Yes\n Data type: string\n Default value: server_audit.log\n\nserver_audit_file_rotate_now\n\n Description: When server_audit_output_type=file, the user can force the log file rotation by setting this variable to ON or 1.\n Command line: --server-audit-rotate-now[={0|1}]\n Scope: Global\n Dynamic: Yes\n Data type: boolean\n Default value: OFF\n\nserver_audit_file_rotate_size\n\n Description: When server_audit_output_type=file, it limits the size of the log file to the given amount of bytes. Reaching that limit turns on the rotation - the current log file is renamed as ''file_path.1''. The empty log file is created as ''file_path'' to log into it. The default value is 1000000.\n Command line: --server-audit-rotate-size=#\n Scope: Global\n Dynamic: Yes\n Data Type: numeric\n Default Value: 1000000\n Range: 100 to 9223372036854775807\n\nserver_audit_file_rotations\n\n Description: When server_audit_output_type=file'', this specifies the number of rotations to save. If set to 0 then the log never rotates. The default value is 9.\n Command line: --server-audit-rotations=#\n Scope: Global\n Dynamic: Yes\n Data type: numeric\n Default value: 9\n Range: 0 to 999\n\nserver_audit_incl_users\n\n Description: If not empty, it contains a comma-delimited list of users whose activity will be logged: SET GLOBAL server_audit_incl_users=''user_foo, user_bar''. CONNECT records aren''t affected by this variable - they are always logged. This setting has higher priority than server_audit_excl_users. So if the same user is specified both in incl_ and excl_ lists, they will still be logged.\n Command line: --server-audit-incl-users=value\n Scope: Global\n Dynamic: Yes\n Data type: string\n Default value: Empty string\n Size limit: 1024 characters\n\nserver_audit_loc_info\n\n Description: Used by plugin internals. It has no useful meaning to users.\n In earlier versions, users see it as a read-only variable.\n In later versions, it is hidden from the user.\n Command line: N/A\n Scope: Global\n Dynamic: No\n Data Type: string\n Default Value: Empty string\n\nserver_audit_logging\n\n Description: Enables/disables the logging. Expected values are ON/OFF: SET GLOBAL server_audit_logging=on If the server_audit_output_type is FILE, this will actually create/open the logfile so the server_audit_file_path should be properly specified beforehand. Same about the SYSLOG-related parameters. The logging is turned off by default.\n Command line: --server-audit-logging[={0|1}]\n Scope: Global\n Dynamic: Yes\n Data type: boolean\n Default value: OFF\n\nserver_audit_mode\n\n Description: This variable doesn''t have any distinctive meaning for a user. Its value mostly reflects the server version with which the plugin was started and is intended to be used by developers for testing.\n Command line: --server-audit-mode[=#]\n Scope: Global\n Dynamic: Yes\n Data type: numeric\n Default value: 0\n Range: 0 to 1\n\nserver_audit_output_type\n\n Description: Specifies the desired output type. Can be SYSLOG, FILE or null as no output: SET GLOBAL server_audit_output_type=file file: log records will be saved into the rotating log file. The name of the file set by server_audit_file_path variable. syslog: log records will be sent to the local syslogd daemon with the standard \\ API. The default value is ''file''.\n Command line: --server-audit-output-type=value\n Scope: Global\n Dynamic: Yes\n Data type: enum\n Default value: file\n Valid values: SYSLOG, FILE\n\nserver_audit_query_log_limit\n\n Description: Limit on the length of the query string in a record.\n Command line: --server-audit-query-log-limit=#\n Scope: Global\n Dynamic: Yes\n Data type: numeric\n Default value: 1024\n Range: 0 to 2147483647\n\nserver_audit_sync_log_file\n\n Description: Flushes the buffer to the log file.\\\n While log records are in the buffer, they don''t appear in the log file. To write them out from the buffer, issue this statement:\\\n SET GLOBAL server_audit_sync_log_file=1\n Command line: --server-audit-sync-log-file\n Scope: Global\n Dynamic: Yes\n Data type: N/A\n Default value: OFF\n Valid values: ON (or 1), OFF (or 0)\n Introduced: MariaDB 12.1\n Usage: See description\n\nserver_audit_syslog_facility\n\n Description: SYSLOG-mode variable. It defines the ''facility'' of the records that will be sent to the syslog. Later the log can be filtered by this parameter.\n Command line: --server-audit-syslog-facility=value\n Scope: Global\n Dynamic: Yes\n Data type: enum\n Default value: LOG_USER\n Valid values: LOG_USER, LOG_MAIL, LOG_DAEMON, LOG_AUTH, LOG_SYSLOG, LOG_LPR, LOG_NEWS, LOG_UUCP, LOG_CRON, LOG_AUTHPRIV, LOG_FTP, and LOG_LOCAL0–LOG_LOCAL7.\n\nserver_audit_syslog_ident\n\n Description: SYSLOG-mode variable. String value for the ''ident'' part of each syslog record. Default value is ''mysql-server_auditing''. New value becomes effective only after restarting the logging.\n Command line: --server-audit-syslog-ident=value\n Scope: Global\n Dynamic: Yes\n Data type: string\n Default value: mysql-server_auditing\n\nserver_audit_syslog_info\n\n Description: SYSLOG-mode variable. The ''info'' string to be added to the syslog records. Can be changed any time.\n Command line: --server-audit-syslog-info=value\n Scope: Global\n Dynamic: Yes\n Data type: string\n Default value: Empty string\n\nserver_audit_syslog_priority\n\n Description: SYSLOG-mode variable. Defines the priority of the log records for the syslogd.\n Command line: --server-audit-syslog-priority=value\n Scope: Global\n Dynamic: Yes\n Data type: enum\n Default value: LOG_INFO\n Valid values:LOG_EMERG, LOG_ALERT, LOG_CRIT, LOG_ERR, LOG_WARNING, LOG_NOTICE, LOG_INFO, LOG_DEBUG\n\nserver_audit_timestamp_format\n\n Description: A format string used to print the timestamp into the audit log messages. The format used is the same as DATE_FORMAT.\n Command line: --server-audit-timestamp-format=value\n Scope: Global\n Dynamic: Yes\n Data type: string\n Default value: %Y%m%d %H:%i:%s\n\nNotes on System Variables\n\naudit_file_buffer_size and server_audit_sync_log_file\n\nThe server audit plugin typically employs synchronous, per-event logging, causing performance bottlenecks. Individual file writes for each log entry can result in significant I/O overhead, especially in large database environments. As of MariaDB 12.1, two new variables were introduced to allow asynchronous logging, and more fine grained control over how audit log writes are handled. Using the server_audit_file_buffer_size setting (buffer size in bytes), you can configure an additional in-memory audit log buffer. When the size of the buffer exceeds the server_audit_file_buffer_size setting, the audit log is written to disk. Additionally, a manual on-demand audit log disk sync can be triggered by setting server_audit_sync_log_file to ON or 1.\n\nOptions\n\nserver_audit\n\n Description: Controls how the server should treat the plugin when the server starts up.\n Valid values are:\n OFF - Disables the plugin without removing it from the mysql.plugins table.\n ON - Enables the plugin. If the plugin cannot be initialized, then the server will still continue starting up, but the plugin will be disabled.\n FORCE - Enables the plugin. If the plugin cannot be initialized, then the server will fail to start with an error.\n FORCE_PLUS_PERMANENT - Enables the plugin. If the plugin cannot be initialized, then the server will fail to start with an error. In addition, the plugin cannot be uninstalled with UNINSTALL SONAME or UNINSTALL PLUGIN while the server is running.\n See MariaDB Audit Plugin - Installation: Prohibiting Uninstallation for more information.\n See Plugin Overview: Configuring Plugin Activation at Server Startup for more information.\n Command line: --server-audit=val\n Data Type: enumerated\n Default Value: ON\n* Valid Values: OFF, ON, FORCE, FORCE_PLUS_PERMANENT`\n\nURL: https://mariadb.com/docs/server/reference/plugins/mariadb-audit-plugin/mariadb-audit-plugin-options-and-system-variables', '', 'https://mariadb.com/docs/server/reference/plugins/mariadb-audit-plugin/mariadb-audit-plugin-options-and-system-variables'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (121, 5, 'Audit Plugin Overview', 'Description\n-----------\n\nMariaDB and MySQL are used in a broad range of environments, but if you needed to record user access to be in compliance with auditing regulations for your organization, you would previously have had to use other database solutions. To meet this need, though, MariaDB has developed the MariaDB Audit Plugin. Although the MariaDB Audit Plugin has some unique features available only for MariaDB, it can be used also with MySQL.\n\nBasically, the purpose of the MariaDB Audit Plugin is to log the server''s activity. For each client session, it records who connected to the server (i.e., user name and host), what queries were executed, and which tables were accessed and server variables that were changed. This information is stored in a rotating log file or it may be sent to the local syslogd.\n\nReview these pages for detailed documentation:\n\n Installation\n Configuration\n Log Settings\n Log Location & Rotation\n Log Format\n Status Variables\n System Variables\n\nTutorials\n\n Activating MariaDB Audit Log\\\n by Jaykishan Mutkawoa, May 30, 2016\n Installing MariaDB Audit Plugin on Amazon RDS\\\n Amazon RDS supports using the MariaDB Audit Plugin on MySQL and MariaDB database instances.\n\nBlog Posts\n\n MySQL Auditing with MariaDB Auditing Plugin\\\n by Peter Zaitsev, February 15, 2016\n\nURL: https://mariadb.com/docs/server/reference/plugins/mariadb-audit-plugin/mariadb-audit-plugin-overview', '', 'https://mariadb.com/docs/server/reference/plugins/mariadb-audit-plugin/mariadb-audit-plugin-overview'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (122, 5, 'Audit Plugin Status Variables', 'Description\n-----------\n\nThere are a few status variables related to the MariaDB Audit Plugin, once it has been installed. These variables can be displayed using the SHOW STATUS statement like so:\n\n``sql\nSHOW STATUS LIKE ''server_audit%'';\n\n+----------------------------+------------------+\n| Variable_name | Value |\n+----------------------------+------------------+\n| Server_audit_active | ON |\n| Server_audit_current_log | server_audit.log |\n| Server_audit_last_error | |\n| Server_audit_writes_failed | 0 |\n+----------------------------+------------------+\n`\n\nStatus Variables\n\nBelow is a list of all status variables related to the Audit Plugin. These cannot be set: These are not to be confused with system variables, which can be set. See Server Status Variables for a complete list of status variables that can be viewed with the SHOW STATUS statement. See also the Full list of MariaDB options, system and status variables.\n\nServer_audit_active\n\n Description: If the auditing is actually working. It gets the ON value when the logging is successfully started. Then it can get the OFF value if the logging was stopped or log records can''t be properly stored due to file or syslog errors.\n Data Type: boolean\n\nServer_audit_current_log\n\n Description: The name of the logfile or the SYSLOG parameters that are in current use.\n Data Type: string\n\nServer_audit_last_error\n\n Description: If something went wrong with the logging here you can see the message.\n Data Type: string\n\nServer_audit_writes_failed\n\n Description: The number of log records since last logging-start that weren''t properly stored because of errors of any kind. The global value can be flushed by FLUSH STATUS.\n Data Type: numeric\n* Default Value: 0`\n\nURL: https://mariadb.com/docs/server/reference/plugins/mariadb-audit-plugin/mariadb-audit-plugin-status-variables', '', 'https://mariadb.com/docs/server/reference/plugins/mariadb-audit-plugin/mariadb-audit-plugin-status-variables'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (123, 5, 'Audit Plugin Versions', 'Description\n-----------\n\nBelow is a list of the releases of the MariaDB Audit Plugin, the most recent version first, and in which versions of MariaDB each plugin version was included.\n\n| MariaDB Community Audit Plugin Version | Introduced in MariaDB Community Server |\n| ------------------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| 1.5.0 | MariaDB 12.0.1 |\n| 1.4.14 | MariaDB 10.3.35, MariaDB 10.4.25, MariaDB 10.5.16, MariaDB 10.6.8, MariaDB 10.7.4 |\n| 1.4.13 | MariaDB 10.2.38, MariaDB 10.3.29, MariaDB 10.4.19, MariaDB 10.5.10 |\n| 1.4.10 | MariaDB 10.2.35, MariaDB 10.3.26, MariaDB 10.5.7 |\n| 1.4.7 | MariaDB 10.1.41, MariaDB 10.2.26, MariaDB 10.3.17, MariaDB 10.4.7 |\n| 1.4.5 | MariaDB 10.2.24, MariaDB 10.3.15, MariaDB 10.4.5 |\n| 1.4.4 | MariaDB 5.5.61, MariaDB 10.0.36, MariaDB 10.1.34, MariaDB 10.2.15, MariaDB 10.3.7, MariaDB 10.4.0 |\n| 1.4.0 | MariaDB 5.5.48, MariaDB 10.0.24, MariaDB 10.1.11 |\n| 1.3.0 | MariaDB 5.5.43, MariaDB 10.0.18, MariaDB 10.1.5 |\n| 1.2.0 | MariaDB 5.5.42, MariaDB 10.0.17, MariaDB 10.1.4 |\n| 1.1.7 | MariaDB 5.5.38, MariaDB 10.0.11, MariaDB 10.1.0 |\n| 1.1.6 | MariaDB 5.5.37, MariaDB 10.0.10 |\n| 1.1.5 | MariaDB 10.0.09 |\n| 1.1.4 | MariaDB 5.5.36 |\n| 1.1.3 | MariaDB 5.5.34, MariaDB 10.0.7 |\n\nURL: https://mariadb.com/docs/server/reference/plugins/mariadb-audit-plugin/mariadb-audit-plugin-versions', '', 'https://mariadb.com/docs/server/reference/plugins/mariadb-audit-plugin/mariadb-audit-plugin-versions'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (124, 5, 'MariaDB Enterprise Audit', 'Description\n-----------\n\nWhile application design specifications and database configurations may intend specific limitations to be placed around access to data, audit mechanisms help confirm the effectiveness of these controls.\n\nMariaDB Enterprise Audit is a plugin that logs data access and database operations.\n\nAudit mechanisms are most effective when they produce a manageable quantity of output. MariaDB Enterprise Audit includes advanced filtering features to enable narrowly defining which information is logged.\n\nWhere audit mechanisms may only be effective when control parameters can also be audited, MariaDB Enterprise Audit implements logging of configuration changes.\n\nPlugin Conflict (MENT-316)\n\nThe MariaDB Enterprise Audit plugin (server_audit2.so) is incompatible with the older server_audit.so (v1) plugin. Running both can cause server instability or deadlocks.\n\n_If you are a new user: You can continue reading._\n\n_If you are migrating: You must remove the old v1 plugin. Please go directly to the_ _Upgrades_ _section for complete instructions._\n\nConfiguration Overview\n\nMariaDB Enterprise Audit is installed and loaded by default. If you are unsure whether it is loaded on your system, you can confirm that the plugin is loaded.\n\nTo use MariaDB Enterprise Audit, the plugin must be configured: Administrators must define Audit Filters to configure what MariaDB Enterprise Audit writes to the audit log.\n\nMariaDB Enterprise Audit supports two types of Audit Filters:\n\n| Audit Filter Type | Used For |\n| ------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------ |\n| Default Audit Filter | The Default Audit Filter is used for any user account that is not assigned a Named Audit Filter. |\n| Named Audit Filters | Named Audit Filters are assigned to specific user accounts. |\n\nAdministrators can define Audit Filters to audit log activity using multiple types of filters:\n\n| Filter Type | Used For |\n| ------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |\n| Event Filters | Event Filters are used to enable or disable audit logging for specific types of operations performed by the user accounts assigned to the Audit Filter. |\n| Logging Filters | Logging Filters are used to enable or disable audit logging for the user accounts assigned to the Audit Filter. |\n| Object Filters | Object Filters are used to enable or disable audit logging for specific databases or tables accessed by the user accounts assigned to the Audit Filter. Support for Object Filters was added in MariaDB Enterprise Server 10.6. Support for Object Filters was backported to ES 10.4.21-13 and ES 10.5.12-8. |\n\nAdministrators must start audit logging.\n\nGeneral Operation\n\nMariaDB Enterprise Audit performs audit logging during typical operations of MariaDB Enterprise Server:\n\n When a user connects, fails to connect, or disconnects, MariaDB Enterprise Audit will write a message to the audit log if the Audit Filter specifies the specific type of Connect Event.\n When a user executes a query, MariaDB Enterprise Audit will write a message to the audit log if the Audit Filter specifies the specific type of Query Event and if the queried objects are not excluded by Object Filters.\n When a query accesses a table, MariaDB Enterprise Audit will write a message to the audit log if the Audit Filter specifies the specific type of Table Event and if the table is not excluded by Object Filters.\n When a query modifies the MariaDB Enterprise Audit configuration, MariaDB Enterprise Audit will write a message to the audit log if the Audit Filter specifies the Audit Config Event.\n When a user''s Audit Filter contains a Logging Filter that disables audit logging, all audit logging for the user''s activity will be skipped.\n\nMariaDB Enterprise Audit writes audit log messages either to a dedicated audit log file or to the system log (syslog), depending on configuration.\n\nAudit log messages that correspond to a query are logged when the query completes. If a query is executed in a transaction, the audit log messages that correspond to the query are logged when the individual query completes, not when the transaction completes. If the query fails, the audit log message is logged at time of failure.\n\nAudit Log Considerations\n\nCare must be taken when logging data for audit to maintain alignment to business requirements. Concerns include:\n\n Queries should not be logged for tables containing Personally Identifiable Information (PII) or Sensitive PII (SPII) such as passwords, since audit log data is written unencrypted. Consider using Object Filters to exclude sensitive information from the audit log.\n Backup of audit data should be performed at least as frequently as database backups.\n Audit log data on database servers could be tampered with if the database server is compromised. Consider secure transmission of log data to a hardened and remote logging server.\n Where audit data is mission-critical, it should be subject to controls, data protection, data retention, and highly-available storage as are used for other mission-critical data.\n\nInstall the Audit Plugin\n\nMariaDB Enterprise Audit comes preinstalled with MariaDB Enterprise Server, so no manual installation is required.\n\nTo verify that the plugin is installed:\n\n1. Locate your server’s plugin directory.\n When MariaDB Enterprise Server is running, you can find the directory by checking the value of the plugin_dir system variable.\n\n``sql\nSHOW GLOBAL VARIABLES\n LIKE ''plugin_dir'';\n`\n\n`sql\n+---------------+--------------------------+\n| Variable_name | Value |\n+---------------+--------------------------+\n| plugin_dir | /usr/lib64/mysql/plugin/ |\n+---------------+--------------------------+\n`\n\n2. Verify the server_audit2.so file—the shared library used by MariaDB Enterprise Audit—is present in your server’s plugin directory.\n\n`bash\n$ ls -l /usr/lib64/mysql/plugin/server_audit2.so\n`\n\n`bash\n-rwxr-xr-x. 1 root root 70432 Jul 15 19:03 /usr/lib64/mysql/plugin/server_audit2.so\n`\n\nMariaDB Enterprise Audit is bundled with all MariaDB Enterprise Server distributions (binary tarball, DEB/RPM package tarball, and DEB/RPM packages). If you do not see the server_audit2.so file, verify that MariaDB Enterprise Server has been installed correctly.\n\nLoad the Audit Plugin\n\nMariaDB Enterprise Audit is enabled through the mariadb-enterprise.cnf configuration file, which is included by default with MariaDB Enterprise Server. This means manual loading is usually not required.\n\nThe mariadb-enterprise.cnf file activates MariaDB Enterprise Audit by configuring the plugin-load-add and server-audit options.\n\n`ini\n-- Auditing - pre-load Plugin\nplugin-load-add=server_audit\nserver_audit=FORCE_PLUS_PERMANENT\n`\n\nIf your environment does not use mariadb-enterprise.cnf, you can enable MariaDB Enterprise Audit by adding the same options to your own configuration file.\n\nConfirm the Audit Plugin is Loaded\n\nTo verify that MariaDB Enterprise Audit is installed, check the information_schema.PLUGINS table.\n\n`sql\nSELECT PLUGIN_STATUS, PLUGIN_LIBRARY, PLUGIN_DESCRIPTION, LOAD_OPTION\nFROM information_schema.PLUGINS\nWHERE PLUGIN_NAME=''SERVER_AUDIT''\\G\n`\n\n`sql\n************************ 1. row ***********************\n PLUGIN_STATUS: ACTIVE\n PLUGIN_LIBRARY: server_audit2.so\nPLUGIN_DESCRIPTION: MariaDB Enterprise Audit\n LOAD_OPTION: FORCE_PLUS_PERMANENT\n`\n\nMariaDB Enterprise Audit is enabled through the mariadb-enterprise.cnf configuration file, which is included by default in MariaDB Enterprise Server. If your results differ from the example output above, verify that the mariadb-enterprise.cnf file specifies the plugin-load-add and server-audit options.\n\nStart Audit Logging\n\nWhen MariaDB Enterprise Audit is installed and loaded, audit logging does not begin automatically. You must explicitly start it, either from the shell or through SQL.\n\n
InterfaceMethodBenefits
ShellConfiguration FileSQL access is not required SUPER privilege is not required Configuration file can be version controlled.
SQLSET GLOBAL StatementServer restart is not required.
\n\nStart Audit Logging in Configuration File\n\nEnable audit logging with MariaDB Enterprise Audit by setting the server_audit_logging system variable in a configuration file. Alternatively, enable it dynamically with SET GLOBAL, which does not require a server restart.\n\nTo configure in a file:\n\n1\\. Set the server_audit_logging system variable in the configuration file.\n\n`ini\n[mariadb]\nserver_audit_logging = ON\n`\n\n2. Restart MariaDB Enterprise Server:\n\n`bash\n$ sudo systemctl restart mariadb\n`\n\nIf the server does not start, review the error log for details.\n\n3. To confirm that audit logging is running, check the value of the Server_audit_active status variable using the SHOW GLOBAL STATUS statement.\n\n`sql\nSHOW GLOBAL STATUS\n LIKE ''Server_audit_active'';\n`\n\n`sql\n+---------------------+-------+\n| Variable_name | Value |\n+---------------------+-------+\n| Server_audit_active | ON |\n+---------------------+-------+\n`\n\nStart Audit Logging with SET GLOBAL\n\nAudit logging with MariaDB Enterprise Audit can be started by setting the server_audit_logging system variable with the SET GLOBAL statement, which requires the SUPER privilege.\n\n1. Set the server_audit_logging system variable with the SET GLOBAL statement:\n\n`sql\nSET GLOBAL server_audit_logging=ON;\n`\n\n2. Confirm that audit logging is started by querying the Server_audit_active status variable with the SHOW GLOBAL STATUS statement:\n\n`sql\nSHOW GLOBAL STATUS\n LIKE ''Server_audit_active'';\n`\n\n`sql\n+---------------------+-------+\n| Variable_name | Value |\n+---------------------+-------+\n| Server_audit_active | ON |\n+---------------------+-------+\n`\n\nWhen you modify a system variable dynamically using the SET GLOBAL statement, the change is not preserved after a server restart. To ensure audit logging automatically starts with the server, also configure the server_audit_logging system variable in a configuration file.\n\n`ini\n[mariadb]\nserver_audit_logging = ON\n`\n\nConfirm Audit Logging is Started\n\nConfirm that audit logging is started by querying the Server_audit_active status variable with the SHOW GLOBAL STATUS statement:\n\n`sql\nSHOW GLOBAL STATUS\n LIKE ''Server_audit_active'';\n`\n\n`sql\n+---------------------+-------+\n| Variable_name | Value |\n+---------------------+-------+\n| Server_audit_active | ON |\n+---------------------+-------+\n`\n\nAudit Logging Buffer Writes\n\nBuffer writes are available from MariaDB Enterprise Server 11.8.\n\nAudit log buffering is controlled by these variables:\n\n server_audit_file_buffer_size — This defines the size of the buffer. The default value is 0, meaning there''s no buffering at all. Setting non-zero value enables the buffering with the buffer of the specified size aligned by 8192. The maximum value is 65536.\n server_audit_sync_log_file — This flushes the buffer to the log file. While the log record is in the buffer, it cannot be seen in the log file. If there aren''t many events to log, the time before records can be observed can be significant. You can issue this statement to force writing the buffer to the file, making sure not to miss recent records:\n\n`sql\nSET GLOBAL server_audit_log_file=1\n`\n\nForbid Uninstallation\n\nIn a secure environment, MariaDB Enterprise Audit provides administrators with an audit trail of actions performed by users on the MariaDB Enterprise Server node. To protect the integrity of the audit trail, users should not be able to uninstall MariaDB Enterprise Audit. If the server-audit option is set to FORCE_PLUS_PERMANENT, MariaDB Enterprise Server will prevent MariaDB Enterprise Audit from being uninstalled:\n\n`ini\nserver_audit=FORCE_PLUS_PERMANENT\n`\n\nWhen a user tries to uninstall MariaDB Enterprise Audit with the server-audit option set to FORCE_PLUS_PERMANENT, the operation fails with the ER_PLUGIN_IS_PERMANENT error code:\n\n`sql\nUNINSTALL SONAME ''server_audit2'';\n`\n\n`sql\nERROR 1702 (HY000): Plugin ''SERVER_AUDIT'' is force_plus_permanent and can not be unloaded\n`\n\nThe mariadb-enterprise.cnf configuration file included by default in MariaDB Enterprise Server sets the server-audit option to FORCE_PLUS_PERMANENT. As a consequence, MariaDB Enterprise Server forbids MariaDB Enterprise Audit from being uninstalled by default.\n\nIf you do not use mariadb-enterprise.cnf in your environment, you can configure MariaDB Enterprise Audit to forbid uninstallation by setting the server-audit option in your configuration file.\n\nConfirm that Uninstallation is Forbidden\n\nTo confirm that MariaDB Enterprise Audit is configured to forbid uninstallation, query the information_schema.PLUGINS table:\n\n`sql\nSELECT PLUGIN_STATUS, PLUGIN_LIBRARY, PLUGIN_DESCRIPTION, LOAD_OPTION\nFROM information_schema.PLUGINS\nWHERE PLUGIN_NAME=''SERVER_AUDIT''\\G\n`\n\n`sql\n*********************** 1. row ***********************\n PLUGIN_STATUS: ACTIVE\n PLUGIN_LIBRARY: server_audit2.so\nPLUGIN_DESCRIPTION: MariaDB Enterprise Audit\n LOAD_OPTION: FORCE_PLUS_PERMANENT\n`\n\nIf your output does not match the example output shown above, confirm that the mariadb-enterprise.cnf configuration file sets the server-audit option to FORCE_PLUS_PERMANENT.\n\nServer Startup Behavior\n\nSome specific server startup behavior is described in the sections below.\n\nFor examples of error messages that can appear in the MariaDB error log during server startup, see Messages\n\n[Truncated — full content at mariadb.com/docs]', '', 'https://mariadb.com/docs/server/reference/plugins/mariadb-enterprise-audit'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (125, 5, 'WSREP\\_INFO Plugin', 'Description\n-----------\n\nThe WSREP_INFO plugin library contains the following plugins:\n\n WSREP_MEMBERSHIP\n WSREP_STATUS\n\nThe WSREP_MEMBERSHIP plugin creates the WSREP_MEMBERSHIP table in the INFORMATION_SCHEMA database. The plugin also adds the SHOW WSREP_MEMBERSHIP statement.\n\nThe WSREP_STATUS plugin creates the WSREP_STATUS table in the INFORMATION_SCHEMA database. The plugin also adds the SHOW WSREP_STATUS statement.\n\nThese tables and statements provide information about Galera. Only users with the SUPER privilege can access this information.\n\nInstalling the Plugin\n\niAlthough the plugin''s shared library is distributed with MariaDB by default, the plugin is not actually installed by MariaDB by default. There are two methods that can be used to install the plugin with MariaDB.\n\nThe first method can be used to install the plugin without restarting the server. You can install the plugin dynamically by executing INSTALL SONAME or INSTALL PLUGIN:\n\n``sql\nINSTALL SONAME ''wsrep_info'';\n`\n\nThe second method can be used to tell the server to load the plugin when it starts up. The plugin can be installed this way by providing the --plugin-load or the --plugin-load-add options. This can be specified as a command-line argument to mysqld or it can be specified in a relevant server option group in an option file:\n\n`ini\n[mariadb]\n...\nplugin_load_add = wsrep_info\n`\n\nUninstalling the Plugin\n\nYou can uninstall the plugin dynamically by executing UNINSTALL SONAME or UNINSTALL PLUGIN:\n\n`sql\nUNINSTALL SONAME ''wsrep_info'';\n``\n\nIf you installed the plugin by providing the --plugin-load or the --plugin-load-add options in a relevant server option group in an option file, then those options should be removed to prevent the plugin from being loaded the next time the server is restarted.\n\nExamples\n--------\n\nSHOW TABLES FROM information_schema LIKE ''WSREP%'';\n+---------------------------------------+\n| Tables_in_information_schema (WSREP%) |\n+---------------------------------------+\n| WSREP_STATUS |\n| WSREP_MEMBERSHIP |\n+---------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/plugins/mariadb-replication-cluster-plugins/wsrep_info-plugin', '', 'https://mariadb.com/docs/server/reference/plugins/mariadb-replication-cluster-plugins/wsrep_info-plugin'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (126, 5, 'wsrep\\_provider', 'Description\n-----------\n\nThis plugin is for Galera Cluster. It splits up the wsrep_provider_options setting into individual configuration variables.\n\nThe plugin is available from MariaDB 11.4, and built in to the server, but not enabled by default.\n\nWithout that plugin, options are grouped together, like this:\n\n``ini\nwsrep_provider_options="base_dir = /var/lib/mysql/; base_host = node-1;..."\n`\n\nWith this plugin loaded, you can configure individual variables, like this:\n\n`ini\nwsrep_provider_base_dir = /var/lib/mysql/\nwsrep_provider_base_host = node-1\n...\n`\n\nThis makes managing provider options easier, and helps avoid the problem of wsrep_provider_options exceeding the maximum length of 2048 characters for an individual variable.\n\nTo enable the plugin, add the following line to the [mariadbd], [server], or [galera] sections of your server option file:\n\n`ini\nplugin-wsrep-provider=ON\n`\n\nAlternatively, start the server with the --plugin-wsrep-provider` option.\n\nSee the wsrep_provider_options page for what you can configure for Galera Cluster.\n\nFor plugin version and maturity level, see this page.\n\nURL: https://mariadb.com/docs/server/reference/plugins/mariadb-replication-cluster-plugins/wsrep_provider', '', 'https://mariadb.com/docs/server/reference/plugins/mariadb-replication-cluster-plugins/wsrep_provider'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (127, 5, 'Disks Plugin', 'Description\n-----------\n\nThe DISKS plugin creates the DISKS table in the INFORMATION_SCHEMA database. This table shows metadata about disks on the system, enabling monitoring of the disk space status. Accessing the INFORMATION_SCHEMA.DISKS table requires the FILE privilege.\n\nThe plugin is supported on Linux systems only.\n\nInstalling the Plugin\n\nAlthough the plugin''s shared library is distributed with MariaDB by default, the plugin is not actually installed by MariaDB automatically. There are two methods that can be used to install the plugin with MariaDB.\n\nThe first method can be used to install the plugin without restarting the server. You can install the plugin dynamically by executing INSTALL SONAME or INSTALL PLUGIN:\n\n``sql\nINSTALL SONAME ''disks'';\n`\n\nThe second method can be used to tell the server to load the plugin when it starts up. The plugin can be installed this way by providing the --plugin-load or the --plugin-load-add options. This can be provided as a command-line argument to mysqld or specified in a relevant server option group in an option file:\n\n`ini\n[mariadb]\n...\nplugin_load_add = disks\n``\n\nExamples\n--------\n\n +-----------+-----------------------+-----------+----------+-----------+\n | Disk | Path | Total | Used | Available |\n +-----------+-----------------------+-----------+----------+-----------+\n | /dev/sda3 | / | 47929956 | 30666304 | 14805864 |\n | /dev/sda1 | /boot/efi | 191551 | 3461 | 188090 |\n | /dev/sda4 | /home | 174679768 | 80335392 | 85448120 |\n | /dev/sdb1 | /mnt/hdd | 961301832 | 83764 | 912363644 |\n | /dev/sdb1 | /home/wikman/Music | 961301832 | 83764 | 912363644 |\n | /dev/sdb1 | /home/wikman/Videos | 961301832 | 83764 | 912363644 |\n | /dev/sdb1 | /home/wikman/hdd | 961301832 | 83764 | 912363644 |\n | /dev/sdb1 | /home/wikman/Pictures | 961301832 | 83764 | 912363644 |\n | /dev/sda3 | /var/lib/docker/aufs | 47929956 | 30666304 | 14805864 |\n +-----------+-----------------------+-----------+----------+-----------+\n 9 rows in set (0.00 sec)\n\nURL: https://mariadb.com/docs/server/reference/plugins/other-plugins/disks-plugin', '', 'https://mariadb.com/docs/server/reference/plugins/other-plugins/disks-plugin'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (128, 5, 'Feedback Plugin', 'Description\n-----------\n\nThe feedback plugin is designed to collect and, optionally, upload\\\nconfiguration and usage information to MariaDB.org or to any other configured URL.\n\nSee the MariaDB User Feedback page on MariaDB.org to see collected MariaDB usage statistics.\n\nMariaDB is usually distributed with this plugin included, but it is not enabled by default.\\\nOn Windows, this plugin is part of the server and has a special checkbox in the installer window. Either way, you need to explicitly install and enable it in order for feedback data to be sent.\n\nVerifying the Plugin''s Status\n\nTo verify whether the feedback plugin is installed and enabled, execute the SHOW PLUGINS statement or query the information_schema.plugins table:\n\n``sql\nSELECT plugin_status FROM information_schema.plugins \n WHERE plugin_name = ''feedback'';\n+---------------+\n| plugin_status |\n+---------------+\n| DISABLED |\n+---------------+\n`\n\nIf that SELECT returns no rows, then you still need to install the plugin.\n\nWhen the plugin is installed and enabled, you will see:\n\n`sql\nSELECT plugin_status FROM information_schema.plugins \n WHERE plugin_name = ''feedback'';\n+---------------+\n| plugin_status |\n+---------------+\n| ACTIVE |\n+---------------+\n`\n\nInstalling the Plugin\n\nIn some releases, the plugin''s shared library is distributed with MariaDB by default, but the plugin is not actually installed by MariaDB. There are two methods that can be used to install the plugin with MariaDB.\n\nThe first method can be used to install the plugin without restarting the server. You can install the plugin dynamically by executing INSTALL SONAME or INSTALL PLUGIN:\n\n`\nINSTALL SONAME ''feedback'';\n`\n\nThe second method can be used to tell the server to load the plugin when it starts up. The plugin can be installed this way by providing the --plugin-load or the --plugin-load-add options. This can be specified as a command-line argument to mariadbd, or it can be specified in a relevant server option group in an option file:\n\n`ini\n[mariadb]\n...\nplugin_load_add = feedback\n`\n\nUninstalling the Plugin\n\nYou can uninstall the plugin dynamically by executing UNINSTALL SONAME or UNINSTALL PLUGIN:\n\n`sql\nUNINSTALL SONAME ''feedback'';\n`\n\nIf you installed the plugin by providing the --plugin-load or the --plugin-load-add options in a relevant server option group in an option file, then those options should be removed to prevent the plugin from being loaded the next time the server is restarted.\n\nEnabling the Plugin\n\nYou can enable the plugin by setting the feedback option to ON in a relevant server option group in an option file:\n\n`ini\n[mariadb]\n...\nfeedback=ON\n`\n\nIn Windows, the plugin can also be enabled during a new MSI installation. The MSI GUI installation provides the "Enable feedback plugin" checkbox to enable the plugin. The MSI command-line installation provides the FEEDBACK=1 command-line option to enable the plugin.\n\nSee the next section for how to verify the plugin is installed and active and (if needed) install the plugin.\n\nCollecting Data\n\nThe feedback plugin collects the following data:\n\n Certain rows from SHOW STATUS and SHOW VARIABLES.\n All installed plugins and their versions.\n System information such as CPU count, memory, architecture, and OS/linux distribution.\n The feedback_server_uid, which is a SHA1 hash of the MAC address of the first network interface and the TCP port that the server listens on.\n\nThe feedback plugin creates the FEEDBACK table in the INFORMATION_SCHEMA database. To see the data that has been collected by the plugin, you can execute:\n\n`sql\nSELECT FROM information_schema.feedback;\n`\n\nOnly the contents of this table are sent to the feedback_url.\n\nMariaDB stores collation usage statistics. Each collation that has been used by the server\\\nwill have a record in output of SELECT FROM information_schema.feedback , for example:\n\n`\n+----------------------------------------+---------------------+\n| VARIABLE_NAME | VARIABLE_VALUE |\n+----------------------------------------+---------------------+\n| Collation used utf8_unicode_ci | 10 |\n| Collation used latin1_general_ci | 20 |\n+----------------------------------------+---------------------+\n`\n\nCollations that have not been used will not be included in the result.\n\nSending Data\n\nThe feedback plugin sends the data using a POST request to any URL or a list of URLs\\\nthat you specify by setting the feedback_url system variable. By default, this is set to the following URL:\n\n https://feedback.mariadb.org/rest/v1/post\n\nBoth HTTP and HTTPS protocols are supported.\n\nIf HTTP traffic requires a proxy in your environment, then you can specify the proxy by setting the feedback_http_proxy system variable.\n\nIf the feedback_url system variable is not set to an empty string, then the\\\nplugin will automatically send a report to all URLs in the list a few minutes after the server starts up and then once a week after that.\n\nIf the feedback_url system variable is set to an empty string, then the\\\nplugin will not automatically send any data. This may be necessary if outbound HTTP communication from your database server is not permitted. In this case, you can still upload the data manually, if you''d like.\n\nFirst, generate the report file with the MariaDB command-line mariadb client:\n\n`bash\n$ mariadb -e ''select from information_schema.feedback'' > report.txt\n`\n\nThen, you can upload the generated report.txt here from the command line with tools such as curl:\n\n`bash\n$ curl -F data=@report.txt https://feedback.mariadb.org/rest/v1/post\n`\n\nManual uploading allows you to be absolutely sure that we receive only the data shown in the INFORMATION_SCHEMA.FEEDBACK table and that no private or sensitive information is being sent.\n\nSystem Variables\n\nfeedback_http_proxy\n\n Description: Proxy server for use when http calls cannot be made, such as in a firewall environment. The format is host:port.\n Command line: --feedback-http=proxy=value\n Read-only: Yes\n Data Type: string\n Default Value: '''' (empty)\n\nfeedback_send_retry_wait\n\n Description: Time in seconds before retrying if the plugin failed to send the data for any reason.\n Command line: --feedback-send-retry-wait=#\n Scope: Global\n Dynamic: Yes\n Data Type: numeric\n Default Value: 60\n Valid Values: 1 to 86400\n\nfeedback_send_timeout\n\n Description: An attempt to send the data times out and fails after this many seconds.\n Command line: --feedback-send-timeout=#\n Scope: Global\n Dynamic: Yes\n Data Type: numeric\n Default Value: 60\n Valid Values: 1 to 86400\n\nfeedback_server_uid\n\n Description: Automatically calculated server unique id hash.\n Scope: Global\n Dynamic: No\n Data Type: string\n\nfeedback_url\n\n Description: URL to which the data is sent. More than one URL, separated by spaces, can be specified. Set it to an empty string to disable data sending.\n Command line: --feedback-url=url\n Scope: Global\n Dynamic: No\n Data Type: string\n Default Value: https://feedback.mariadb.org/rest/v1/post\n\nfeedback_user_info\n\n Description: The value of this option is not used by the plugin, but it is included in the feedback data. It can be used to add any user-specified string to the report. This could be used to help to identify it. For example, a support contract number, or a computer name (if you collect reports internally by specifying your own feedback-url).\n Command line: --feedback-user-info=string\n Scope: Global\n Dynamic: No\n Data Type: string\n Default Value: Empty string\n\nOptions\n\nfeedback\n\n Description: Controls how the server should treat the plugin when the server starts up.\n Valid values are:\n OFF - Disables the plugin without removing it from the mysql.plugins table.\n ON - Enables the plugin. If the plugin cannot be initialized, then the server will still continue starting up, but the plugin will be disabled.\n FORCE - Enables the plugin. If the plugin cannot be initialized, then the server will fail to start with an error.\n FORCE_PLUS_PERMANENT - Enables the plugin. If the plugin cannot be initialized, then the server will fail to start with an error. In addition, the plugin cannot be uninstalled with UNINSTALL SONAME or UNINSTALL PLUGIN while the server is running.\n See Plugin Overview: Configuring Plugin Activation at Server Startup for more information.\n Command line: --feedback=value\n Data Type: enumerated\n Default Value: ON\n Valid Values: OFF, ON, FORCE, FORCE_PLUS_PERMANENT`\n\nURL: https://mariadb.com/docs/server/reference/plugins/other-plugins/feedback-plugin', '', 'https://mariadb.com/docs/server/reference/plugins/other-plugins/feedback-plugin'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (129, 5, 'METADATA\\_LOCK\\_INFO Plugin', 'Description\n-----------\n\nThe METADATA_LOCK_INFO plugin creates the METADATA_LOCK_INFO table in the INFORMATION_SCHEMA database. This table shows active metadata locks. The table is empty if there are no active metadata locks.\n\nInstalling the Plugin\n\nAlthough the plugin''s shared library is distributed with MariaDB by default, the plugin is not actually installed by MariaDB by default. There are two methods that can be used to install the plugin with MariaDB.\n\nThe first method can be used to install the plugin without restarting the server. You can install the plugin dynamically by executing INSTALL SONAME or INSTALL PLUGIN:\n\n``sql\nINSTALL SONAME ''metadata_lock_info'';\n`\n\nThe second method can be used to tell the server to load the plugin when it starts up. The plugin can be installed this way by providing the --plugin-load or the --plugin-load-add options. This can be specified as a command-line argument to mysqld or it can be specified in a relevant server option group in an option file:\n\n`ini\n[mariadb]\n...\nplugin_load_add = metadata_lock_info\n`\n\nUninstalling the Plugin\n\nYou can uninstall the plugin dynamically by executing UNINSTALL SONAME or UNINSTALL PLUGIN:\n\n`sql\nUNINSTALL SONAME ''metadata_lock_info'';\n``\n\nIf you installed the plugin by providing the --plugin-load or the --plugin-load-add options in a relevant server option group in an option file, then those options should be removed to prevent the plugin from being loaded the next time the server is restarted.\n\nExamples\n--------\n\nSELECT * FROM information_schema.metadata_lock_info; \n+-----------+--------------------------+---------------+----------------------+-----------------+-------------+\n| THREAD_ID | LOCK_MODE | LOCK_DURATION | LOCK_TYPE | TABLE_SCHEMA | TABLE_NAME | \n+-----------+--------------------------+---------------+----------------------+-----------------+-------------+\n| 31 | MDL_INTENTION_EXCLUSIVE | MDL_EXPLICIT | Global read lock | | | \n| 31 | MDL_INTENTION_EXCLUSIVE | MDL_EXPLICIT | Commit lock | | |\n| 31 | MDL_INTENTION_EXCLUSIVE | MDL_EXPLICIT | Schema metadata lock | dbname | |\n| 31 | MDL_SHARED_NO_READ_WRITE | MDL_EXPLICIT | Table metadata lock | dbname | exotics |\n+-----------+--------------------------+---------------+----------------------+-----------------+-------------+\n4 rows in set (0.00 sec)\n\nURL: https://mariadb.com/docs/server/reference/plugins/other-plugins/metadata-lock-info-plugin', '', 'https://mariadb.com/docs/server/reference/plugins/other-plugins/metadata-lock-info-plugin'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (130, 5, 'mhnsw', 'Description\n-----------\n\nThis plugin is for internal use only.\n\nThis plugin implements the nhnsw vector index algorithm. It is used to create vector indexes.\n\nSee Vector Overview for the functionality, and Vector System Variables for what you can configure.\n\nIt is built in the server, and is always enabled.\n\nFor plugin version and maturity level, see this page.\n\nURL: https://mariadb.com/docs/server/reference/plugins/other-plugins/mhnsw', '', 'https://mariadb.com/docs/server/reference/plugins/other-plugins/mhnsw'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (131, 5, 'MYSQL\\_JSON', 'Description\n-----------\n\nThe TYPE_MYSQL_JSON plugin is available from MariaDB 10.5.7.\n\nThe JSON type in MySQL stores the JSON object in its own native form, while, in MariaDB, the JSON type is a LONGTEXT. Opening a table with a JSON type created in MySQL results in an error:\n\n``sql\nSELECT * FROM mysql_json_table;\nERROR 4161 (HY000): Unknown data type: ''MYSQL_JSON''\n`\n\nThe mysql_json plugin is used to make it easier to upgrade to MariaDB.\n\nInstalling\n\nInstalling can be done in a number of ways, for example:\n\n`sql\nINSTALL SONAME ''type_mysql_json'';\n``\n\nSee Making MariaDB understand MySQL JSON for a full description.\n\nURL: https://mariadb.com/docs/server/reference/plugins/other-plugins/mysql_json', '', 'https://mariadb.com/docs/server/reference/plugins/other-plugins/mysql_json'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (132, 5, 'online\\_alter\\_log', 'Description\n-----------\n\nThis plugin is for internal use only.\n\nThis plugin represents the online alter log in a transaction. It is used to commit transactions for tables while an online ALTER TABLE query is running.\n\nIt is built in the server, and is always enabled.\n\nSee the Online Schema Change page for functionality details.\n\nFor plugin version and maturity level, see this page.\n\nURL: https://mariadb.com/docs/server/reference/plugins/other-plugins/online_alter_log', '', 'https://mariadb.com/docs/server/reference/plugins/other-plugins/online_alter_log'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (133, 5, 'Query Cache Information Plugin', 'Description\n-----------\n\nThe QUERY_CACHE_INFO plugin creates the QUERY_CACHE_INFO table in the INFORMATION_SCHEMA database. This table shows all queries in the query cache. Querying this table acquires the query cache lock and will result in lock waits for queries that are using or expiring from the query cache. You must have the PROCESS privilege to query this table.\n\nInstalling the Plugin\n\nAlthough the plugin''s shared library is distributed with MariaDB by default, the plugin is not actually installed by MariaDB by default. There are two methods that can be used to install the plugin with MariaDB.\n\nThe first method can be used to install the plugin without restarting the server. You can install the plugin dynamically by executing INSTALL SONAME or INSTALL PLUGIN:\n\n``sql\nINSTALL SONAME ''query_cache_info'';\n`\n\nThe second method can be used to tell the server to load the plugin when it starts up. The plugin can be installed this way by providing the --plugin-load or the --plugin-load-add options. This can be specified as a command-line argument to mysqld or it can be specified in a relevant server option group in an option file:\n\n`ini\n[mariadb]\n...\nplugin_load_add = query_cache_info\n`\n\nUninstalling the Plugin\n\nYou can uninstall the plugin dynamically by executing UNINSTALL SONAME or UNINSTALL PLUGIN:\n\n`sql\nUNINSTALL SONAME ''query_cache_info'';\n``\n\nIf you installed the plugin by providing the --plugin-load or the --plugin-load-add options in a relevant server option group in an option file, then those options should be removed to prevent the plugin from being loaded the next time the server is restarted.\n\nExamples\n--------\n\nSELECT statement_schema, statement_text, result_blocks_count, \n result_blocks_size FROM information_schema.query_cache_info;\n+------------------+------------------+---------------------+--------------------+\n| statement_schema | statement_text | result_blocks_count | result_blocks_size |\n+------------------+------------------+---------------------+--------------------+\n| test | SELECT * FROM t1 | 1 | 512 |\n+------------------+------------------+---------------------+--------------------+\n\nURL: https://mariadb.com/docs/server/reference/plugins/other-plugins/query-cache-information-plugin', '', 'https://mariadb.com/docs/server/reference/plugins/other-plugins/query-cache-information-plugin'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (134, 5, 'Query Response Time Plugin', 'Description\n-----------\n\nThe query_response_time plugin creates the QUERY_RESPONSE_TIME table in the INFORMATION_SCHEMA database. The plugin also adds the SHOW QUERY_RESPONSE_TIME and FLUSH QUERY_RESPONSE_TIME statements.\n\nThe slow query log provides exact information about queries that take a long time to execute. However, sometimes there are a large number of queries that each take a very short amount of time to execute. This feature provides a tool for analyzing that information by counting and displaying the number of queries according to the length of time they took to execute.\n\nThis feature is based on Percona''s Response Time Distribution.\n\nInstalling the Plugin\n\nThis shared library actually consists of a number of different plugins:\n\n QUERY_RESPONSE_TIME - An INFORMATION_SCHEMA plugin that exposes statistics.\n QUERY_RESPONSE_TIME_AUDIT - audit plugin, collects statistics.\n\nBoth plugins need to be installed to get meaningful statistics.\n\nIn addition, these additional plugins are available:\n\n QUERY_RESPONSE_TIME_READ\n QUERY_RESPONSE_TIME_READ_WRITE\n QUERY_RESPONSE_TIME_WRITE\n\nThis shared library actually consists of a number of different plugins:\n\n QUERY_RESPONSE_TIME - An INFORMATION_SCHEMA plugin that exposes statistics.\n QUERY_RESPONSE_TIME_AUDIT - audit plugin, collects statistics.\n\nBoth plugins need to be installed to get meaningful statistics.\n\nAlthough the plugin''s shared library is distributed with MariaDB by default, the plugins are not actually installed by MariaDB by default. There are two methods that can be used to install the plugins with MariaDB.\n\nThe first method can be used to install the plugin library without restarting the server. You can install the plugins dynamically by executing INSTALL SONAME or INSTALL PLUGIN:\n\n``sql\nINSTALL SONAME ''query_response_time'';\n`\n\nThe second method can be used to tell the server to load the plugin library when it starts up. The plugins can be installed this way by providing the --plugin-load or the --plugin-load-add options. This can be specified as a command-line argument to mysqld or it can be specified in a relevant server option group in an option file:\n\n`ini\n[mariadb]\n...\nplugin_load_add = query_response_time\n`\n\nNote that in both cases you have to activate data collection by changing the query_response_time_stats setting to ON, it is OFF by default even when the plugin library is loaded.\n\nYou can change the setting at runtime with\n\n`sql\nSET GLOBAL query_response_time_stats=ON;\n`\n\nor in the options file after the plugin has been loaded:\n\n`ini\n[mariadb]\n...\nplugin_load_add = query_response_time\nquery_response_time_stats=ON;\n`\n\nUninstalling the Plugin\n\nYou can uninstall the plugin dynamically by executing UNINSTALL SONAME or UNINSTALL PLUGIN:\n\n`sql\nUNINSTALL SONAME ''query_response_time'';\n`\n\nIf you installed the plugin by providing the --plugin-load or the --plugin-load-add options in a relevant server option group in an option file, then those options should be removed to prevent the plugin from being loaded the next time the server is restarted.\n\nResponse Time Distribution\n\nThe user can define time intervals that divide the range 0 to positive infinity into smaller intervals and then collect the number of commands whose execution times fall into each of those intervals.\n\nEach interval is described as:\n\n`\n(range_base ^ n; range_base ^ (n+1)]\n`\n\nThe range_base is some positive number (see Limitations). The interval is defined as the difference between two nearby powers of the range base.\n\nIf the range base equals 10, we have the following intervals:\n\n`\n(0; 10 ^ -6], (10 ^ -6; 10 ^ -5], (10 ^ -5; 10 ^ -4], ..., \n (10 ^ -1; 10 ^1], (10^1; 10^2]...(10^7; positive infinity]\n`\n\nor\n\n`\n(0; 0.000001], (0.000001; 0.000010], (0.000010; 0.000100], ..., \n (0.100000; 1.0]; (1.0; 10.0]...(1000000; positive infinity]\n`\n\nFor each interval, a count is made of the queries with execution times that fell into that interval.\n\nYou can select the range of the intervals by changing the range base. For example, for base range=2 we have the following intervals:\n\n`\n(0; 2 ^ -19], (2 ^ -19; 2 ^ -18], (2 ^ -18; 2 ^ -17], ..., \n (2 ^ -1; 2 ^1], (2 ^ 1; 2 ^ 2]...(2 ^ 25; positive infinity]\n`\n\nor\n\n`\n(0; 0.000001], (0.000001, 0.000003], ..., \n (0.25; 0.5], (0.5; 2], (2; 4]...(8388608; positive infinity]\n`\n\nSmall numbers look strange (i.e., don’t look like powers of 2), because we lose precision on division when the ranges are calculated at runtime. In the resulting table, you look at the high boundary of the range:\n\n`sql\nSELECT FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME;\n+----------------+-------+----------------+\n| TIME | COUNT | TOTAL |\n+----------------+-------+----------------+\n| 0.000001 | 0 | 0.000000 |\n| 0.000010 | 17 | 0.000094 |\n| 0.000100 | 4301 0.236555 |\n| 0.001000 | 1499 | 0.824450 |\n| 0.010000 | 14851 | 81.680502 |\n| 0.100000 | 8066 | 443.635693 |\n| 1.000000 | 0 | 0.000000 |\n| 10.000000 | 0 | 0.000000 |\n| 100.000000 | 1 | 55.937094 |\n| 1000.000000 | 0 | 0.000000 |\n| 10000.000000 | 0 | 0.000000 |\n| 100000.000000 | 0 | 0.000000 |\n| 1000000.000000 | 0 | 0.000000 |\n| TOO LONG | 0 | TOO LONG |\n+----------------+-------+----------------+\n`\n\nThis means there were:\n\n`\n 17 queries with 0.000001 < query execution time < = 0.000010 seconds; total execution time of the 17 queries = 0.000094 seconds\n\n 4301 queries with 0.000010 < query execution time < = 0.000100 seconds; total execution time of the 4301 queries = 0.236555 seconds\n\n 1499 queries with 0.000100 < query execution time < = 0.001000 seconds; total execution time of the 1499 queries = 0.824450 seconds\n\n 14851 queries with 0.001000 < query execution time < = 0.010000 seconds; total execution time of the 14851 queries = 81.680502 seconds\n\n 8066 queries with 0.010000 < query execution time < = 0.100000 seconds; total execution time of the 8066 queries = 443.635693 seconds\n\n 1 query with 10.000000 < query execution time < = 100.0000 seconds; total execution time of the 1 query = 55.937094 seconds\n`\n\nUsing the Plugin\n\nUsing the Information Schema Table\n\nYou can get the distribution by querying the QUERY_RESPONSE_TIME table in the INFORMATION_SCHEMA database:\n\n`sql\nSELECT FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME;\n`\n\nYou can also write more complex queries:\n\n`sql\nSELECT c.count, c.time,\n(SELECT SUM(a.count) FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME AS a \n WHERE a.count != 0) AS query_count,\n(SELECT COUNT() FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME AS b \n WHERE b.count != 0) AS not_zero_region_count,\n(SELECT COUNT() FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME) AS region_count\nFROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME AS c \n WHERE c.count > 0;\n`\n\nNote: If query_response_time_stats is set to ON, then the execution times for these two SELECT queries will also be collected.\n\nUsing the SHOW Statement\n\nAs an alternative to the QUERY_RESPONSE_TIME table in the INFORMATION_SCHEMA database, you can also use the SHOW QUERY_RESPONSE_TIME statement:\n\n`sql\nSHOW QUERY_RESPONSE_TIME;\n`\n\nFlushing Plugin Data\n\nFlushing the plugin data does two things:\n\n Clears the collected times from the QUERY_RESPONSE_TIME table in the INFORMATION_SCHEMA database.\n Reads the value of query_response_time_range_base and uses it to set the range base for the table.\n\nPlugin data can be flushed with the FLUSH QUERY_RESPONSE_TIME statement:\n\n`sql\nFLUSH QUERY_RESPONSE_TIME;\n`\n\nSetting the query_response_time_flush system variable has the same effect:\n\n`sql\nSET GLOBAL query_response_time_flush=1;\n`\n\nIt is possible to specify flushing read and/or write statements with the FLUSH QUERY_RESPONSE_TIME_READ, FLUSH QUERY_RESPONSE_TIME_WRITE and FLUSH QUERY_RESPONSE_TIME_READ_WRITE statements.\n\nIt is not possible to specify flushing read and/or write statements with the FLUSH QUERY_RESPONSE_TIME_READ, FLUSH QUERY_RESPONSE_TIME_WRITE and FLUSH QUERY_RESPONSE_TIME_READ_WRITE statements.\n\nSystem Variables\n\nquery_response_time_flush\n\n Description: Updating this variable flushes the statistics and re-reads query_response_time_range_base.\n Command line: None\n Scope: Global\n Dynamic: Yes\n Data Type: boolean\n Default Value: OFF\n\nquery_response_time_range_base\n\n Description: Select base of log for QUERY_RESPONSE_TIME ranges. WARNING: variable change takes affect only after flush.\n Command line: --query-response-time-range-base=#\n Scope: Global\n Dynamic: Yes\n Data Type: numeric\n Default Value: 10\n Range: 2 to 1000\n\nquery_response_time_exec_time_debug\n\n Description: Pretend queries take this many microseconds. When 0 (the default) use the actual execution time.\n This system variable is only available when the plugin is a debug build.\n Scope: Global\n Dynamic: Yes\n Data Type: numeric\n Default Value: 0\n Range: 0 to 31536000\n\nquery_response_time_session_stats\n\n Description: Controls query response time statistics collection for the current session: ON - enable, OFF - disable, GLOBAL (default) - use query_response_time_stats value.\n Command line: query-response-time-session-stats=val]\n Scope: Global, Session\n Dynamic: Yes\n Data Type: enum\n Default Value: GLOBAL\n Valid Values: GLOBAL, ON, OFF\n Introduced: MariaDB 11.5\n\nquery_response_time_stats\n\n Description: Enable or disable query response time statistics collecting.\n Command line: query-response-time-stats[={0|1}]\n Scope: Global\n Dynamic: Yes\n Data Type: boolean\n Default Value: OFF\n\nOptions\n\nquery_response_time\n\n Description: Controls how the server should treat the plugin when the server starts up.\n Valid values are:\n OFF - Disables the plugin without removing it from the mysql.plugins table.\n ON - Enables the plugin. If the plugin cannot be initialized, then the server will still continue starting up, but the plugin will be disabled.\n FORCE - Enables the plugin. If the plugin cannot be initialized, then the server will fail to start with an error.\n FORCE_PLUS_PERMANENT - Enables the plugin. If the plugin cannot be initialized, then the server will fail to start with an error. In addition, the plugin cannot be uninstalled with UNINSTALL SONAME or UNINSTALL PLUGIN while the server is running.\n See Plugin Overview: Configuring Plugin Activation at Server Startup for more information.\n Command line: --query-response-time=value\n Data Type: enumerated\n Default Value: ON\n Valid Values: OFF, ON, FORCE, FORCE_PLUS_PERMANENT\n\nquery_response_time_audit\n\n Description: Controls how the server should treat the plugin when the server starts up.\n Valid values are:\n OFF - Disables the plugin without removing it from the mysql.plugins table.\n ON - Enables the plugin. If the plugin cannot be initialized, then the server will still continue starting up, but the plugin will be disabled.\n FORCE - Enables the plugin. If the plugin cannot be initialized, then the server will fail to start with an error.\n FORCE_PLUS_PERMANENT - Enables the plugin. If the plugin cannot be initialized, then the server will fail to start with an error. In addition, the plugin cannot be uninstalled with UNINSTALL SONAME or UNINSTALL PLUGIN while the server is running.\n See Plugin Overview: Configuring Plugin Activation at Server Startup for more information.\n Command line: --query-response-time-audit=value\n Data Type: enumerated\n Default Value: ON\n* Valid Values: OFF, ON, FORCE, FORCE_PLUS_PERMANENT`\n\nURL: https://mariadb.com/docs/server/reference/plugins/other-plugins/query-response-time-plugin', '', 'https://mariadb.com/docs/server/reference/plugins/other-plugins/query-response-time-plugin'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (135, 5, 'User Variables Plugin', 'Description\n-----------\n\nThe user_variables plugin creates the USER_VARIABLES table in the INFORMATION_SCHEMA database. This table contains information about user-defined variables.\n\nViewing\n\nUser-defined variables can be viewed by either querying the USER_VARIABLES, or by running SHOW USER_VARIABLES.\n\nFlushing User-Defined Variables\n\nUser-defined variables are reset and the Information Schema table emptied with the FLUSH USER_VARIABLES statement.\n\nExamples\n--------\n\nSET @v1 = 0;\nSET @v2 = ''abc'';\nSET @v3 = CAST(123 AS CHAR(5));\n\nSHOW USER_VARIABLES;\n+---------------+-------+\n| Variable_name | Value |\n+---------------+-------+\n| v3 | 123 |\n| v2 | abc |\n| v1 | 0 |\n+---------------+-------+\n\nSELECT FROM information_schema.USER_VARIABLES ORDER BY VARIABLE_NAME;\n+---------------+----------------+---------------+--------------------+\n| VARIABLE_NAME | VARIABLE_VALUE | VARIABLE_TYPE | CHARACTER_SET_NAME |\n+---------------+----------------+---------------+--------------------+\n| v1 | 0 | INT | latin1 |\n| v2 | abc | VARCHAR | utf8 |\n| v3 | 123 | VARCHAR | utf8 |\n+---------------+----------------+---------------+--------------------+\n\nFLUSH USER_VARIABLES;\n\nSELECT FROM information_schema.USER_VARIABLES ORDER BY VARIABLE_NAME;\nEmpty set (0.000 sec)\n\nURL: https://mariadb.com/docs/server/reference/plugins/other-plugins/user-variables-plugin', '', 'https://mariadb.com/docs/server/reference/plugins/other-plugins/user-variables-plugin'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (136, 5, 'Cracklib Password Check Plugin', 'Description\n-----------\n\ncracklib_password_check is a password validation plugin. It uses the CrackLib library to check the strength of new passwords. CrackLib is installed by default in many Linux distributions, since the system''s Pluggable Authentication Module (PAM) authentication framework is usually configured to check the strength of new passwords with the pam_cracklib PAM module.\n\nNote that passwords can be directly set as a hash, bypassing the password validation, if the strict_password_validation variable is OFF (it is ON by default).\n\nThe plugin requires at least cracklib 2.9.0, so it is not available on Debian/Ubuntu builds before Debian 8 Jessie/Ubuntu 14.04 Trusty, RedHat Enterprise Linux / CentOS 6.\n\nInstalling the Plugin''s Package\n\nThe cracklib_password_check plugin''s shared library is included in MariaDB packages as the cracklib_password_check.so or cracklib_password_check.dll shared library on systems where it can be built.\n\nInstalling on Linux\n\nThe cracklib_password_check plugin is included in systemd binary tarballs on Linux, but not in the older generic and glibc_214 tarballs.\n\nInstalling with a Package Manager\n\nThe cracklib_password_check plugin can also be installed via a package manager on Linux. In order to do so, your system needs to be configured to install from one of the MariaDB repositories.\n\nYou can configure your package manager to install it from MariaDB Corporation''s MariaDB Package Repository by using the MariaDB Package Repository setup script.\n\nYou can also configure your package manager to install it from MariaDB Foundation''s MariaDB Repository by using the MariaDB Repository Configuration Tool.\n\nInstalling with yum/dnf\n\nOn RHEL, CentOS, Fedora, and other similar Linux distributions, it is highly recommended to install the relevant RPM package from MariaDB''s repository using yum or dnf. Starting with RHEL 8 and Fedora 22, yum has been replaced by dnf, which is the next major version of yum. However, yum commands still work on many systems that use dnf:\n\n``bash\nsudo yum install MariaDB-cracklib-password-check\n`\n\nInstalling with apt-get\n\nOn Debian, Ubuntu, and other similar Linux distributions, it is highly recommended to install the relevant DEB package from MariaDB''s repository using apt-get:\n\n`sql\nsudo apt-get install mariadb-plugin-cracklib-password-check\n`\n\nInstalling with zypper\n\nOn SLES, OpenSUSE, and other similar Linux distributions, it is highly recommended to install the relevant RPM package from MariaDB''s repository using zypper:\n\n`bash\nsudo zypper install MariaDB-cracklib-password-check\n`\n\nInstalling the Plugin\n\nOnce the shared library is in place, the plugin is not actually installed by MariaDB by default. There are two methods that can be used to install the plugin with MariaDB.\n\nThe first method can be used to install the plugin without restarting the server. You can install the plugin dynamically by executing INSTALL SONAME or INSTALL PLUGIN:\n\n`sql\nINSTALL SONAME ''cracklib_password_check'';\n`\n\nThe second method can be used to tell the server to load the plugin when it starts up. The plugin can be installed this way by providing the --plugin-load or the --plugin-load-add options. This can be specified as a command-line argument to mariadbd, or it can be specified in a relevant server option group in an option file:\n\n`ini\n[mariadb]\n...\nplugin_load_add = cracklib_password_check\n`\n\nUninstalling the Plugin\n\nYou can uninstall the plugin dynamically by executing UNINSTALL SONAME or UNINSTALL PLUGIN:\n\n`sql\nUNINSTALL SONAME ''cracklib_password_check'';\n``\n\nIf you installed the plugin by providing the --plugin-load or the --plugin-load-add options in a relevant server option group in an option file, then those options should be removed to prevent the plugin from being loaded the next time the server is restarted.\n\nViewing CrackLib Errors\n\nIf password validation fails, then the original CrackLib error message can be viewed by executing SHOW WARNINGS.\n\nExamples\n--------\n\nSET PASSWORD FOR ''bob''@''%.loc.gov'' = PASSWORD(''abc'');\nERROR 1819 (HY000): Your password does not satisfy the current policy requirements\n\nURL: https://mariadb.com/docs/server/reference/plugins/password-validation-plugins/cracklib-password-check-plugin', '', 'https://mariadb.com/docs/server/reference/plugins/password-validation-plugins/cracklib-password-check-plugin'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (137, 5, 'Password Reuse Check Plugin', 'Description\n-----------\n\nThe plugin is used to prevent a user from reusing a password, which can be a requirement in some security policies. The password_reuse_check_interval system variable determines the retention period, in days, for a password. By default, this is zero, meaning unlimited retention. Old passwords are stored in the mysql.password_reuse_check_history table.\n\nNote that passwords can be directly set as a hash, bypassing the password validation, if the strict_password_validation variable is OFF (it is ON by default).\n\nInstalling the Plugin\n\nAlthough the plugin''s shared library is distributed with MariaDB by default, the plugin is not actually installed by MariaDB by default.\n\nYou can install the plugin dynamically, without restarting the server, by executing INSTALL SONAME or INSTALL PLUGIN:\n\n``sql\nINSTALL SONAME ''password_reuse_check'';\n`\n\nThe second method can be used to tell the server to load the plugin when it starts up. The plugin can be installed this way by providing the --plugin-load or the --plugin-load-add options. This can be specified as a command-line argument to mysqld or it can be specified in a relevant server option group in an option file:\n\n`ini\n[mariadb]\n...\nplugin_load_add = password_reuse_check\n`\n\nUninstalling the Plugin\n\nYou can uninstall the plugin dynamically by executing UNINSTALL SONAME or UNINSTALL PLUGIN:\n\n`sql\nUNINSTALL SONAME ''password_reuse_check'';\n``\n\nIf you installed the plugin by providing the --plugin-load or the --plugin-load-add options in a relevant server option group in an option file, then those options should be removed to prevent the plugin from being loaded the next time the server is restarted.\n\nExamples\n--------\n\nINSTALL SONAME ''password_reuse_check'';\n\nGRANT SELECT ON . TO user1@localhost identified by ''pwd1'';\nQuery OK, 0 rows affected (0.038 sec)\n\nGRANT SELECT ON . TO user1@localhost identified by ''pwd1'';\nERROR 1819 (HY000): Your password does not satisfy the current policy requirements\n\nGRANT SELECT ON . TO user1@localhost identified by ''pwd2'';\nQuery OK, 0 rows affected (0.003 sec)\n\nGRANT SELECT ON . TO user1@localhost identified by ''pwd1'';\nERROR 1819 (HY000): Your password does not satisfy the current policy requirements\n\nURL: https://mariadb.com/docs/server/reference/plugins/password-validation-plugins/password-reuse-check-plugin', '', 'https://mariadb.com/docs/server/reference/plugins/password-validation-plugins/password-reuse-check-plugin'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (138, 5, 'Password Validation Plugin Overview', 'Description\n-----------\n\n_Password validation_ means ensuring that user passwords meet certain minimal security requirements. A dedicated plugin API allows the creation of password validation plugins that will check user passwords as they are set (in SET PASSWORD and GRANT statements) and either allow or reject them.\n\nSQL-Level Extensions\n\nMariaDB comes with three password validation plugins — the simple_password_check plugin, the cracklib_password_check plugin and the password_reuse_check plugin. They are not enabled by default – use INSTALL SONAME (or INSTALL PLUGIN) statement to install them.\n\nWhen at least one password plugin is loaded, all new passwords will be validated and password-changing statements will fail if the password will not pass validation checks. Several password validation plugin can be loaded at the same time — in this case a password must pass all validation checks by all plugins.\n\nPassword-Changing Statements\n\nOne can use various SQL statements to change a user password:\n\nWith Plain Text Password\n\n``sql\nSET PASSWORD = PASSWORD(''plain-text password'');\nSET PASSWORD FOR user@host = PASSWORD(''plain-text password'');\nSET PASSWORD = OLD_PASSWORD(''plain-text password'');\nSET PASSWORD FOR user@host = OLD_PASSWORD(''plain-text password'');\nCREATE USER user@host IDENTIFIED BY ''plain-text password'';\nGRANT PRIVILEGES TO user@host IDENTIFIED BY ''plain-text password'';\n`\n\nThese statements are subject to password validation. If at least one password validation plugin is loaded, plain-text passwords specified in these statements will be validated.\n\nWith Password Hash\n\n`sql\nSET PASSWORD = ''password hash'';\nSET PASSWORD FOR user@host = ''password hash'';\nCREATE USER user@host IDENTIFIED BY PASSWORD ''password hash'';\nCREATE USER user@host IDENTIFIED VIA mysql_native_password USING ''password hash'';\nCREATE USER user@host IDENTIFIED VIA mysql_old_password USING ''password hash'';\nGRANT PRIVILEGES TO user@host IDENTIFIED BY PASSWORD ''password hash'';\nGRANT PRIVILEGES TO user@host IDENTIFIED VIA mysql_native_password USING ''password hash'';\nGRANT PRIVILEGES TO user@host IDENTIFIED VIA mysql_old_password USING ''password hash'';\n``\n\nThese statements can not possibly use password validation — there is nothing to validate, the original plain-text password is not available.\n\nMariaDB introduces a strict password validation mode — controlled by a strict_password_validation global server variable.\n\nIf the strict password validation is enabled and at least one password validation plugin is loaded, passwords that cannot be validated are rejected; otherwise, they''re accepted. By default, a strict password validation is enabled (but note that it has no effect if no password validation plugin is loaded).\n\nExamples\n--------\n\nGRANT SELECT ON . to foobar IDENTIFIED BY ''raboof'';\nERROR HY000: Your password does not satisfy the current policy requirements\n\nSHOW WARNINGS;\n+---------+------+----------------------------------------------------------------+\n| Level | Code | Message |\n+---------+------+----------------------------------------------------------------+\n| Warning | 1819 | cracklib: it is based on your username |\n| Error | 1819 | Your password does not satisfy the current policy requirements |\n+---------+------+----------------------------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/plugins/password-validation-plugins/password-validation', '', 'https://mariadb.com/docs/server/reference/plugins/password-validation-plugins/password-validation'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (139, 5, 'password\\_reuse\\_check\\_interval Variable', 'Description\n-----------\n\nThe password_reuse_check_interval system variable is available when the password_reuse_check plugin is installed. It determines the retention period for the password history in days. Zero, the default, means that passwords are never discarded.\n\n Command line: --password_reuse_check_interval=#\n Scope: Global\n Read-only: No\n Data Type: numeric\n Default Value: 0\n Range: 0 to 36500\n\nURL: https://mariadb.com/docs/server/reference/plugins/password-validation-plugins/password_reuse_check_interval', '', 'https://mariadb.com/docs/server/reference/plugins/password-validation-plugins/password_reuse_check_interval'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (140, 5, 'Simple Password Check Plugin', 'Description\n-----------\n\nsimple_password_check is a password validation plugin. It can check whether a password contains at least a certain number of characters of a specific type. When first installed, a password is required to be at least eight characters, and requires at least one digit, one uppercase character, one lowercase character, and one character that is neither a digit nor a letter.\n\nNote that passwords can be directly set as a hash, bypassing the password validation, if the strict_password_validation variable is OFF (it is ON by default).\n\nInstalling the Plugin\n\nAlthough the plugin''s shared library is distributed with MariaDB by default, the plugin is not actually installed by MariaDB by default. There are two methods that can be used to install the plugin with MariaDB.\n\nThe first method can be used to install the plugin without restarting the server. You can install the plugin dynamically by executing INSTALL SONAME or INSTALL PLUGIN:\n\n``sql\nINSTALL SONAME ''simple_password_check'';\n`\n\nThe second method can be used to tell the server to load the plugin when it starts up. The plugin can be installed this way by providing the --plugin-load or the --plugin-load-add options. This can be specified as a command-line argument to mariadbd, or it can be specified in a relevant server option group in an option file:\n\n`ini\n[mariadb]\n...\nplugin_load_add = simple_password_check\n`\n\nUninstalling the Plugin\n\nYou can uninstall the plugin dynamically by executing UNINSTALL SONAME or UNINSTALL PLUGIN:\n\n`sql\nUNINSTALL SONAME ''simple_password_check'';\n``\n\nIf you installed the plugin by providing the --plugin-load or the --plugin-load-add options in a relevant server option group in an option file, then those options should be removed to prevent the plugin from being loaded the next time the server is restarted.\n\nExamples\n--------\n\nSET PASSWORD FOR ''bob''@''%.loc.gov'' = PASSWORD(''abc'');\nERROR 1819 (HY000): Your password does not satisfy the current policy requirements\n\nURL: https://mariadb.com/docs/server/reference/plugins/password-validation-plugins/simple-password-check-plugin', '', 'https://mariadb.com/docs/server/reference/plugins/password-validation-plugins/simple-password-check-plugin'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (141, 5, 'Plugin Overview', 'Description\n-----------\n\nMariaDB supports the use of plugins, software components that may be added to the core software without having to rebuild the MariaDB server from source code. Plugins can be loaded at startup, or loaded and unloaded while the server is running, without interruption. Plugins are commonly used for adding desired storage engines, additional security requirements, logging special information about the server, or even small enhancements, such as a plugin to get a timestamp as an integer.\n\nQuerying Plugin Information\n\nThere are a number of ways to see which plugins are currently active.\n\nA server almost always has a large number of active plugins, because the server contains a large number of built-in plugins, which are active by default and cannot be uninstalled.\n\nQuerying Plugin Information with SHOW PLUGINS\n\nThe SHOW PLUGINS statement can be used to query information about all active plugins.\n\nFor example:\n\n``sql\nSHOW PLUGINS\\G;\n******************* 1. row ****************\n Name: binlog\n Status: ACTIVE\n Type: STORAGE ENGINE\nLibrary: NULL\nLicense: GPL\n**************** 2. row ****************\n Name: mysql_native_password\n Status: ACTIVE\n Type: AUTHENTICATION\nLibrary: NULL\nLicense: GPL\n**************** 3. row ******************\n Name: mysql_old_password\n Status: ACTIVE\n Type: AUTHENTICATION\nLibrary: NULL\nLicense: GPL\n...\n`\n\nIf a plugin''s Library column has a NULL value, then the plugin is built-in, and it cannot be uninstalled.\n\nQuerying Plugin Information with information_schema.PLUGINS\n\nThe information_schema.PLUGINS table can be queried to get more detailed information about plugins.\n\nFor example:\n\n`sql\nSELECT FROM information_schema.PLUGINS\\G\n...\n************************ 65. row *********************\n PLUGIN_NAME: user_variables\n PLUGIN_VERSION: 1.0\n PLUGIN_STATUS: ACTIVE\n PLUGIN_TYPE: INFORMATION SCHEMA\n PLUGIN_TYPE_VERSION: 110600.0\n PLUGIN_LIBRARY: NULL\nPLUGIN_LIBRARY_VERSION: NULL\n PLUGIN_AUTHOR: Sergey Vojtovich\n PLUGIN_DESCRIPTION: User-defined variables\n PLUGIN_LICENSE: GPL\n LOAD_OPTION: ON\n PLUGIN_MATURITY: Stable\n PLUGIN_AUTH_VERSION: 1.0\n********************* 66. row *********************\n PLUGIN_NAME: wsrep_provider\n PLUGIN_VERSION: 1.0\n PLUGIN_STATUS: ACTIVE\n PLUGIN_TYPE: REPLICATION\n PLUGIN_TYPE_VERSION: 2.0\n PLUGIN_LIBRARY: NULL\nPLUGIN_LIBRARY_VERSION: NULL\n PLUGIN_AUTHOR: Codership Oy\n PLUGIN_DESCRIPTION: Wsrep provider plugin\n PLUGIN_LICENSE: GPL\n LOAD_OPTION: ON\n PLUGIN_MATURITY: Alpha\n PLUGIN_AUTH_VERSION: 1.0\n********************* 67. row ***********************\n PLUGIN_NAME: THREAD_POOL_GROUPS\n PLUGIN_VERSION: 1.0\n PLUGIN_STATUS: ACTIVE\n PLUGIN_TYPE: INFORMATION SCHEMA\n PLUGIN_TYPE_VERSION: 110600.0\n PLUGIN_LIBRARY: NULL\nPLUGIN_LIBRARY_VERSION: NULL\n PLUGIN_AUTHOR: Vladislav Vaintroub\n PLUGIN_DESCRIPTION: Provides information about threadpool groups.\n PLUGIN_LICENSE: GPL\n LOAD_OPTION: ON\n PLUGIN_MATURITY: Stable\n PLUGIN_AUTH_VERSION: 1.0\n...\n`\n\nIf a plugin''s PLUGIN_LIBRARY column has the NULL value, the plugin is built-in and cannot be uninstalled.\n\nQuerying Plugin Information with mysql.plugin\n\nThe mysql.plugin table can be queried to get information about installed plugins.\n\nThis table only contains information about plugins that have been installed via the following methods:\n\n The INSTALL SONAME statement.\n The INSTALL PLUGIN statement.\n The mariadb-plugin utility.\n\nThis table does not contain information about:\n\n Built-in plugins.\n Plugins loaded with the --plugin-load-add option.\n Plugins loaded with the --plugin-load option.\n\nThis table only contains enough information to reload the plugin when the server is restarted, which means it only contains the plugin name and the plugin library.\n\nFor example:\n\n`sql\nSELECT FROM mysql.plugin;\n\n+------+------------+\n| name | dl |\n+------+------------+\n| PBXT | libpbxt.so |\n+------+------------+\n`\n\nInstalling a Plugin\n\nThere are three primary ways to install a plugin:\n\n A plugin can be installed dynamically with an SQL statement.\n A plugin can be installed with a mariadbd option, but it requires a server restart.\n A plugin can be installed with the mariadb-plugin utility, while the server is completely offline.\n\nWhen you are installing a plugin, you also have to ensure that:\n\n The server''s plugin directory is properly configured, and the plugin''s library is in the plugin directory.\n The server''s minimum plugin maturity is properly configured, and the plugin is mature enough to be installed.\n\nInstalling a Plugin Dynamically\n\nA plugin can be installed dynamically by executing either the INSTALL SONAME or the INSTALL PLUGIN statement.\n\nIf a plugin is installed with one of these statements, a record will be added to the mysql.plugins table for the plugin. This means that the plugin will automatically be loaded every time the server restarts, unless specifically uninstalled or deactivated.\n\nInstalling a Plugin with INSTALL SONAME\n\nYou can install a plugin dynamically by executing the INSTALL SONAME statement. INSTALL SONAME installs all plugins from the given plugin library. This could be required for some plugin libraries.\n\nFor example, to install all plugins in the server_audit plugin library (which is currently only the server_audit audit plugin), you could execute the following:\n\n`sql\nINSTALL SONAME ''server_audit'';\n`\n\nInstalling a Plugin with INSTALL PLUGIN\n\nYou can install a plugin dynamically by executing the INSTALL PLUGIN statement. INSTALL PLUGIN installs a single plugin from the given plugin library.\n\nFor example, to install the server_audit audit plugin from the server_audit plugin library, you could execute the following:\n\n`sql\nINSTALL PLUGIN server_audit SONAME ''server_audit'';\n`\n\nInstalling a Plugin with Plugin Load Options\n\nA plugin can be installed with a mariadbd option by providing either the --plugin-load-add or the --plugin-load option.\n\nIf a plugin is installed with one of these options, then a record will not be added to the mysql.plugins table for the plugin. This means that if the server is restarted without the same option set, then the plugin will not automatically be loaded.\n\nInstalling a Plugin with --plugin-load-add\n\nYou can install a plugin with the --plugin-load-add option by specifying the option as a command-line argument to mariadbd or by specifying the option in a relevant server option group in an option file.\n\nThe --plugin-load-add option uses the following format:\n\n Plugins can be specified in the format name=library, where name is the plugin name and library is the plugin library. This format installs a single plugin from the given plugin library.\n Plugins can also be specified in the format library, where library is the plugin library. This format installs all plugins from the given plugin library.\n Multiple plugins can be specified by separating them with semicolons.\n\nFor example, to install all plugins in the server_audit plugin library (which is currently only the server_audit audit plugin) and also the ed25519 authentication plugin from the auth_ed25519 plugin library, you could set the option to the following values on the command-line:\n\n`bash\n$ mariadbd --user=mysql --plugin-load-add=''server_audit'' --plugin-load-add=''ed25519=auth_ed25519''\n`\n\nYou could also set the option to the same values in an option file:\n\n`ini\n[mariadb]\n...\nplugin_load_add = server_audit\nplugin_load_add = ed25519=auth_ed25519\n`\n\nSpecial care must be taken when specifying both the --plugin-load option and the --plugin-load-add option together. The --plugin-load option resets the plugin load list, and this can cause unexpected problems if you are not aware. The --plugin-load-add option does not reset the plugin load list, so it is much safer to use. See Specifying Multiple Plugin Load Options for more information.\n\nInstalling a Plugin with --plugin-load\n\nYou can install a plugin with the --plugin-load option by specifying the option as a command-line argument to mariadbd or by specifying the option in a relevant server option group in an option file.\n\nThe --plugin-load option uses the following format:\n\n Plugins can be specified in the format name=library, where name is the plugin name and library is the plugin library. This format installs a single plugin from the given plugin library.\n Plugins can also be specified in the format library, where library is the plugin library. This format installs all plugins from the given plugin library.\n Multiple plugins can be specified by separating them with semicolons.\n\nFor example, to install all plugins in the server_audit plugin library (which is currently only the server_audit audit plugin) and also the ed25519 authentication plugin from the auth_ed25519 plugin library, you could set the option to the following values on the command-line:\n\n`bash\n$ mariadbd --user=mysql --plugin-load=''server_audit;ed25519=auth_ed25519''\n`\n\nYou could also set the option to the same values in an option file:\n\n`ini\n[mariadb]\n...\nplugin_load = server_audit;ed25519=auth_ed25519\n`\n\nSpecial care must be taken when specifying the --plugin-load option multiple times, or when specifying both the --plugin-load option and the --plugin-load-add option together. The --plugin-load option resets the plugin load list, and this can cause unexpected problems if you are not aware. The --plugin-load-add option does not reset the plugin load list, so it is much safer to use. See Specifying Multiple Plugin Load Options for more information.\n\nSpecifying Multiple Plugin Load Options\n\nSpecial care must be taken when specifying the --plugin-load option multiple times, or when specifying both the --plugin-load option and the --plugin-load-add option. The --plugin-load option resets the plugin load list, and this can cause unexpected problems if you are not aware. The --plugin-load-add option does not reset the plugin load list, so it is much safer to use.\n\nThis can have the following consequences:\n\n If the --plugin-load option is specified multiple times, then only the last instance will have any effect. For example, in the following case, the first instance of the option is reset:\n\n`ini\n[mariadb]\n...\nplugin_load = server_audit\nplugin_load = ed25519=auth_ed25519\n`\n\n If the --plugin-load option is specified after the --plugin-load-add option, then it will also reset the changes made by that option. For example, in the following case, the --plugin-load-add option does not do anything, because the subsequent --plugin-load option resets the plugin load list:\n\n`ini\n[mariadb]\n...\nplugin_load_add = server_audit\nplugin_load = ed25519=auth_ed25519\n`\n\n In contrast, if the --plugin-load option is specified before the --plugin-load-add option, then it will work fine, because the --plugin-load-add option does not reset the plugin load list. For example, in the following case, both plugins are properly loaded:\n\n`ini\n[mariadb]\n...\nplugin_load = server_audit\nplugin_load_add = ed25519=auth_ed25519\n`\n\nInstalling a Plugin with mariadb-plugin\n\nA plugin can be installed with the mariadb-plugin utility if the server is completely offline.\n\nThe syntax is:\n\n`sql\nmariadb-plugin [options] ENABLE|DISABLE\n`\n\nFor example, to install the server_audit audit plugin, you could execute the following:\n\n`sql\nmariadb-plugin server_audit ENABLE\n`\n\nIf a plugin is installed with this utility, a record will be added to the mysql.plugins table for the plugin. This means that the plugin will automatically be loaded every time the server restarts, unless specifically uninstalled or deactivated.\n\nConfiguring the Plugin Directory\n\nWhen a plugin is being installed, the server looks for the plugin''s library in the server''s plugin directory. This directory is configured by the plugin_dir system variable. This can be specified as a command-line argument to mariadbd or it can be specified in a relevant server option group in an option file:\n\n`ini\n[mariadb]\n...\nplugin_dir = /usr/lib64/mysql/plugin\n`\n\nConfiguring the Minimum Plugin Maturity\n\nWhen a plugin is being installed, the server compares the plugin''s maturity level against the server''s minimum allowed plugin maturity. This can help prevent users from using unstable plugins on production servers. This minimum plugin maturity is configured by the plugin_maturity system variable. This can be specified as a command-line argument to mariadbd or it can be specified in a relevant server option group in an option file:\n\n`ini\n[mariadb]\n...\nplugin_maturity = stable\n`\n\nConfiguring Plugin Activation at Server Startup\n\nA plugin will be loaded by default when the server starts if:\n\n The plugin was installed with the INSTALL SONAME statement.\n The plugin was installed with the INSTALL PLUGIN statement.\n The plugin was installed with the mariadb-plugin utility.\n The server is configured to load the plugin with the --plugin-load-add option.\n The server is configured to load the plugin with the --plugin-load option.\n\nThis behavior can be changed with special options that take the form --plugin-name. For example, for the server_audit audit plugin, the special option is called --server-audit.\n\nThe possible values for these special options are:\n\n| Option Value | Description |\n| ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| OFF | Disables the plugin without removing it from the mysql.plugins table. |\n| ON | Enables the plugin. If the plugin cannot be initialized, then the server will still continue starting up, but the plugin will be disabled.\n\n[Truncated — full content at mariadb.com/docs]', '', 'https://mariadb.com/docs/server/reference/plugins/plugin-overview'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (142, 16, 'Aggregate Functions', 'Description\n-----------\n\nstored-aggregate-functions.md\n\nStored Aggregate Functions allow users to create custom aggregate functions that process a sequence of rows and return a single summary result. This page provides a general overview.\n\navg.md\n\nCalculate the average value. This function computes the arithmetic mean of a numeric expression, ignoring NULL values.\n\nbit_and.md\n\nPerform a bitwise AND operation. This function returns the result of performing a bitwise AND on all values in a given expression.\n\nbit_or.md\n\nPerform a bitwise OR operation. This function returns the result of performing a bitwise OR on all values in a given expression.\n\nbit_xor.md\n\nPerform a bitwise XOR operation. This function returns the result of performing a bitwise XOR on all values in a given expression.\n\ncount-distinct.md\n\nCount unique values. This function returns the number of distinct, non-NULL values found in the specified column or expression.\n\ncount.md\n\nComplete COUNT() function reference: COUNT(*) and COUNT(expr) syntax, COUNT(DISTINCT) usage, GROUP BY aggregation, and OVER(PARTITION BY) window syntax.\n\ngroup_concat.md\n\nComplete GROUP_CONCAT reference for MariaDB. Complete function guide with syntax, parameters, return values, and usage examples for production use.\n\njson_arrayagg.md\n\nAggregate values into a JSON array. This function aggregates a result set column into a single JSON array.\n\njson_objectagg.md\n\nAggregate key-value pairs into a JSON object. This function aggregates two columns or expressions into a single JSON object.\n\nmax.md\n\nFind the maximum value. This function returns the highest value in a set of values, applicable to numbers, strings, and dates.\n\nmin.md\n\nFind the minimum value. This function returns the lowest value in a set of values, applicable to numbers, strings, and dates.\n\nstd.md\n\nCalculate population standard deviation. This function returns the square root of the population variance. It is a synonym for STDDEV_POP().\n\nstddev.md\n\nCalculate population standard deviation. This function is a synonym for STD() and STDDEV_POP(), returning the square root of the population variance.\n\nstddev_pop.md\n\nCalculate population standard deviation. This function computes the standard deviation assuming the set of values represents the entire population.\n\nstddev_samp.md\n\nCalculate sample standard deviation. This function computes the standard deviation assuming the set of values represents a sample of the population.\n\nsum.md\n\nCalculate the total sum. This function returns the sum of all values in a numeric expression, ignoring NULL values.\n\nvar_pop.md\n\nCalculate population variance. This function computes the statistical variance for a set of values assumed to be the entire population.\n\nvar_samp.md\n\nCalculate sample variance. This function computes the statistical variance for a set of values assumed to be a sample of the population.\n\nvariance.md\n\nCalculate population variance. This function is a synonym for VAR_POP() and returns the variance of a set of values.\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/aggregate-functions/README', '', 'https://mariadb.com/docs/server/reference/sql-functions/aggregate-functions/README'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (143, 16, 'AVG', 'Syntax\n------\n\nAVG([DISTINCT] expr)\n\nDescription\n-----------\n\nReturns the average value of expr. The DISTINCT option can be used to return the average of the distinct values of expr. NULL values are ignored. It is an aggregate function, and so can be used with the GROUP BY clause.\n\nAVG() returns NULL if there were no matching rows.\n\nAVG() can be used as a window function.\n\nExamples\n--------\n\nCREATE TABLE sales (sales_value INT);\n\nINSERT INTO sales VALUES(10),(20),(20),(40);\n\nSELECT AVG(sales_value) FROM sales;\n+------------------+\n| AVG(sales_value) |\n+------------------+\n| 22.5000 |\n+------------------+\n\nSELECT AVG(DISTINCT(sales_value)) FROM sales;\n+----------------------------+\n| AVG(DISTINCT(sales_value)) |\n+----------------------------+\n| 23.3333 |\n+----------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/aggregate-functions/avg', '', 'https://mariadb.com/docs/server/reference/sql-functions/aggregate-functions/avg'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (144, 16, 'BIT\\_AND', 'Syntax\n------\n\nBIT_AND(expr) [over_clause]\n\nDescription\n-----------\n\nReturns the bitwise AND of all bits in _expr_. The calculation is performed with 64-bit (BIGINT) precision. It is an aggregate function, and so can be used with the GROUP BY clause.\n\nIf no rows match, BIT_AND will return a value with all bits set to 1. NULL values have no effect on the result unless all results are NULL, which is treated as no match.\n\nBIT_AND can be used as a window function with the addition of the _over_clause_.\n\nExamples\n--------\n\nCREATE TABLE vals (x INT);\n\nINSERT INTO vals VALUES(111),(110),(100);\n\nSELECT BIT_AND(x), BIT_OR(x), BIT_XOR(x) FROM vals;\n+------------+-----------+------------+\n| BIT_AND(x) | BIT_OR(x) | BIT_XOR(x) |\n+------------+-----------+------------+\n| 100 | 111 | 101 |\n+------------+-----------+------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/aggregate-functions/bit_and', '', 'https://mariadb.com/docs/server/reference/sql-functions/aggregate-functions/bit_and'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (145, 16, 'BIT\\_OR', 'Syntax\n------\n\nBIT_OR(expr) [over_clause]\n\nDescription\n-----------\n\nReturns the bitwise OR of all bits in expr. The calculation is performed with 64-bit (BIGINT) precision. It is an aggregate function, and so can be used with the GROUP BY clause.\n\nIf no rows match, BIT_OR will return a value with all bits set to 0. NULL values have no effect on the result unless all results are NULL, which is treated as no match.\n\nBIT_OR can be used as a window function with the addition of the _over_clause_.\n\nExamples\n--------\n\nCREATE TABLE vals (x INT);\n\nINSERT INTO vals VALUES(111),(110),(100);\n\nSELECT BIT_AND(x), BIT_OR(x), BIT_XOR(x) FROM vals;\n+------------+-----------+------------+\n| BIT_AND(x) | BIT_OR(x) | BIT_XOR(x) |\n+------------+-----------+------------+\n| 100 | 111 | 101 |\n+------------+-----------+------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/aggregate-functions/bit_or', '', 'https://mariadb.com/docs/server/reference/sql-functions/aggregate-functions/bit_or'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (146, 16, 'BIT\\_XOR', 'Syntax\n------\n\nBIT_XOR(expr) [over_clause]\n\nDescription\n-----------\n\nReturns the bitwise XOR of all bits in expr. The calculation is performed with 64-bit (BIGINT) precision. It is an aggregate function, and so can be used with the GROUP BY clause.\n\nIf no rows match, BIT_XOR will return a value with all bits set to 0. NULL values have no effect on the result unless all results are NULL, which is treated as no match.\n\nBIT_XOR can be used as a window function with the addition of the _over_clause_.\n\nExamples\n--------\n\nCREATE TABLE vals (x INT);\n\nINSERT INTO vals VALUES(111),(110),(100);\n\nSELECT BIT_AND(x), BIT_OR(x), BIT_XOR(x) FROM vals;\n+------------+-----------+------------+\n| BIT_AND(x) | BIT_OR(x) | BIT_XOR(x) |\n+------------+-----------+------------+\n| 100 | 111 | 101 |\n+------------+-----------+------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/aggregate-functions/bit_xor', '', 'https://mariadb.com/docs/server/reference/sql-functions/aggregate-functions/bit_xor'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (147, 16, 'COUNT DISTINCT', 'Syntax\n------\n\nCOUNT(DISTINCT expr,[expr...])\n\nDescription\n-----------\n\nReturns a count of the number of different non-NULL values.\n\nCOUNT(DISTINCT) returns 0 if there were no matching rows.\n\nExamples\n--------\n\nCREATE TABLE student (name CHAR(10), test CHAR(10), score TINYINT); \n\nINSERT INTO student VALUES \n (''Chun'', ''SQL'', 75), (''Chun'', ''Tuning'', 73), \n (''Esben'', ''SQL'', 43), (''Esben'', ''Tuning'', 31), \n (''Kaolin'', ''SQL'', 56), (''Kaolin'', ''Tuning'', 88), \n (''Tatiana'', ''SQL'', 87), (''Tatiana'', ''Tuning'', 83);\n\nSELECT COUNT() FROM student;\n+----------+\n| COUNT() |\n+----------+\n| 8 |\n+----------+\n\nSELECT COUNT(DISTINCT (name)) FROM student;\n+------------------------+\n| COUNT(DISTINCT (name)) |\n+------------------------+\n| 4 |\n+------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/aggregate-functions/count-distinct', '', 'https://mariadb.com/docs/server/reference/sql-functions/aggregate-functions/count-distinct'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (148, 16, 'COUNT', 'Description\n-----------\n\nReturns a count of the number of non-NULL values of expr in the rows retrieved by a SELECT statement. The result is a BIGINT value. It is an aggregate function, and so can be used with the GROUP BY clause.\n\nCOUNT(\\) counts the total number of rows in a table.\n\nCOUNT() returns 0 if there were no matching rows.\n\nCOUNT() can be used as a window function.\n\nExamples\n--------\n\nCREATE TABLE student (name CHAR(10), test CHAR(10), score TINYINT); \n\nINSERT INTO student VALUES \n (''Chun'', ''SQL'', 75), (''Chun'', ''Tuning'', 73), \n (''Esben'', ''SQL'', 43), (''Esben'', ''Tuning'', 31), \n (''Kaolin'', ''SQL'', 56), (''Kaolin'', ''Tuning'', 88), \n (''Tatiana'', ''SQL'', 87), (''Tatiana'', ''Tuning'', 83);\n\nSELECT COUNT() FROM student;\n+----------+\n| COUNT(*) |\n+----------+\n| 8 |\n+----------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/aggregate-functions/count', '', 'https://mariadb.com/docs/server/reference/sql-functions/aggregate-functions/count'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (149, 16, 'GROUP\\_CONCAT', 'Syntax\n------\n\nGROUP_CONCAT(expr)\n\nDescription\n-----------\n\nThis function returns a string result with the concatenated non-NULL values from a group. If any expr in GROUP_CONCAT evaluates to NULL, that tuple is not present in the list returned by GROUP_CONCAT.\n\nIt returns NULL if all arguments are NULL, or there are no matching rows.\n\nThe maximum returned length in bytes is determined by the group_concat_max_len server system variable, which defaults to 1M.\n\nIf group_concat_max_len <= 512, the return type is VARBINARY or VARCHAR; otherwise, the return type is BLOB or TEXT. The choice between binary or non-binary types depends from the input.\n\nThe full syntax is as follows:\n\n``sql\nGROUP_CONCAT([DISTINCT] expr [,expr ...]\n [ORDER BY {unsigned_integer | col_name | expr}\n [ASC | DESC] [,col_name ...]]\n [SEPARATOR str_val]\n [LIMIT {[offset,] row_count | row_count OFFSET offset}])\n`\n\nDISTINCT eliminates duplicate values from the output string.\n\nORDER BY determines the order of returned values.\n\nSEPARATOR specifies a separator between the values. The default separator is a comma (,). It is possible to avoid using a separator by specifying an empty string.\n\nLIMIT\n\nThe LIMIT clause can be used with GROUP_CONCAT`.\n\nExamples\n--------\n\nSELECT student_name,\n GROUP_CONCAT(test_score)\n FROM student\n GROUP BY student_name;\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/aggregate-functions/group_concat', '', 'https://mariadb.com/docs/server/reference/sql-functions/aggregate-functions/group_concat'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (150, 16, 'MAX', 'Syntax\n------\n\nMAX([DISTINCT] expr)\n\nDescription\n-----------\n\nReturns the largest, or maximum, value of _expr_. MAX() can also take a string argument in which case it returns the maximum string value. The DISTINCT keyword can be used to find the maximum of the distinct values of _expr_, however, this produces the same result as omitting DISTINCT.\n\nNote that SET and ENUM fields are currently compared by their string value rather than their relative position in the set, so MAX() may produce a different highest result than ORDER BY DESC.\n\nIt is an aggregate function, and so can be used with the GROUP BY clause.\n\nMAX() can be used as a window function.\n\nMAX() returns NULL if there were no matching rows.\n\nNot only ascending, but also descending indexes can be used to optimize MAX.\n\nOnly ascending indexes can be used to optimize MAX.\n\nExamples\n--------\n\nCREATE TABLE student (name CHAR(10), test CHAR(10), score TINYINT); \n\nINSERT INTO student VALUES \n (''Chun'', ''SQL'', 75), (''Chun'', ''Tuning'', 73), \n (''Esben'', ''SQL'', 43), (''Esben'', ''Tuning'', 31), \n (''Kaolin'', ''SQL'', 56), (''Kaolin'', ''Tuning'', 88), \n (''Tatiana'', ''SQL'', 87), (''Tatiana'', ''Tuning'', 83);\n\nSELECT name, MAX(score) FROM student GROUP BY name;\n+---------+------------+\n| name | MAX(score) |\n+---------+------------+\n| Chun | 75 |\n| Esben | 43 |\n| Kaolin | 88 |\n| Tatiana | 87 |\n+---------+------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/aggregate-functions/max', '', 'https://mariadb.com/docs/server/reference/sql-functions/aggregate-functions/max'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (151, 16, 'MIN', 'Syntax\n------\n\nMIN([DISTINCT] expr)\n\nDescription\n-----------\n\nReturns the minimum value of _expr_. MIN() may take a string argument, in which case it returns the minimum string value. The DISTINCT keyword can be used to find the minimum of the distinct values of _expr_, however, this produces the same result as omitting DISTINCT.\n\nNote that SET and ENUM fields are currently compared by their string value rather than their relative position in the set, so MIN() may produce a different lowest result than ORDER BY ASC.\n\nIt is an aggregate function, and so can be used with the GROUP BY clause.\n\nMIN() can be used as a window function.\n\nMIN() returns NULL if there were no matching rows.\n\nNot only ascending, but also descending indexes can be used to optimize MIN.\n\nOnly ascending indexes can be used to optimize MIN.\n\nExamples\n--------\n\nCREATE TABLE student (name CHAR(10), test CHAR(10), score TINYINT); \n\nINSERT INTO student VALUES \n (''Chun'', ''SQL'', 75), (''Chun'', ''Tuning'', 73), \n (''Esben'', ''SQL'', 43), (''Esben'', ''Tuning'', 31), \n (''Kaolin'', ''SQL'', 56), (''Kaolin'', ''Tuning'', 88), \n (''Tatiana'', ''SQL'', 87), (''Tatiana'', ''Tuning'', 83);\n\nSELECT name, MIN(score) FROM student GROUP BY name;\n+---------+------------+\n| name | MIN(score) |\n+---------+------------+\n| Chun | 73 |\n| Esben | 31 |\n| Kaolin | 56 |\n| Tatiana | 83 |\n+---------+------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/aggregate-functions/min', '', 'https://mariadb.com/docs/server/reference/sql-functions/aggregate-functions/min'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (152, 16, 'STD', 'Syntax\n------\n\nSTD(expr)\n\nDescription\n-----------\n\nReturns the population standard deviation of _expr_. This is an extension to standard SQL. The standard SQL function STDDEV_POP() can be used instead.\n\nIt is an aggregate function, and so can be used with the GROUP BY clause.\n\nSTD() can be used as a window function.\n\nThis function returns NULL if there were no matching rows.\n\nExamples\n--------\n\nCREATE OR REPLACE TABLE stats (category VARCHAR(2), x INT);\n\nINSERT INTO stats VALUES \n (''a'',1),(''a'',2),(''a'',3),\n (''b'',11),(''b'',12),(''b'',20),(''b'',30),(''b'',60);\n\nSELECT category, STDDEV_POP(x), STDDEV_SAMP(x), VAR_POP(x) \n FROM stats GROUP BY category;\n+----------+---------------+----------------+------------+\n| category | STDDEV_POP(x) | STDDEV_SAMP(x) | VAR_POP(x) |\n+----------+---------------+----------------+------------+\n| a | 0.8165 | 1.0000 | 0.6667 |\n| b | 18.0400 | 20.1693 | 325.4400 |\n+----------+---------------+----------------+------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/aggregate-functions/std', '', 'https://mariadb.com/docs/server/reference/sql-functions/aggregate-functions/std'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (153, 16, 'STDDEV', 'Syntax\n------\n\nSTDDEV(expr)\n\nDescription\n-----------\n\nReturns the population standard deviation of _expr_. This function is provided for compatibility with Oracle. The standard SQL function STDDEV_POP() can be used instead.\n\nIt is an aggregate function, and so can be used with the GROUP BY clause.\n\nSTDDEV() can be used as a window function.\n\nThis function returns NULL if there were no matching rows.\n\nExamples\n--------\n\nCREATE OR REPLACE TABLE stats (category VARCHAR(2), x INT);\n\nINSERT INTO stats VALUES \n (''a'',1),(''a'',2),(''a'',3),\n (''b'',11),(''b'',12),(''b'',20),(''b'',30),(''b'',60);\n\nSELECT category, STDDEV_POP(x), STDDEV_SAMP(x), VAR_POP(x) \n FROM stats GROUP BY category;\n+----------+---------------+----------------+------------+\n| category | STDDEV_POP(x) | STDDEV_SAMP(x) | VAR_POP(x) |\n+----------+---------------+----------------+------------+\n| a | 0.8165 | 1.0000 | 0.6667 |\n| b | 18.0400 | 20.1693 | 325.4400 |\n+----------+---------------+----------------+------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/aggregate-functions/stddev', '', 'https://mariadb.com/docs/server/reference/sql-functions/aggregate-functions/stddev'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (154, 16, 'STDDEV\\_POP', 'Syntax\n------\n\nSTDDEV_POP(expr)\n\nDescription\n-----------\n\nReturns the population standard deviation of _expr_ (the square root of VAR_POP()). You can also use STD() or STDDEV(), which are equivalent but not standard SQL.\n\nIt is an aggregate function, and so can be used with the GROUP BY clause.\n\nSTDDEV_POP() can be used as a window function.\n\nSTDDEV_POP() returns NULL if there were no matching rows.\n\nExamples\n--------\n\nCREATE OR REPLACE TABLE stats (category VARCHAR(2), x INT);\n\nINSERT INTO stats VALUES \n (''a'',1),(''a'',2),(''a'',3),\n (''b'',11),(''b'',12),(''b'',20),(''b'',30),(''b'',60);\n\nSELECT category, STDDEV_POP(x), STDDEV_SAMP(x), VAR_POP(x) \n FROM stats GROUP BY category;\n+----------+---------------+----------------+------------+\n| category | STDDEV_POP(x) | STDDEV_SAMP(x) | VAR_POP(x) |\n+----------+---------------+----------------+------------+\n| a | 0.8165 | 1.0000 | 0.6667 |\n| b | 18.0400 | 20.1693 | 325.4400 |\n+----------+---------------+----------------+------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/aggregate-functions/stddev_pop', '', 'https://mariadb.com/docs/server/reference/sql-functions/aggregate-functions/stddev_pop'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (155, 16, 'STDDEV\\_SAMP', 'Syntax\n------\n\nSTDDEV_SAMP(expr)\n\nDescription\n-----------\n\nReturns the sample standard deviation of expr (the square root of VAR_SAMP()).\n\nIt is an aggregate function, and so can be used with the GROUP BY clause.\n\nSTDDEV_SAMP() can be used as a window function.\n\nSTDDEV_SAMP() returns NULL if there were no matching rows.\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/aggregate-functions/stddev_samp', '', 'https://mariadb.com/docs/server/reference/sql-functions/aggregate-functions/stddev_samp'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (156, 16, 'SUM', 'Syntax\n------\n\nSUM([DISTINCT] expr)\n\nDescription\n-----------\n\nReturns the sum of _expr_. If the return set has no rows, SUM() returnsNULL. The DISTINCT keyword can be used to sum only the distinct values of expr.\n\nSUM() can be used as a window function, although not with the DISTINCT specifier.\n\nExamples\n--------\n\nCREATE TABLE sales (sales_value INT);\nINSERT INTO sales VALUES(10),(20),(20),(40);\n\nSELECT SUM(sales_value) FROM sales;\n+------------------+\n| SUM(sales_value) |\n+------------------+\n| 90 |\n+------------------+\n\nSELECT SUM(DISTINCT(sales_value)) FROM sales;\n+----------------------------+\n| SUM(DISTINCT(sales_value)) |\n+----------------------------+\n| 70 |\n+----------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/aggregate-functions/sum', '', 'https://mariadb.com/docs/server/reference/sql-functions/aggregate-functions/sum'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (157, 16, 'VAR\\_POP', 'Syntax\n------\n\nVAR_POP(expr)\n\nDescription\n-----------\n\nReturns the population standard variance of expr. It considers rows as the whole population, not as a sample, so it has the number of rows as the denominator. You can also use VARIANCE(), which is equivalent but is not standard SQL.\n\nVariance is calculated by\n\n working out the mean for the set;\n for each number, subtracting the mean and squaring the result;\n* calculating the average of the resulting differences.\n\nIt is an aggregate function, and so can be used with the GROUP BY clause.\n\nVAR_POP() can be used as a window function.\n\nVAR_POP() returns NULL if there were no matching rows.\n\nExamples\n--------\n\nCREATE TABLE v(i tinyint);\n\nINSERT INTO v VALUES(101),(99);\n\nSELECT VAR_POP(i) FROM v;\n+------------+\n| VAR_POP(i) |\n+------------+\n| 1.0000 |\n+------------+\n\nINSERT INTO v VALUES(120),(80);\n\nSELECT VAR_POP(i) FROM v;\n+------------+\n| VAR_POP(i) |\n+------------+\n| 200.5000 |\n+------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/aggregate-functions/var_pop', '', 'https://mariadb.com/docs/server/reference/sql-functions/aggregate-functions/var_pop'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (158, 16, 'VAR\\_SAMP', 'Syntax\n------\n\nVAR_SAMP(expr)\n\nDescription\n-----------\n\nReturns the sample variance of _expr_. That is, the denominator is the number of rows minus one.\n\nIt is an aggregate function, and so can be used with the GROUP BY clause.\n\nVAR_SAMP() can be used as a window function.\n\nVAR_SAMP() returns NULL if there were no matching rows.\n\nExamples\n--------\n\nCREATE OR REPLACE TABLE stats (category VARCHAR(2), x INT);\n\nINSERT INTO stats VALUES \n (''a'',1),(''a'',2),(''a'',3),\n (''b'',11),(''b'',12),(''b'',20),(''b'',30),(''b'',60);\n\nSELECT category, STDDEV_POP(x), STDDEV_SAMP(x), VAR_POP(x) \n FROM stats GROUP BY category;\n+----------+---------------+----------------+------------+\n| category | STDDEV_POP(x) | STDDEV_SAMP(x) | VAR_POP(x) |\n+----------+---------------+----------------+------------+\n| a | 0.8165 | 1.0000 | 0.6667 |\n| b | 18.0400 | 20.1693 | 325.4400 |\n+----------+---------------+----------------+------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/aggregate-functions/var_samp', '', 'https://mariadb.com/docs/server/reference/sql-functions/aggregate-functions/var_samp'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (159, 16, 'VARIANCE', 'Syntax\n------\n\nVARIANCE(expr)\n\nDescription\n-----------\n\nReturns the population standard variance of expr. This is an extension to standard SQL. The standard SQL function VAR_POP() can be used instead.\n\nVariance is calculated by\n\n working out the mean for the set;\n for each number, subtracting the mean and squaring the result;\n* calculating the average of the resulting differences.\n\nIt is an aggregate function, and so can be used with the GROUP BY clause.\n\nVARIANCE() can be used as a window function.\n\nVARIANCE() returns NULL if there were no matching rows.\n\nExamples\n--------\n\nCREATE TABLE v(i tinyint);\n\nINSERT INTO v VALUES(101),(99);\n\nSELECT VARIANCE(i) FROM v;\n+-------------+\n| VARIANCE(i) |\n+-------------+\n| 1.0000 |\n+-------------+\n\nINSERT INTO v VALUES(120),(80);\n\nSELECT VARIANCE(i) FROM v;\n+-------------+\n| VARIANCE(i) |\n+-------------+\n| 200.5000 |\n+-------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/aggregate-functions/variance', '', 'https://mariadb.com/docs/server/reference/sql-functions/aggregate-functions/variance'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (160, 7, 'CASE OPERATOR', 'Syntax\n------\n\nCASE value WHEN [compare_value] THEN result [WHEN [compare_value] THEN\nresult ...] [ELSE result] END\n\nCASE WHEN [condition] THEN result [WHEN [condition] THEN result ...]\n[ELSE result] END\n\nDescription\n-----------\n\nThe first version returns the result for the first value=compare_value comparison that is true. The second version returns the result for the first condition that is true. If there was no matching result value, the result after ELSE is returned, or NULL if there is no ELSE part.\n\nThere is also a CASE statement, which differs from the CASE operator described here.\n\nExamples\n--------\n\nSELECT CASE 1 WHEN 1 THEN ''one'' WHEN 2 THEN ''two'' ELSE ''more'' END;\n+------------------------------------------------------------+\n| CASE 1 WHEN 1 THEN ''one'' WHEN 2 THEN ''two'' ELSE ''more'' END |\n+------------------------------------------------------------+\n| one |\n+------------------------------------------------------------+\n\nSELECT CASE WHEN 1>0 THEN ''true'' ELSE ''false'' END;\n+--------------------------------------------+\n| CASE WHEN 1>0 THEN ''true'' ELSE ''false'' END |\n+--------------------------------------------+\n| true |\n+--------------------------------------------+\n\nSELECT CASE BINARY ''B'' WHEN ''a'' THEN 1 WHEN ''b'' THEN 2 END;\n+-----------------------------------------------------+\n| CASE BINARY ''B'' WHEN ''a'' THEN 1 WHEN ''b'' THEN 2 END |\n+-----------------------------------------------------+\n| NULL |\n+-----------------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/control-flow-functions/case-operator', '', 'https://mariadb.com/docs/server/reference/sql-functions/control-flow-functions/case-operator'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (161, 7, 'DECODE\\_ORACLE', 'Description\n-----------\n\nDECODE_ORACLE is a synonym for the Oracle mode version of the DECODE function, and is available in all modes.\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/control-flow-functions/decode_oracle', '', 'https://mariadb.com/docs/server/reference/sql-functions/control-flow-functions/decode_oracle'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (162, 7, 'IF Function', 'Syntax\n------\n\nIF(expr1,expr2,expr3)\n\nDescription\n-----------\n\nIf expr1 is TRUE (expr1 <> 0 and expr1 <> NULL) then IF() returns expr2; otherwise it returns expr3. IF() returns a numeric or string value, depending on the context in which it is used.\n\nNote: There is also an IF statement which differs from theIF() function described here.\n\nExamples\n--------\n\nSELECT IF(1>2,2,3);\n+-------------+\n| IF(1>2,2,3) |\n+-------------+\n| 3 |\n+-------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/control-flow-functions/if-function', '', 'https://mariadb.com/docs/server/reference/sql-functions/control-flow-functions/if-function'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (163, 7, 'IFNULL', 'Syntax\n------\n\nIFNULL(expr1,expr2)\nNVL(expr1,expr2)\n\nDescription\n-----------\n\nIf _expr1_ is not NULL, IFNULL() returns _expr1_; otherwise it returns_expr2_. IFNULL() returns a numeric or string value, depending on the context in which it is used.\n\nNVL() is an alias for IFNULL().\n\nExamples\n--------\n\nSELECT IFNULL(1,0); \n+-------------+\n| IFNULL(1,0) |\n+-------------+\n| 1 |\n+-------------+\n\nSELECT IFNULL(NULL,10);\n+-----------------+\n| IFNULL(NULL,10) |\n+-----------------+\n| 10 |\n+-----------------+\n\nSELECT IFNULL(1/0,10);\n+----------------+\n| IFNULL(1/0,10) |\n+----------------+\n| 10.0000 |\n+----------------+\n\nSELECT IFNULL(1/0,''yes'');\n+-------------------+\n| IFNULL(1/0,''yes'') |\n+-------------------+\n| yes |\n+-------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/control-flow-functions/ifnull', '', 'https://mariadb.com/docs/server/reference/sql-functions/control-flow-functions/ifnull'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (164, 7, 'NULLIF', 'Syntax\n------\n\nNULLIF(expr1,expr2)\n\nDescription\n-----------\n\nReturns NULL if expr1 = expr2 is true, otherwise returns expr1. This is the same as CASE WHEN expr1 = expr2 THEN NULL ELSE expr1 END.\n\nExamples\n--------\n\nSELECT NULLIF(1,1);\n+-------------+\n| NULLIF(1,1) |\n+-------------+\n| NULL |\n+-------------+\n\nSELECT NULLIF(1,2);\n+-------------+\n| NULLIF(1,2) |\n+-------------+\n| 1 |\n+-------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/control-flow-functions/nullif', '', 'https://mariadb.com/docs/server/reference/sql-functions/control-flow-functions/nullif'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (165, 7, 'NVL', 'Description\n-----------\n\nNVL is a synonym for IFNULL.\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/control-flow-functions/nvl', '', 'https://mariadb.com/docs/server/reference/sql-functions/control-flow-functions/nvl'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (166, 7, 'NVL2', 'Syntax\n------\n\nNVL2(expr1,expr2,expr3)\n\nDescription\n-----------\n\nThe NVL2 function returns a value based on whether a specified expression is NULL or not. If _expr1_ is not NULL, then NVL2 returns _expr2_. If _expr1_ is NULL, then NVL2 returns _expr3_.\n\nExamples\n--------\n\nSELECT NVL2(NULL,1,2);\n+----------------+\n| NVL2(NULL,1,2) |\n+----------------+\n| 2 |\n+----------------+\n\nSELECT NVL2(''x'',1,2);\n+---------------+\n| NVL2(''x'',1,2) |\n+---------------+\n| 1 |\n+---------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/control-flow-functions/nvl2', '', 'https://mariadb.com/docs/server/reference/sql-functions/control-flow-functions/nvl2'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (167, 31, 'ADD\\_MONTHS', 'Syntax\n------\n\nADD_MONTHS(date, months)\n\nDescription\n-----------\n\nADD_MONTHS adds an integer _months_ to a given _date_ (DATE, DATETIME or TIMESTAMP), returning the resulting date.\n\n_months_ can be positive or negative. If months is not a whole number, it is rounded to the nearest whole number (not truncated).\n\nThe resulting day component will remain the same as that specified in _date_, unless the resulting month has fewer days than the day component of the given date, in which case the day will be the last day of the resulting month.\n\nReturns NULL if given an invalid date or a NULL argument.\n\nExamples\n--------\n\nSELECT ADD_MONTHS(''2012-01-31'', 2);\n+-----------------------------+\n| ADD_MONTHS(''2012-01-31'', 2) |\n+-----------------------------+\n| 2012-03-31 |\n+-----------------------------+\n\nSELECT ADD_MONTHS(''2012-01-31'', -5);\n+------------------------------+\n| ADD_MONTHS(''2012-01-31'', -5) |\n+------------------------------+\n| 2011-08-31 |\n+------------------------------+\n\nSELECT ADD_MONTHS(''2011-01-31'', 1);\n+-----------------------------+\n| ADD_MONTHS(''2011-01-31'', 1) |\n+-----------------------------+\n| 2011-02-28 |\n+-----------------------------+\n\nSELECT ADD_MONTHS(''2012-01-31'', 1);\n+-----------------------------+\n| ADD_MONTHS(''2012-01-31'', 1) |\n+-----------------------------+\n| 2012-02-29 |\n+-----------------------------+\n\nSELECT ADD_MONTHS(''2012-01-31'', 2);\n+-----------------------------+\n| ADD_MONTHS(''2012-01-31'', 2) |\n+-----------------------------+\n| 2012-03-31 |\n+-----------------------------+\n\nSELECT ADD_MONTHS(''2012-01-31'', 3);\n+-----------------------------+\n| ADD_MONTHS(''2012-01-31'', 3) |\n+-----------------------------+\n| 2012-04-30 |\n+-----------------------------+\n\nSELECT ADD_MONTHS(''2011-01-15'', 2.5);\n+-------------------------------+\n| ADD_MONTHS(''2011-01-15'', 2.5) |\n+-------------------------------+\n| 2011-04-15 |\n+-------------------------------+\n1 row in set (0.001 sec)\n\nSELECT ADD_MONTHS(''2011-01-15'', 2.6);\n+-------------------------------+\n| ADD_MONTHS(''2011-01-15'', 2.6) |\n+-------------------------------+\n| 2011-04-15 |\n+-------------------------------+\n1 row in set (0.001 sec)\n\nSELECT ADD_MONTHS(''2011-01-15'', 2.1);\n+-------------------------------+\n| ADD_MONTHS(''2011-01-15'', 2.1) |\n+-------------------------------+\n| 2011-03-15 |\n+-------------------------------+\n1 row in set (0.004 sec)\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/add_months', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/add_months'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (168, 31, 'ADDDATE', 'Syntax\n------\n\nADDDATE(date,INTERVAL expr unit), ADDDATE(expr,days)\n\nDescription\n-----------\n\nWhen invoked with the INTERVAL form of the second argument, ADDDATE() is a synonym for DATE_ADD(). The related function SUBDATE() is a synonym for DATE_SUB(). For information on the INTERVAL unit argument, see the discussion for DATE_ADD().\n\nWhen invoked with the days form of the second argument, MariaDB treats it as an integer number of days to be added to _expr_.\n\nExamples\n--------\n\nSELECT DATE_ADD(''2008-01-02'', INTERVAL 31 DAY);\n+-----------------------------------------+\n| DATE_ADD(''2008-01-02'', INTERVAL 31 DAY) |\n+-----------------------------------------+\n| 2008-02-02 |\n+-----------------------------------------+\n\nSELECT ADDDATE(''2008-01-02'', INTERVAL 31 DAY);\n+----------------------------------------+\n| ADDDATE(''2008-01-02'', INTERVAL 31 DAY) |\n+----------------------------------------+\n| 2008-02-02 |\n+----------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/adddate', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/adddate'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (169, 31, 'ADDTIME', 'Syntax\n------\n\nADDTIME(expr1,expr2)\n\nDescription\n-----------\n\nADDTIME() adds _expr2_ to _expr1_ and returns the result. _expr1_ is a time or datetime expression, and _expr2_ is a time expression.\n\nExamples\n--------\n\nSELECT ADDTIME(''2007-12-31 23:59:59.999999'', ''1 1:1:1.000002'');\n+---------------------------------------------------------+\n| ADDTIME(''2007-12-31 23:59:59.999999'', ''1 1:1:1.000002'') |\n+---------------------------------------------------------+\n| 2008-01-02 01:01:01.000001 |\n+---------------------------------------------------------+\n\nSELECT ADDTIME(''01:00:00.999999'', ''02:00:00.999998'');\n+-----------------------------------------------+\n| ADDTIME(''01:00:00.999999'', ''02:00:00.999998'') |\n+-----------------------------------------------+\n| 03:00:01.999997 |\n+-----------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/addtime', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/addtime'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (170, 31, 'CONVERT\\_TZ', 'Syntax\n------\n\nCONVERT_TZ(dt,from_tz,to_tz)\n\nDescription\n-----------\n\nCONVERT_TZ() converts a datetime value _dt_ from the time zone given by _from_tz_ to the time zone given by _to_tz_ and returns the resulting value.\n\nIn order to use named time zones, such as GMT, MET or Africa/Johannesburg, the time_zone tables must be loaded (see mysql_tzinfo_to_sql).\n\nNo conversion takes place if the value falls outside of the supported TIMESTAMP range when converted from _from_tz_ to UTC.\n\nThe supported range is 1970-01-01 00:00:00 to 2106-02-07 06:28:15 UTC.\n\nThe supported range is 1970-01-01 00:00:01 to 2038-01-19 05:14:07 UTC.\n\nThis function returns NULL if the arguments are invalid (or named time zones have not been loaded).\n\nSee time zones for more information.\n\nExamples\n--------\n\nSELECT CONVERT_TZ(''2016-01-01 12:00:00'',''+00:00'',''+10:00'');\n+-----------------------------------------------------+\n| CONVERT_TZ(''2016-01-01 12:00:00'',''+00:00'',''+10:00'') |\n+-----------------------------------------------------+\n| 2016-01-01 22:00:00 |\n+-----------------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/convert_tz', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/convert_tz'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (171, 31, 'CURDATE', 'Syntax\n------\n\nCURDATE()\nCURRENT_DATE\nCURRENT_DATE()\n\nDescription\n-----------\n\nCURDATE returns the current date as a value in YYYY-MM-DD or YYYYMMDD format, depending on whether the function is used in a string or numeric context.\n\nCURRENT_DATE and CURRENT_DATE() are synonyms.\n\nExamples\n--------\n\nSELECT CURDATE();\n+------------+\n| CURDATE() |\n+------------+\n| 2019-03-05 |\n+------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/curdate', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/curdate'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (172, 31, 'CURRENT\\_DATE', 'Syntax\n------\n\nCURRENT_DATE, CURRENT_DATE()\n\nDescription\n-----------\n\nCURRENT_DATE and CURRENT_DATE() are synonyms for CURDATE().\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/current_date', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/current_date'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (173, 31, 'CURRENT\\_TIME', 'Syntax\n------\n\nCURRENT_TIME\nCURRENT_TIME([precision])\n\nDescription\n-----------\n\nCURRENT_TIME and CURRENT_TIME() are synonyms for CURTIME().\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/current_time', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/current_time'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (174, 31, 'CURRENT\\_TIMESTAMP', 'Syntax\n------\n\nCURRENT_TIMESTAMP\nCURRENT_TIMESTAMP([precision])\n\nDescription\n-----------\n\nCURRENT_TIMESTAMP and CURRENT_TIMESTAMP() are synonyms for NOW().\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/current_timestamp', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/current_timestamp'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (175, 31, 'CURTIME', 'Syntax\n------\n\nCURTIME([precision])\n\nDescription\n-----------\n\nReturns the current time as a value in HH:MM:SS or HHMMSS.uuuuuu format, depending on whether the function is used in a string or numeric context. The value is expressed in the current time zone.\n\nThe optional _precision_ determines the microsecond precision. See Microseconds in MariaDB.\n\nExamples\n--------\n\nSELECT CURTIME();\n+-----------+\n| CURTIME() |\n+-----------+\n| 12:45:39 |\n+-----------+\n\nSELECT CURTIME() + 0;\n+---------------+\n| CURTIME() + 0 |\n+---------------+\n| 124545.000000 |\n+---------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/curtime', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/curtime'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (176, 31, 'Date and Time Units', 'Description\n-----------\n\nThe INTERVAL keyword can be used to add or subtract a time interval of time to a DATETIME, DATE or TIME value.\n\nThe syntax is:\n\n``sql\nINTERVAL time_quantity time_unit\n`\n\nFor example, the SECOND unit is used below by the DATE_ADD() function:\n\n`sql\nSELECT ''2008-12-31 23:59:59'' + INTERVAL 1 SECOND;\n+-------------------------------------------+\n| ''2008-12-31 23:59:59'' + INTERVAL 1 SECOND |\n+-------------------------------------------+\n| 2009-01-01 00:00:00 |\n+-------------------------------------------+\n`\n\nThe following units are valid:\n\n| Unit | Description |\n| ------------------- | --------------------------------------- |\n| MICROSECOND | Microseconds |\n| SECOND | Seconds |\n| MINUTE | Minutes |\n| HOUR | Hours |\n| DAY | Days |\n| WEEK | Weeks |\n| MONTH | Months |\n| QUARTER | Quarters |\n| YEAR | Years |\n| SECOND_MICROSECOND | Seconds.Microseconds |\n| MINUTE_MICROSECOND | Minutes.Seconds.Microseconds |\n| MINUTE_SECOND | Minutes.Seconds |\n| HOUR_MICROSECOND | Hours.Minutes.Seconds.Microseconds |\n| HOUR_SECOND | Hours.Minutes.Seconds |\n| HOUR_MINUTE | Hours.Minutes |\n| DAY_MICROSECOND | Days Hours.Minutes.Seconds.Microseconds |\n| DAY_SECOND | Days Hours.Minutes.Seconds |\n| DAY_MINUTE | Days Hours.Minutes |\n| DAY_HOUR | Days Hours |\n| YEAR_MONTH | Years-Months |\n\nThe time units containing an underscore are composite; that is, they consist of multiple base time units. For base time units, time_quantity is an integer number. For composite units, the quantity must be expressed as a string with multiple integer numbers separated by any punctuation character.\n\nExample of composite units:\n\n`sql\nINTERVAL ''2:2'' YEAR_MONTH\nINTERVAL ''1:30:30'' HOUR_SECOND\nINTERVAL ''1!30!30'' HOUR_SECOND -- same as above\n`\n\nTime units can be used in the following contexts:\n\n after a + or a - operator;\n with the following DATE or TIME functions: ADDDATE(), SUBDATE(), DATE_ADD(), DATE_SUB(), TIMESTAMPADD(), TIMESTAMPDIFF(), EXTRACT();\n in the ON SCHEDULE clause of CREATE EVENT and ALTER EVENT;\n when defining a partitioning BY SYSTEM_TIME` .\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/date-and-time-units', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/date-and-time-units'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (177, 31, 'DATE FUNCTION', 'Syntax\n------\n\nDATE(expr)\n\nDescription\n-----------\n\nExtracts the date part of the date or datetime expression _expr_. Returns NULL and throws a warning when passed an invalid date.\n\nExamples\n--------\n\nSELECT DATE(''2013-07-18 12:21:32'');\n+-----------------------------+\n| DATE(''2013-07-18 12:21:32'') |\n+-----------------------------+\n| 2013-07-18 |\n+-----------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/date-function', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/date-function'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (178, 31, 'DATE\\_ADD', 'Syntax\n------\n\nDATE_ADD(date,INTERVAL expr unit)\n\nDescription\n-----------\n\nPerforms date arithmetic. The _date_ argument specifies the starting date or datetime value. _expr_ is an expression specifying the interval value to be added to the starting date. _expr_ is a string; it may start with a "-" for negative intervals. For composite interval units (such as DAY_HOUR, MINUTE_SECOND, and SECOND_MICROSECOND), \n_expr_ can contain multiple components separated by spaces or punctuation. For example:\n\n- ''1 10'' DAY_HOUR represents 1 day and 10 hours \n- ''1:1'' MINUTE_SECOND represents 1 minute and 1 second \n- ''1.999999'' SECOND_MICROSECOND represents seconds and microseconds \n\nThe exact format of _expr_ depends on the _unit_ specified.\n\n_unit_ is a keyword indicating the units in which the expression should be interpreted. See Date and Time Units for a complete list of permitted units.\n\nThe result type of DATE_ADD() is determined as follows:\n\n if the first argument is of the type DATETIME, the function returns DATETIME ;\n if the first argument is DATE and the interval uses HOUR or smaller units, the function returns DATETIME ;\n if the first argument is DATE and the interval uses DAY or larger units, the function returns DATE ;\n similarly, if the first argument is TIME and the interval uses DAY or smaller units the function returns TIME, if the interval uses anything larger, the function returns DATETIME ;\n* if the first argument isn''t a temporal type, the function returns a string.\n\nExamples\n--------\n\nSELECT ''2008-12-31 23:59:59'' + INTERVAL 1 SECOND;\n+-------------------------------------------+\n| ''2008-12-31 23:59:59'' + INTERVAL 1 SECOND |\n+-------------------------------------------+\n| 2009-01-01 00:00:00 |\n+-------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/date_add', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/date_add'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (179, 31, 'DATE\\_FORMAT', 'Syntax\n------\n\nDATE_FORMAT(date, format[, locale])\n\nDescription\n-----------\n\nFormats the date value according to the format string.\n\nThe language used for the names is controlled by the value of the lc_time_names system variable. See server locale for more on the supported locales.\n\nDate Formatting Options\n\nThe options that can be used by DATE_FORMAT(), as well as its inverse STR_TO_DATE() and the FROM_UNIXTIME() function, are:\n\n| Option | Description |\n| ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |\n| %a | Short weekday name in current locale (Variable lc_time_names). |\n| %b | Short form month name in current locale. For locale en_US this is one of: Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, or Dec. |\n| %c | Month with 1 or 2 digits. |\n| %D | Day with English suffix ''th'', ''nd'', ''st'' or ''rd''''. (1st, 2nd, 3rd...). |\n| %d | Day with 2 digits. |\n| %e | Day with 1 or 2 digits. |\n| %f | Microseconds 6 digits. |\n| %H | Hour with 2 digits between 00-23. |\n| %h | Hour with 2 digits between 01-12. |\n| %I | Hour with 2 digits between 01-12. |\n| %i | Minute with 2 digits. |\n| %j | Day of the year (001-366) |\n| %k | Hour with 1 digits between 0-23. |\n| %l | Hour with 1 digits between 1-12. |\n| %M | Full month name in current locale (Variable lc_time_names). |\n| %m | Month with 2 digits. |\n| %p | AM/PM according to current locale (Variable lc_time_names). |\n| %r | Time in 12 hour format, followed by AM/PM. Short for ''%I:%i:%S %p''. |\n| %S | Seconds with 2 digits. |\n| %s | Seconds with 2 digits. |\n| %T | Time in 24 hour format. Short for ''%H:%i:%S''. |\n| %U | Week number (00-53), when first day of the week is Sunday. |\n| %u | Week number (00-53), when first day of the week is Monday. |\n| %V | Week number (01-53), when first day of the week is Sunday. Used with %X. |\n| %v | Week number (01-53), when first day of the week is Monday. Used with %x. |\n| %W | Full weekday name in current locale (Variable lc_time_names). |\n| %w | Day of the week. 0 = Sunday, 6 = Saturday. |\n| %X | Year with 4 digits when first day of the week is Sunday. Used with %V. |\n| %x | Year with 4 digits when first day of the week is Monday. Used with %v. |\n| %Y | Year with 4 digits. |\n| %y | Year with 2 digits. |\n| %Z | Timezone abbreviation. From MariaDB 11.3.0. |\n| %z | Numeric timezone +hhmm or -hhmm presenting the hour and minute offset from UTC. From MariaDB 11.3.0. |\n| %# | For str_to_date(), skip all numbers. |\n| %. | For str_to_date(), skip all punctation characters. |\n| %@ | For str_to_date(), skip all alpha characters. |\n| %% | A literal % character. |\n\nTo get a date in one of the standard formats, GET_FORMAT() can be used.\n\nExamples\n--------\n\nSELECT DATE_FORMAT(''2009-10-04 22:23:00'', ''%W %M %Y'');\n+------------------------------------------------+\n| DATE_FORMAT(''2009-10-04 22:23:00'', ''%W %M %Y'') |\n+------------------------------------------------+\n| Sunday October 2009 |\n+------------------------------------------------+\n\nSELECT DATE_FORMAT(''2007-10-04 22:23:00'', ''%H:%i:%s'');\n+------------------------------------------------+\n| DATE_FORMAT(''2007-10-04 22:23:00'', ''%H:%i:%s'') |\n+------------------------------------------------+\n| 22:23:00 |\n+------------------------------------------------+\n\nSELECT DATE_FORMAT(''1900-10-04 22:23:00'', ''%D %y %a %d %m %b %j'');\n+------------------------------------------------------------+\n| DATE_FORMAT(''1900-10-04 22:23:00'', ''%D %y %a %d %m %b %j'') |\n+------------------------------------------------------------+\n| 4th 00 Thu 04 10 Oct 277 |\n+------------------------------------------------------------+\n\nSELECT DATE_FORMAT(''1997-10-04 22:23:00'', ''%H %k %I %r %T %S %w'');\n+------------------------------------------------------------+\n| DATE_FORMAT(''1997-10-04 22:23:00'', ''%H %k %I %r %T %S %w'') |\n+------------------------------------------------------------+\n| 22 22 10 10:23:00 PM 22:23:00 00 6 |\n+------------------------------------------------------------+\n\nSELECT DATE_FORMAT(''1999-01-01'', ''%X %V'');\n+------------------------------------+\n| DATE_FORMAT(''1999-01-01'', ''%X %V'') |\n+------------------------------------+\n| 1998 52 |\n+------------------------------------+\n\nSELECT DATE_FORMAT(''2006-06-00'', ''%d'');\n+---------------------------------+\n| DATE_FORMAT(''2006-06-00'', ''%d'') |\n+---------------------------------+\n| 00 |\n+---------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/date_format', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/date_format'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (180, 31, 'DATE\\_SUB', 'Syntax\n------\n\nDATE_SUB(date,INTERVAL expr unit)\n\nDescription\n-----------\n\nPerforms date arithmetic. The _date_ argument specifies the starting date or datetime value. _expr_ is an expression specifying the interval value to be subtracted from the starting date. _expr_ is a string; it may start with a "-" for negative intervals. _unit_ is a keyword indicating the units in which the expression should be interpreted. See Date and Time Units for a complete list of permitted units.\n\nSee also DATE_ADD().\n\nExamples\n--------\n\nSELECT DATE_SUB(''1998-01-02'', INTERVAL 31 DAY);\n+-----------------------------------------+\n| DATE_SUB(''1998-01-02'', INTERVAL 31 DAY) |\n+-----------------------------------------+\n| 1997-12-02 |\n+-----------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/date_sub', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/date_sub'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (181, 31, 'DATEDIFF', 'Syntax\n------\n\nDATEDIFF(expr1,expr2)\n\nDescription\n-----------\n\nDATEDIFF() returns (_expr1_ – _expr2_) expressed as a value in days from one date to the other. _expr1_ and _expr2_ are date or date-and-time expressions. Only the date parts of the values are used in the calculation.\n\nExamples\n--------\n\nSELECT DATEDIFF(''2007-12-31 23:59:59'',''2007-12-30'');\n+----------------------------------------------+\n| DATEDIFF(''2007-12-31 23:59:59'',''2007-12-30'') |\n+----------------------------------------------+\n| 1 |\n+----------------------------------------------+\n\nSELECT DATEDIFF(''2010-11-30 23:59:59'',''2010-12-31'');\n+----------------------------------------------+\n| DATEDIFF(''2010-11-30 23:59:59'',''2010-12-31'') |\n+----------------------------------------------+\n| -31 |\n+----------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/datediff', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/datediff'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (182, 31, 'DAY', 'Syntax\n------\n\nDAY(date)\n\nDescription\n-----------\n\nDAY() is a synonym for DAYOFMONTH().\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/day', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/day'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (183, 31, 'DAYNAME', 'Syntax\n------\n\nDAYNAME(date)\n\nDescription\n-----------\n\nReturns the name of the weekday for date. The language used for the name is controlled by the value\\\nof the lc_time_names system variable. See server locale for more on the supported locales.\n\nExamples\n--------\n\nSELECT DAYNAME(''2007-02-03'');\n+-----------------------+\n| DAYNAME(''2007-02-03'') |\n+-----------------------+\n| Saturday |\n+-----------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/dayname', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/dayname'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (184, 31, 'DAYOFMONTH', 'Syntax\n------\n\nDAYOFMONTH(date)\n\nDescription\n-----------\n\nReturns the day of the month for date, in the range 1 to 31, or 0 for dates such as ''0000-00-00'' or ''2008-00-00'' which have a zero day part.\n\nDAY() is a synonym.\n\nExamples\n--------\n\nSELECT DAYOFMONTH(''2007-02-03'');\n+--------------------------+\n| DAYOFMONTH(''2007-02-03'') |\n+--------------------------+\n| 3 |\n+--------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/dayofmonth', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/dayofmonth'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (185, 31, 'DAYOFWEEK', 'Syntax\n------\n\nDAYOFWEEK(date)\n\nDescription\n-----------\n\nReturns the day of the week index for the date (1 = Sunday, 2 = Monday, ..., 7 = Saturday). These index values correspond to the ODBC standard.\n\nThis contrasts with WEEKDAY() which follows a different index numbering (0 = Monday, 1 = Tuesday, ... 6 = Sunday).\n\nExamples\n--------\n\nSELECT DAYOFWEEK(''2007-02-03'');\n+-------------------------+\n| DAYOFWEEK(''2007-02-03'') |\n+-------------------------+\n| 7 |\n+-------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/dayofweek', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/dayofweek'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (186, 31, 'DAYOFYEAR', 'Syntax\n------\n\nDAYOFYEAR(date)\n\nDescription\n-----------\n\nReturns the day of the year for date, in the range 1 to 366.\n\nExamples\n--------\n\nSELECT DAYOFYEAR(''2018-02-16'');\n+-------------------------+\n| DAYOFYEAR(''2018-02-16'') |\n+-------------------------+\n| 47 |\n+-------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/dayofyear', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/dayofyear'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (187, 31, 'EXTRACT', 'Syntax\n------\n\nEXTRACT(unit FROM date)\n\nDescription\n-----------\n\nThe EXTRACT() function extracts the required unit from the date. See Date and Time Units for a complete list of permitted units.\n\nHOUR() is not a standard SQL function, so continues to adhere to the old behavior inherited from MySQL.\n\nExamples\n--------\n\nSELECT EXTRACT(YEAR FROM ''2009-07-02'');\n+---------------------------------+\n| EXTRACT(YEAR FROM ''2009-07-02'') |\n+---------------------------------+\n| 2009 |\n+---------------------------------+\n\nSELECT EXTRACT(YEAR_MONTH FROM ''2009-07-02 01:02:03'');\n+------------------------------------------------+\n| EXTRACT(YEAR_MONTH FROM ''2009-07-02 01:02:03'') |\n+------------------------------------------------+\n| 200907 |\n+------------------------------------------------+\n\nSELECT EXTRACT(DAY_MINUTE FROM ''2009-07-02 01:02:03'');\n+------------------------------------------------+\n| EXTRACT(DAY_MINUTE FROM ''2009-07-02 01:02:03'') |\n+------------------------------------------------+\n| 20102 |\n+------------------------------------------------+\n\nSELECT EXTRACT(MICROSECOND FROM ''2003-01-02 10:30:00.000123'');\n+--------------------------------------------------------+\n| EXTRACT(MICROSECOND FROM ''2003-01-02 10:30:00.000123'') |\n+--------------------------------------------------------+\n| 123 |\n+--------------------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/extract', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/extract'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (188, 31, 'FORMAT\\_PICO\\_TIME', 'Syntax\n------\n\nFORMAT_PICO_TIME(time_val)\n\nDescription\n-----------\n\nGiven a time in picoseconds, returns a human-readable time value and unit indicator. Resulting unit is dependent on the length of the argument, and can be:\n\n ps - picoseconds\n ns - nanoseconds\n us - microseconds\n ms - milliseconds\n s - seconds\n min - minutes\n h - hours\n d - days\n\nWith the exception of results under one nanosecond, which are not rounded and are represented as whole numbers, the result is rounded to 2 decimal places, with a minimum of 3 significant digits.\n\nReturns NULL if the argument is NULL.\n\nThis function is very similar to the Sys Schema FORMAT_TIME function, but with the following differences:\n\n Represents minutes as min rather than m.\n Does not represent weeks.\n\nExamples\n--------\n\nSELECT\n FORMAT_PICO_TIME(43) AS ps,\n FORMAT_PICO_TIME(4321) AS ns, \n FORMAT_PICO_TIME(43211234) AS us,\n FORMAT_PICO_TIME(432112344321) AS ms,\n FORMAT_PICO_TIME(43211234432123) AS s,\n FORMAT_PICO_TIME(432112344321234) AS m,\n FORMAT_PICO_TIME(4321123443212345) AS h,\n FORMAT_PICO_TIME(432112344321234545) AS d;\n+--------+---------+----------+-----------+---------+----------+--------+--------+\n| ps | ns | us | ms | s | m | h | d |\n+--------+---------+----------+-----------+---------+----------+--------+--------+\n| 43 ps | 4.32 ns | 43.21 us | 432.11 ms | 43.21 s | 7.20 min | 1.20 h | 5.00 d |\n+--------+---------+----------+-----------+---------+----------+--------+--------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/format_pico_time', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/format_pico_time'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (189, 31, 'FROM\\_DAYS', 'Syntax\n------\n\nFROM_DAYS(N)\n\nDescription\n-----------\n\nGiven a day number N, returns a DATE value. The day count is based on the number of days from the start of the standard calendar (0000-00-00).\n\nThe function is not designed for use with dates before the advent of the Gregorian calendar in October 1582. Results will not be reliable since it doesn''t account for the lost days when the calendar changed from the Julian calendar.\n\nThis is the converse of the TO_DAYS() function.\n\nExamples\n--------\n\nSELECT FROM_DAYS(730669);\n+-------------------+\n| FROM_DAYS(730669) |\n+-------------------+\n| 2000-07-03 |\n+-------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/from_days', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/from_days'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (190, 31, 'FROM\\_UNIXTIME', 'Syntax\n------\n\nFROM_UNIXTIME(unix_timestamp)\nFROM_UNIXTIME(unix_timestamp,format)\n\nDescription\n-----------\n\nConverts the number of seconds from the epoch (1970-01-01 00:00:00 UTC) to aTIMESTAMP value, the opposite of what UNIX_TIMESTAMP() is doing. Returns NULL if the result would be outside of the valid range of TIMESTAMP values.\n\nIf format is given, the result is exactly equivalent to\n\n``sql\nDATE_FORMAT(FROM_UNIXTIME(unix_timestamp), format)\n`\n\nTimestamps in MariaDB have a maximum value of 4294967295, equivalent to 2106-02-07 06:28:15. This is due to the underlying 32-bit limitation. Using the function on a timestamp beyond this will result in NULL being returned. Use DATETIME as a storage type if you require dates beyond this.\n\nThe one-argument form of FROM_UNIXTIME() returns aDATETIME. This means that it can return values outside of valid TIMESTAMP range, in particular 1970-01-01 00:00:00. And it can return the same result for different values of unix_timestamp (around DST changes).\n\nTimestamps in MariaDB have a maximum value of 4294967295, equivalent to 2106-02-07 06:28:15. This is due to the underlying 32-bit limitation. Using the function on a timestamp beyond this will result in NULL being returned. Use DATETIME as a storage type if you require dates beyond this.\n\nThe one-argument form of FROM_UNIXTIME() returns aDATETIME. This means that it can return values outside of valid TIMESTAMP range, in particular 1970-01-01 00:00:00. And it can return the same result for different values of unix_timestamp (around DST changes).\n\nThe maximum value is 2147483647, equivalent to 2038-01-19 05:14:07.\n\nThe following options can be used by FROM_UNIXTIME(), as well as DATE_FORMAT() and STR_TO_DATE():\n\n| Option | Description |\n| ------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| %a | Short weekday name in current locale (Variable lc_time_names). |\n| %b | Short form month name in current locale. For locale en_US this is one of: Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov or Dec. |\n| %c | Month with 1 or 2 digits. |\n| %D | Day with English suffix ''th'', ''nd'', ''st'' or ''rd''''. (1st, 2nd, 3rd...). |\n| %d | Day with 2 digits. |\n| %e | Day with 1 or 2 digits. |\n| %f | Microseconds 6 digits. |\n| %H | Hour with 2 digits between 00-23. |\n| %h | Hour with 2 digits between 01-12. |\n| %I | Hour with 2 digits between 01-12. |\n| %i | Minute with 2 digits. |\n| %j | Day of the year (001-366) |\n| %k | Hour with 1 digits between 0-23. |\n| %l | Hour with 1 digits between 1-12. |\n| %M | Full month name in current locale (Variable lc_time_names). |\n| %m | Month with 2 digits. |\n| %p | AM/PM according to current locale (Variable lc_time_names). |\n| %r | Time in 12 hour format, followed by AM/PM. Short for ''%I:%i:%S %p''. |\n| %S | Seconds with 2 digits. |\n| %s | Seconds with 2 digits. |\n| %T | Time in 24 hour format. Short for ''%H:%i:%S''. |\n| %U | Week number (00-53), when first day of the week is Sunday. |\n| %u | Week number (00-53), when first day of the week is Monday. |\n| %V | Week number (01-53), when first day of the week is Sunday. Used with %X. |\n| %v | Week number (01-53), when first day of the week is Monday. Used with %x. |\n| %W | Full weekday name in current locale (Variable lc_time_names). |\n| %w | Day of the week. 0 = Sunday, 6 = Saturday. |\n| %X | Year with 4 digits when first day of the week is Sunday. Used with %V. |\n| %x | Year with 4 digits when first day of the week is Sunday. Used with %v. |\n| %Y | Year with 4 digits. |\n| %y | Year with 2 digits. |\n| %# | For str_to_date(), skip all numbers. |\n| %. | For str_to_date(), skip all punctation characters. |\n| %@ | For str_to_date(), skip all alpha characters. |\n| %% | A literal % character. |\n\nPerformance Considerations\n\nIf your session time zone is set to SYSTEM (the default), FROM_UNIXTIME() will call the OS function to convert the data using the system time zone. At least on Linux, the corresponding function (localtime_r`) uses a global mutex inside glibc that can cause contention under high concurrent load.\n\nSet your time zone to a named time zone to avoid this issue. See mysql time zone tables for details on how to do this.\n\nExamples\n--------\n\nSELECT FROM_UNIXTIME(1196440219);\n+---------------------------+\n| FROM_UNIXTIME(1196440219) |\n+---------------------------+\n| 2007-11-30 11:30:19 |\n+---------------------------+\n\nSELECT FROM_UNIXTIME(1196440219) + 0;\n+-------------------------------+\n| FROM_UNIXTIME(1196440219) + 0 |\n+-------------------------------+\n| 20071130113019.000000 |\n+-------------------------------+\n\nSELECT FROM_UNIXTIME(UNIX_TIMESTAMP(), ''%Y %D %M %h:%i:%s %x'');\n+---------------------------------------------------------+\n| FROM_UNIXTIME(UNIX_TIMESTAMP(), ''%Y %D %M %h:%i:%s %x'') |\n+---------------------------------------------------------+\n| 2010 27th March 01:03:47 2010 |\n+---------------------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/from_unixtime', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/from_unixtime'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (191, 31, 'GET\\_FORMAT', 'Syntax\n------\n\nGET_FORMAT({DATE|DATETIME|TIME}, {''EUR''|''USA''|''JIS''|''ISO''|''INTERNAL''})\n\nDescription\n-----------\n\nReturns a format string. This function is useful in combination with the DATE_FORMAT() and the STR_TO_DATE() functions.\n\nPossible result formats are:\n\n| Function Call | Result Format |\n| -------------------------------- | ------------------- |\n| GET_FORMAT(DATE,''EUR'') | ''%d.%m.%Y'' |\n| GET_FORMAT(DATE,''USA'') | ''%m.%d.%Y'' |\n| GET_FORMAT(DATE,''JIS'') | ''%Y-%m-%d'' |\n| GET_FORMAT(DATE,''ISO'') | ''%Y-%m-%d'' |\n| GET_FORMAT(DATE,''INTERNAL'') | ''%Y%m%d'' |\n| GET_FORMAT(DATETIME,''EUR'') | ''%Y-%m-%d %H.%i.%s'' |\n| GET_FORMAT(DATETIME,''USA'') | ''%Y-%m-%d %H.%i.%s'' |\n| GET_FORMAT(DATETIME,''JIS'') | ''%Y-%m-%d %H:%i:%s'' |\n| GET_FORMAT(DATETIME,''ISO'') | ''%Y-%m-%d %H:%i:%s'' |\n| GET_FORMAT(DATETIME,''INTERNAL'') | ''%Y%m%d%H%i%s'' |\n| GET_FORMAT(TIME,''EUR'') | ''%H.%i.%s'' |\n| GET_FORMAT(TIME,''USA'') | ''%h:%i:%s %p'' |\n| GET_FORMAT(TIME,''JIS'') | ''%H:%i:%s'' |\n| GET_FORMAT(TIME,''ISO'') | ''%H:%i:%s'' |\n| GET_FORMAT(TIME,''INTERNAL'') | ''%H%i%s'' |\n\nExamples\n--------\n\nSELECT GET_FORMAT(DATE, ''EUR'');\n+-------------------------+\n| GET_FORMAT(DATE, ''EUR'') |\n+-------------------------+\n| %d.%m.%Y |\n+-------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/get_format', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/get_format'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (192, 31, 'HOUR', 'Description\n-----------\n\nReturns the hour for time. The range of the return value is 0 to 23 for time-of-day values. However, the range of TIME values actually is much larger, so HOUR can return values greater than 23.\n\nThe return value is always positive, even if a negative TIME value is provided.\n\nExamples\n--------\n\nSELECT HOUR(''10:05:03'');\n+------------------+\n| HOUR(''10:05:03'') |\n+------------------+\n| 10 |\n+------------------+\n\nSELECT HOUR(''272:59:59'');\n+-------------------+\n| HOUR(''272:59:59'') |\n+-------------------+\n| 272 |\n+-------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/hour', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/hour'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (193, 31, 'LAST\\_DAY', 'Syntax\n------\n\nLAST_DAY(date)\n\nDescription\n-----------\n\nTakes a date or datetime value and returns the corresponding value for the last day of the month. Returns NULL if the argument is invalid.\n\nExamples\n--------\n\nSELECT LAST_DAY(''2003-02-05'');\n+------------------------+\n| LAST_DAY(''2003-02-05'') |\n+------------------------+\n| 2003-02-28 |\n+------------------------+\n\nSELECT LAST_DAY(''2004-02-05'');\n+------------------------+\n| LAST_DAY(''2004-02-05'') |\n+------------------------+\n| 2004-02-29 |\n+------------------------+\n\nSELECT LAST_DAY(''2004-01-01 01:01:01'');\n+---------------------------------+\n| LAST_DAY(''2004-01-01 01:01:01'') |\n+---------------------------------+\n| 2004-01-31 |\n+---------------------------------+\n\nSELECT LAST_DAY(''2003-03-32'');\n+------------------------+\n| LAST_DAY(''2003-03-32'') |\n+------------------------+\n| NULL |\n+------------------------+\n1 row in set, 1 warning (0.00 sec)\n\nWarning (Code 1292): Incorrect datetime value: ''2003-03-32''\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/last_day', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/last_day'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (194, 31, 'LOCALTIME', 'Syntax\n------\n\nLOCALTIME\nLOCALTIME([precision])\n\nDescription\n-----------\n\nLOCALTIME and LOCALTIME() are synonyms for NOW().\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/localtime', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/localtime'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (195, 31, 'LOCALTIMESTAMP', 'Syntax\n------\n\nLOCALTIMESTAMP\nLOCALTIMESTAMP([precision])\n\nDescription\n-----------\n\nLOCALTIMESTAMP and LOCALTIMESTAMP() are synonyms for NOW().\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/localtimestamp', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/localtimestamp'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (196, 31, 'MAKEDATE', 'Syntax\n------\n\nMAKEDATE(year,dayofyear)\n\nDescription\n-----------\n\nReturns a date, given year and day-of-year values. dayofyear must be greater than 0 or the result is NULL.\n\nExamples\n--------\n\nSELECT MAKEDATE(2011,31), MAKEDATE(2011,32);\n+-------------------+-------------------+\n| MAKEDATE(2011,31) | MAKEDATE(2011,32) |\n+-------------------+-------------------+\n| 2011-01-31 | 2011-02-01 |\n+-------------------+-------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/makedate', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/makedate'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (197, 31, 'MAKETIME', 'Syntax\n------\n\nMAKETIME(hour,minute,second)\n\nDescription\n-----------\n\nReturns a time value calculated from the hour, minute, and second arguments.\n\nIf minute or second are out of the range 0 to 60, NULL is returned. The hour can be in the range -838 to 838, outside of which the value is truncated with a warning.\n\nExamples\n--------\n\nSELECT MAKETIME(13,57,33);\n+--------------------+\n| MAKETIME(13,57,33) |\n+--------------------+\n| 13:57:33 |\n+--------------------+\n\nSELECT MAKETIME(-13,57,33);\n+---------------------+\n| MAKETIME(-13,57,33) |\n+---------------------+\n| -13:57:33 |\n+---------------------+\n\nSELECT MAKETIME(13,67,33);\n+--------------------+\n| MAKETIME(13,67,33) |\n+--------------------+\n| NULL |\n+--------------------+\n\nSELECT MAKETIME(-1000,57,33);\n+-----------------------+\n| MAKETIME(-1000,57,33) |\n+-----------------------+\n| -838:59:59 |\n+-----------------------+\n1 row in set, 1 warning (0.00 sec)\n\nSHOW WARNINGS;\n+---------+------+-----------------------------------------------+\n| Level | Code | Message |\n+---------+------+-----------------------------------------------+\n| Warning | 1292 | Truncated incorrect time value: ''-1000:57:33'' |\n+---------+------+-----------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/maketime', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/maketime'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (198, 31, 'MICROSECOND', 'Syntax\n------\n\nMICROSECOND(expr)\n\nDescription\n-----------\n\nReturns the microseconds from the time or datetime expression _expr_ as a number in the range from 0 to 999999.\n\nIf _expr_ is a time with no microseconds, zero is returned, while if _expr_ is a date with no time, zero with a warning is returned.\n\nExamples\n--------\n\nSELECT MICROSECOND(''12:00:00.123456'');\n+--------------------------------+\n| MICROSECOND(''12:00:00.123456'') |\n+--------------------------------+\n| 123456 |\n+--------------------------------+\n\nSELECT MICROSECOND(''2009-12-31 23:59:59.000010'');\n+-------------------------------------------+\n| MICROSECOND(''2009-12-31 23:59:59.000010'') |\n+-------------------------------------------+\n| 10 |\n+-------------------------------------------+\n\nSELECT MICROSECOND(''2013-08-07 12:13:14'');\n+------------------------------------+\n| MICROSECOND(''2013-08-07 12:13:14'') |\n+------------------------------------+\n| 0 |\n+------------------------------------+\n\nSELECT MICROSECOND(''2013-08-07'');\n+---------------------------+\n| MICROSECOND(''2013-08-07'') |\n+---------------------------+\n| 0 |\n+---------------------------+\n1 row in set, 1 warning (0.00 sec)\n\nSHOW WARNINGS;\n+---------+------+----------------------------------------------+\n| Level | Code | Message |\n+---------+------+----------------------------------------------+\n| Warning | 1292 | Truncated incorrect time value: ''2013-08-07'' |\n+---------+------+----------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/microsecond', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/microsecond'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (199, 31, 'Microseconds in MariaDB', 'Description\n-----------\n\nThe TIME, DATETIME, and TIMESTAMP types, along with the temporal functions, CAST and dynamic columns, support microseconds. The datetime precision of a column can be specified when creating the table with CREATE TABLE, for example:\n\n``sql\nCREATE TABLE example(\n col_microsec DATETIME(6),\n col_millisec TIME(3)\n);\n`\n\nGenerally, the precision can be specified for any TIME, DATETIME, or TIMESTAMP column, in parentheses, after the type name. The datetime precision specifies number of digits after the decimal dot and can be any integer number from 0 to 6. If no precision is specified it is assumed to be 0, for backward compatibility reasons.\n\nA datetime precision can be specified wherever a type name is used. For example:\n\n when declaring arguments of stored routines;\n when specifying a return type of a stored function;\n when declaring variables;\n in a CAST function.\n\n`sql\nCREATE FUNCTION example(x DATETIME(5)) RETURNS TIME(4)\nBEGIN\n DECLARE y TIMESTAMP(6);\n RETURN CAST(x AS time(2));\nEND;\n`\n\n%f is used as the formatting option for microseconds in the STR_TO_DATE, DATE_FORMAT and FROM_UNIXTIME functions, for example:\n\n`sql\nSELECT STR_TO_DATE(''20200809 020917076'',''%Y%m%d %H%i%s%f'');\n+-----------------------------------------------------+\n| STR_TO_DATE(''20200809 020917076'',''%Y%m%d %H%i%s%f'') |\n+-----------------------------------------------------+\n| 2020-08-09 02:09:17.076000 |\n+-----------------------------------------------------+\n`\n\nAdditional Information\n\n When comparing anything to a temporal value (DATETIME, TIME, DATE, or TIMESTAMP), both values are compared as temporal values, not as strings.\n The INFORMATION_SCHEMA.COLUMNS table has a new column DATETIME_PRECISION\n NOW(), CURTIME(), UTC_TIMESTAMP(), UTC_TIME(), CURRENT_TIME(), CURRENT_TIMESTAMP(), LOCALTIME() and LOCALTIMESTAMP() accept datetime precision as an optional argument. For example:\n\n`sql\nSELECT CURTIME(4);\n--> 10:11:12.3456\n`\n\n TIME_TO_SEC() and UNIX_TIMESTAMP() preserve microseconds of the argument. These functions will return a decimal number if the result non-zero datetime precision and an integer otherwise (for backward compatibility).\n\n`sql\nSELECT TIME_TO_SEC(''10:10:10.12345'');\n--> 36610.12345\n`\n\n Current versions of this patch fix a bug in the following optimization: In certain queries with DISTINCT MariaDB can ignore this clause if it can prove that all result rows are unique anyway, for example, when a primary key is compared with a constant. Sometimes this optimization was applied incorrectly, though — for example, when comparing a string with a date constant. This is now fixed.\n DATE_ADD() and DATE_SUB() functions can now take a TIME expression as an argument (not just DATETIME as before).\n\n`sql\nSELECT TIME(''10:10:10'') + INTERVAL 100 MICROSECOND;\n--> 10:10:10.000100\n`\n\n The event_time field in the mysql.general_log table and the start_time, query_time, and lock_time fields in the mysql.slow_log table now store values with microsecond precision.\n The old syntax TIMESTAMP(N), where N is the display width, is no longer supported.\n When a DATETIME value is compared to a TIME value, the latter is treated as a full datetime with a zero date part, similar to comparing DATE to a DATETIME, or to comparing DECIMAL numbers.\\\n Earlier versions of MariaDB used to compare only the time part of both operands in such a case.\n In MariaDB, an extra column TIME_MS has been added to the INFORMATION_SCHEMA.PROCESSLIST table, as well as to the output of SHOW FULL PROCESSLIST.\n\nNote: When you convert a temporal value to a value with a smaller precision, it will be truncated, not rounded. This is done to guarantee that the date part is not changed. For example:\n\n`sql\nSELECT CAST(''2009-12-31 23:59:59.998877'' AS DATETIME(3));\n-> 2009-12-31 23:59:59.998\n``\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/microseconds-in-mariadb', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/microseconds-in-mariadb'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (200, 31, 'MINUTE', 'Syntax\n------\n\nMINUTE(time)\n\nDescription\n-----------\n\nReturns the minute for _time_, in the range 0 to 59.\n\nExamples\n--------\n\nSELECT MINUTE(''2013-08-03 11:04:03'');\n+-------------------------------+\n| MINUTE(''2013-08-03 11:04:03'') |\n+-------------------------------+\n| 4 |\n+-------------------------------+\n\n SELECT MINUTE (''23:12:50'');\n+---------------------+\n| MINUTE (''23:12:50'') |\n+---------------------+\n| 12 |\n+---------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/minute', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/minute'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (201, 31, 'MONTH', 'Syntax\n------\n\nMONTH(date)\n\nDescription\n-----------\n\nReturns the month for date in the range 1 to 12 for January to December, or 0 for dates such as 0000-00-00 or 2008-00-00 that have a zero month part.\n\nExamples\n--------\n\nSELECT MONTH(''2019-01-03'');\n+---------------------+\n| MONTH(''2019-01-03'') |\n+---------------------+\n| 1 |\n+---------------------+\n\nSELECT MONTH(''2019-00-03'');\n+---------------------+\n| MONTH(''2019-00-03'') |\n+---------------------+\n| 0 |\n+---------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/month', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/month'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (202, 31, 'MONTHNAME', 'Syntax\n------\n\nMONTHNAME(date)\n\nDescription\n-----------\n\nReturns the full name of the month for date. The language used for the name is controlled by the value of the lc_time_names system variable. See server locale for more on the supported locales.\n\nExamples\n--------\n\nSELECT MONTHNAME(''2019-02-03'');\n+-------------------------+\n| MONTHNAME(''2019-02-03'') |\n+-------------------------+\n| February |\n+-------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/monthname', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/monthname'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (203, 31, 'MONTHS\\_BETWEEN', 'Description\n-----------\n\nMONTHS_BETWEEN returns the number of months between dates two dates. If the first date given is later than the second date, the result is positive; otherwise, the result is negative. If both dates are the same days of the month, or both are last days of months, the result is always an integer. Otherwise, the fractional portion of the result based on a 31-day month is calculated, and considered the difference in time components between the dates.\n\nThe following example calculates the months between two dates:\n\n``sql\nSELECT MONTHS_BETWEEN\n (TO_DATE(''02-02-1995'',''MM-DD-YYYY''),\n TO_DATE(''01-01-1995'',''MM-DD-YYYY'') \n );\n`\n\nThe result is 1.03225806`.\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/months_between', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/months_between'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (204, 31, 'NOW', 'Syntax\n------\n\nNOW([precision])\nCURRENT_TIMESTAMP\nCURRENT_TIMESTAMP([precision])\nLOCALTIME, LOCALTIME([precision])\nLOCALTIMESTAMP\nLOCALTIMESTAMP([precision])\n\nDescription\n-----------\n\nReturns the current date and time as a value in YYYY-MM-DD HH:MM:SS or YYYYMMDDHHMMSS.uuuuuu format, depending on whether the function is used in a string or numeric context. The value is expressed in the current time zone.\n\nMariaDB starting with 11.7\n\nThese functions return SQL standard compliant types:\n\n NOW() and CURRENT_TIMESTAMP() return a TIMESTAMP value (analogous to the standard type TIMESTAMP WITH LOCAL TIME ZONE) which corresponds to the current point in time and is unambiguous around DST changes.\n LOCALTIMESTAMP returns a DATETIME value (analogous to the standard type TIMESTAMP WITHOUT TIME ZONE). Storing its result in a TIMESTAMP column can result in a data loss around DST changes.\n\nThese functions do not return SQL standard compliant types:\n\n NOW()\n CURRENT_TIMESTAMP()\n* LOCALTIMESTAMP\n\nThe optional _precision_ determines the microsecond precision. See Microseconds in MariaDB.\n\nNOW() (or its synonyms) can be used as the default value for TIMESTAMP columns as well as.\n\nWhen displayed in the INFORMATION_SCHEMA.COLUMNS table, a default CURRENT TIMESTAMP is displayed as current_timestamp() .\n\nChanging the timestamp system variable with a SET timestamp statement affects the value returned by NOW(), but not by SYSDATE().\n\nExamples\n--------\n\nSELECT NOW();\n+---------------------+\n| NOW() |\n+---------------------+\n| 2010-03-27 13:13:25 |\n+---------------------+\n\nSELECT NOW() + 0;\n+-----------------------+\n| NOW() + 0 |\n+-----------------------+\n| 20100327131329.000000 |\n+-----------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/now', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/now'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (205, 31, 'PERIOD\\_ADD', 'Syntax\n------\n\nPERIOD_ADD(P,N)\n\nDescription\n-----------\n\nAdds N months to period P. P is in the format YYMM or YYYYMM, and is not a date value. If P contains a two-digit year, values from 00 to 69 are converted to from 2000 to 2069, while values from 70 are converted to 1970 upwards.\n\nReturns a value in the format YYYYMM.\n\nExamples\n--------\n\nSELECT PERIOD_ADD(200801,2);\n+----------------------+\n| PERIOD_ADD(200801,2) |\n+----------------------+\n| 200803 |\n+----------------------+\n\nSELECT PERIOD_ADD(6910,2);\n+--------------------+\n| PERIOD_ADD(6910,2) |\n+--------------------+\n| 206912 |\n+--------------------+\n\nSELECT PERIOD_ADD(7010,2);\n+--------------------+\n| PERIOD_ADD(7010,2) |\n+--------------------+\n| 197012 |\n+--------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/period_add', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/period_add'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (206, 31, 'PERIOD\\_DIFF', 'Syntax\n------\n\nPERIOD_DIFF(P1,P2)\n\nDescription\n-----------\n\nReturns the number of months between periods P1 and P2. P1 and P2 can be in the format YYMM or YYYYMM, and are not date values.\n\nIf P1 or P2 contains a two-digit year, values from 00 to 69 are converted to from 2000 to 2069, while values from 70 are converted to 1970 upwards.\n\nExamples\n--------\n\nSELECT PERIOD_DIFF(200802,200703);\n+----------------------------+\n| PERIOD_DIFF(200802,200703) |\n+----------------------------+\n| 11 |\n+----------------------------+\n\nSELECT PERIOD_DIFF(6902,6803);\n+------------------------+\n| PERIOD_DIFF(6902,6803) |\n+------------------------+\n| 11 |\n+------------------------+\n\nSELECT PERIOD_DIFF(7002,6803);\n+------------------------+\n| PERIOD_DIFF(7002,6803) |\n+------------------------+\n| -1177 |\n+------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/period_diff', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/period_diff'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (207, 31, 'QUARTER', 'Syntax\n------\n\nQUARTER(date)\n\nDescription\n-----------\n\nReturns the quarter of the year for date, in the range 1 to 4. Returns 0 if month contains a zero value, or NULL if the given value is not otherwise a valid date (zero values are accepted).\n\nExamples\n--------\n\nSELECT QUARTER(''2008-04-01'');\n+-----------------------+\n| QUARTER(''2008-04-01'') |\n+-----------------------+\n| 2 |\n+-----------------------+\n\nSELECT QUARTER(''2019-00-01'');\n+-----------------------+\n| QUARTER(''2019-00-01'') |\n+-----------------------+\n| 0 |\n+-----------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/quarter', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/quarter'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (208, 31, 'SEC\\_TO\\_TIME', 'Syntax\n------\n\nSEC_TO_TIME(seconds)\n\nDescription\n-----------\n\nReturns the seconds argument, converted to hours, minutes, and seconds, as a TIME value. The range of the result is constrained to that of the TIME data type. A warning occurs if the argument corresponds to a value outside that range.\n\nThe time will be returned in the format hh:mm:ss, or hhmmss if used in a numeric calculation.\n\nExamples\n--------\n\nSELECT SEC_TO_TIME(12414);\n+--------------------+\n| SEC_TO_TIME(12414) |\n+--------------------+\n| 03:26:54 |\n+--------------------+\n\nSELECT SEC_TO_TIME(12414)+0;\n+----------------------+\n| SEC_TO_TIME(12414)+0 |\n+----------------------+\n| 32654 |\n+----------------------+\n\nSELECT SEC_TO_TIME(9999999);\n+----------------------+\n| SEC_TO_TIME(9999999) |\n+----------------------+\n| 838:59:59 |\n+----------------------+\n1 row in set, 1 warning (0.00 sec)\n\nSHOW WARNINGS;\n+---------+------+-------------------------------------------+\n| Level | Code | Message |\n+---------+------+-------------------------------------------+\n| Warning | 1292 | Truncated incorrect time value: ''9999999'' |\n+---------+------+-------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/sec_to_time', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/sec_to_time'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (209, 31, 'SECOND', 'Syntax\n------\n\nSECOND(time)\n\nDescription\n-----------\n\nReturns the second for a given time (which can include microseconds), in the range 0 to 59, or NULL if not given a valid time value.\n\nExamples\n--------\n\nSELECT SECOND(''10:05:03'');\n+--------------------+\n| SECOND(''10:05:03'') |\n+--------------------+\n| 3 |\n+--------------------+\n\nSELECT SECOND(''10:05:01.999999'');\n+---------------------------+\n| SECOND(''10:05:01.999999'') |\n+---------------------------+\n| 1 |\n+---------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/second', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/second'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (210, 31, 'STR\\_TO\\_DATE', 'Syntax\n------\n\nSTR_TO_DATE(str,format)\n\nDescription\n-----------\n\nThis is the inverse of the DATE_FORMAT() function. It takes a string str and a format string format. STR_TO_DATE() returns aDATETIME value if the format string contains both date and time parts, or aDATE or TIME value if the string contains only date or time parts.\n\nThe date, time, or datetime values contained in str should be given in the format indicated by format. If str contains an illegal date, time, or datetime value, STR_TO_DATE() returns NULL. An illegal value also produces a warning.\n\nUnder specific SQL_MODE settings an error may also be generated if the str isn''t a valid date:\n\n ALLOW_INVALID_DATES\n NO_ZERO_DATE\n* NO_ZERO_IN_DATE\n\nThe options that can be used by STR_TO_DATE(), as well as its inverse DATE_FORMAT() and the FROM_UNIXTIME() function, are:\n\n| Option | Description |\n| ------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| %a | Short weekday name in current locale (Variable lc_time_names). |\n| %b | Short form month name in current locale. For locale en_US this is one of: Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov or Dec. |\n| %c | Month with 1 or 2 digits. |\n| %D | Day with English suffix ''th'', ''nd'', ''st'' or ''rd''''. (1st, 2nd, 3rd...). |\n| %d | Day with 2 digits. |\n| %e | Day with 1 or 2 digits. |\n| %f | Microseconds 6 digits. |\n| %H | Hour with 2 digits between 00-23. |\n| %h | Hour with 2 digits between 01-12. |\n| %I | Hour with 2 digits between 01-12. |\n| %i | Minute with 2 digits. |\n| %j | Day of the year (001-366) |\n| %k | Hour with 1 digits between 0-23. |\n| %l | Hour with 1 digits between 1-12. |\n| %M | Full month name in current locale (Variable lc_time_names). |\n| %m | Month with 2 digits. |\n| %p | AM/PM according to current locale (Variable lc_time_names). |\n| %r | Time in 12 hour format, followed by AM/PM. Short for ''%I:%i:%S %p''. |\n| %S | Seconds with 2 digits. |\n| %s | Seconds with 2 digits. |\n| %T | Time in 24 hour format. Short for ''%H:%i:%S''. |\n| %U | Week number (00-53), when first day of the week is Sunday. |\n| %u | Week number (00-53), when first day of the week is Monday. |\n| %V | Week number (01-53), when first day of the week is Sunday. Used with %X. |\n| %v | Week number (01-53), when first day of the week is Monday. Used with %x. |\n| %W | Full weekday name in current locale (Variable lc_time_names). |\n| %w | Day of the week. 0 = Sunday, 6 = Saturday. |\n| %X | Year with 4 digits when first day of the week is Sunday. Used with %V. |\n| %x | Year with 4 digits when first day of the week is Monday. Used with %v. |\n| %Y | Year with 4 digits. |\n| %y | Year with 2 digits. |\n| %# | For str_to_date(), skip all numbers. |\n| %. | For str_to_date(), skip all punctation characters. |\n| %@ | For str_to_date(), skip all alpha characters. |\n| %% | A literal % character. |\n\nExamples\n--------\n\nSELECT STR_TO_DATE(''Wednesday, June 2, 2014'', ''%W, %M %e, %Y'');\n+---------------------------------------------------------+\n| STR_TO_DATE(''Wednesday, June 2, 2014'', ''%W, %M %e, %Y'') |\n+---------------------------------------------------------+\n| 2014-06-02 |\n+---------------------------------------------------------+\n\nSELECT STR_TO_DATE(''Wednesday23423, June 2, 2014'', ''%W, %M %e, %Y'');\n+--------------------------------------------------------------+\n| STR_TO_DATE(''Wednesday23423, June 2, 2014'', ''%W, %M %e, %Y'') |\n+--------------------------------------------------------------+\n| NULL |\n+--------------------------------------------------------------+\n1 row in set, 1 warning (0.00 sec)\n\nSHOW WARNINGS;\n+---------+------+-----------------------------------------------------------------------------------+\n| Level | Code | Message |\n+---------+------+-----------------------------------------------------------------------------------+\n| Warning | 1411 | Incorrect datetime value: ''Wednesday23423, June 2, 2014'' for function str_to_date |\n+---------+------+-----------------------------------------------------------------------------------+\n\nSELECT STR_TO_DATE(''Wednesday23423, June 2, 2014'', ''%W%#, %M %e, %Y'');\n+----------------------------------------------------------------+\n| STR_TO_DATE(''Wednesday23423, June 2, 2014'', ''%W%#, %M %e, %Y'') |\n+----------------------------------------------------------------+\n| 2014-06-02 |\n+----------------------------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/str_to_date', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/str_to_date'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (211, 31, 'SUBDATE', 'Syntax\n------\n\nSUBDATE(date,INTERVAL expr unit), SUBDATE(expr,days)\n\nDescription\n-----------\n\nWhen invoked with the INTERVAL form of the second argument, SUBDATE() is a synonym for DATE_SUB(). See Date and Time Units for a complete list of permitted units.\n\nThe second form allows the use of an integer value for days. In such cases, it is interpreted as the number of days to be subtracted from the date or datetime expression expr.\n\nExamples\n--------\n\nSELECT DATE_SUB(''2008-01-02'', INTERVAL 31 DAY);\n+-----------------------------------------+\n| DATE_SUB(''2008-01-02'', INTERVAL 31 DAY) |\n+-----------------------------------------+\n| 2007-12-02 |\n+-----------------------------------------+\n\nSELECT SUBDATE(''2008-01-02'', INTERVAL 31 DAY);\n+----------------------------------------+\n| SUBDATE(''2008-01-02'', INTERVAL 31 DAY) |\n+----------------------------------------+\n| 2007-12-02 |\n+----------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/subdate', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/subdate'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (212, 31, 'SUBTIME', 'Syntax\n------\n\nSUBTIME(expr1,expr2)\n\nDescription\n-----------\n\nSUBTIME() returns expr1 - expr2 expressed as a value in the same format as expr1. expr1 is a time or datetime expression, and expr2 is a time expression.\n\nExamples\n--------\n\nSELECT SUBTIME(''2007-12-31 23:59:59.999999'',''1 1:1:1.000002'');\n+--------------------------------------------------------+\n| SUBTIME(''2007-12-31 23:59:59.999999'',''1 1:1:1.000002'') |\n+--------------------------------------------------------+\n| 2007-12-30 22:58:58.999997 |\n+--------------------------------------------------------+\n\nSELECT SUBTIME(''01:00:00.999999'', ''02:00:00.999998'');\n+-----------------------------------------------+\n| SUBTIME(''01:00:00.999999'', ''02:00:00.999998'') |\n+-----------------------------------------------+\n| -00:59:59.999999 |\n+-----------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/subtime', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/subtime'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (213, 31, 'SYSDATE', 'Syntax\n------\n\nSYSDATE([precision])\n\nDescription\n-----------\n\nReturns the current date and time as a value in YYYY-MM-DD HH:MM:SS or YYYYMMDDHHMMSS.uuuuuu format, depending on whether the function is used in a string or numeric context.\n\nThe optional _precision_ determines the microsecond precision. See Microseconds in MariaDB.\n\nSYSDATE() returns the time at which it executes. This differs from the behavior for NOW(), which returns a constant time that indicates the time at which the statement began to execute. (Within a stored routine or trigger, NOW() returns the time at which the routine or triggering statement began to execute.)\n\nIn addition, changing the timestamp system variable with a SET timestamp statement affects the value returned by NOW() but not by SYSDATE(). This means that timestamp settings in the binary log have no effect on invocations of SYSDATE().\n\nBecause SYSDATE() can return different values even within the same statement, and is not affected by SET TIMESTAMP, it is non-deterministic and therefore unsafe for replication if statement-based binary logging is used. If that is a problem, you can use row-based logging, or start the server with the --sysdate-is-now mariadbd option to cause SYSDATE() to be an alias for NOW(). The non-deterministic nature of SYSDATE() also means that indexes cannot be used for evaluating expressions that refer to it, and that statements using the SYSDATE() function are unsafe for statement-based replication.\n\nExamples\n--------\n\nSELECT NOW(), SLEEP(2), NOW();\n+---------------------+----------+---------------------+\n| NOW() | SLEEP(2) | NOW() |\n+---------------------+----------+---------------------+\n| 2010-03-27 13:23:40 | 0 | 2010-03-27 13:23:40 |\n+---------------------+----------+---------------------+\n\nSELECT SYSDATE(), SLEEP(2), SYSDATE();\n+---------------------+----------+---------------------+\n| SYSDATE() | SLEEP(2) | SYSDATE() |\n+---------------------+----------+---------------------+\n| 2010-03-27 13:23:52 | 0 | 2010-03-27 13:23:54 |\n+---------------------+----------+---------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/sysdate', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/sysdate'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (214, 31, 'TIME\\_FORMAT', 'Syntax\n------\n\nTIME_FORMAT(time,format)\n\nDescription\n-----------\n\nThis is used like the DATE_FORMAT() function, but the format string may contain format specifiers only for hours, minutes, and seconds. Other specifiers produce a NULL value or 0.\n\nExamples\n--------\n\nSELECT TIME_FORMAT(''100:00:00'', ''%H %k %h %I %l'');\n+--------------------------------------------+\n| TIME_FORMAT(''100:00:00'', ''%H %k %h %I %l'') |\n+--------------------------------------------+\n| 100 100 04 04 4 |\n+--------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/time_format', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/time_format'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (215, 31, 'TIME\\_TO\\_SEC', 'Syntax\n------\n\nTIME_TO_SEC(time)\n\nDescription\n-----------\n\nReturns the time argument, converted to seconds.\n\nThe value returned by TIME_TO_SEC is of type DOUBLE. The returned value preserves microseconds of the argument. See also Microseconds in MariaDB.\n\nExamples\n--------\n\nSELECT TIME_TO_SEC(''22:23:00'');\n+-------------------------+\n| TIME_TO_SEC(''22:23:00'') |\n+-------------------------+\n| 80580 |\n+-------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/time_to_sec', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/time_to_sec'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (216, 31, 'TIMEDIFF', 'Syntax\n------\n\nTIMEDIFF(expr1,expr2)\n\nDescription\n-----------\n\nTIMEDIFF() returns expr1 - expr2 expressed as a time value. expr1 andexpr2 are time or date-and-time expressions, but both must be of the\\\nsame type.\n\nExamples\n--------\n\nSELECT TIMEDIFF(''2000:01:01 00:00:00'', ''2000:01:01 00:00:00.000001'');\n+---------------------------------------------------------------+\n| TIMEDIFF(''2000:01:01 00:00:00'', ''2000:01:01 00:00:00.000001'') |\n+---------------------------------------------------------------+\n| -00:00:00.000001 |\n+---------------------------------------------------------------+\n\nSELECT TIMEDIFF(''2008-12-31 23:59:59.000001'', ''2008-12-30 01:01:01.000002'');\n+----------------------------------------------------------------------+\n| TIMEDIFF(''2008-12-31 23:59:59.000001'', ''2008-12-30 01:01:01.000002'') |\n+----------------------------------------------------------------------+\n| 46:58:57.999999 |\n+----------------------------------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/timediff', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/timediff'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (217, 31, 'TIMESTAMPADD', 'Syntax\n------\n\nTIMESTAMPADD(unit,interval,datetime_expr)\n\nDescription\n-----------\n\nAdds the integer expression interval to the date or datetime expression datetime_expr. The unit for interval is given by the unit argument, which should be one of the following values: MICROSECOND, SECOND, MINUTE, HOUR, DAY, WEEK, MONTH, QUARTER, or YEAR.\n\nThe unit value may be specified using one of keywords as shown, or with a prefix of SQL_TSI_. For example, DAY and SQL_TSI_DAY both are allowed.\n\nExamples\n--------\n\nSELECT TIMESTAMPADD(MINUTE,1,''2003-01-02'');\n+-------------------------------------+\n| TIMESTAMPADD(MINUTE,1,''2003-01-02'') |\n+-------------------------------------+\n| 2003-01-02 00:01:00 |\n+-------------------------------------+\n\nSELECT TIMESTAMPADD(WEEK,1,''2003-01-02'');\n+-----------------------------------+\n| TIMESTAMPADD(WEEK,1,''2003-01-02'') |\n+-----------------------------------+\n| 2003-01-09 |\n+-----------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/timestampadd', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/timestampadd'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (218, 31, 'TIMESTAMPDIFF', 'Syntax\n------\n\nTIMESTAMPDIFF(unit,datetime_expr1,datetime_expr2)\n\nDescription\n-----------\n\nReturns datetime_expr2 - datetime_expr1, where datetime_expr1 anddatetime_expr2 are date or datetime expressions. One expression may be a date and the other a datetime; a date value is treated as a datetime having the time part ''00:00:00'' where necessary. The unit for the result (an integer) is given by the unit argument. The legal values for unit are the same as those listed in the description of the TIMESTAMPADD() function, that is, MICROSECOND, SECOND, MINUTE, HOUR, DAY, WEEK, MONTH, QUARTER, or YEAR.\n\nTIMESTAMPDIFF can also be used to calculate age.\n\nExamples\n--------\n\nSELECT TIMESTAMPDIFF(MONTH,''2003-02-01'',''2003-05-01'');\n+------------------------------------------------+\n| TIMESTAMPDIFF(MONTH,''2003-02-01'',''2003-05-01'') |\n+------------------------------------------------+\n| 3 |\n+------------------------------------------------+\n\nSELECT TIMESTAMPDIFF(YEAR,''2002-05-01'',''2001-01-01'');\n+-----------------------------------------------+\n| TIMESTAMPDIFF(YEAR,''2002-05-01'',''2001-01-01'') |\n+-----------------------------------------------+\n| -1 |\n+-----------------------------------------------+\n\nSELECT TIMESTAMPDIFF(MINUTE,''2003-02-01'',''2003-05-01 12:05:55'');\n+----------------------------------------------------------+\n| TIMESTAMPDIFF(MINUTE,''2003-02-01'',''2003-05-01 12:05:55'') |\n+----------------------------------------------------------+\n| 128885 |\n+----------------------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/timestampdiff', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/timestampdiff'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (219, 31, 'TO\\_DATE', 'Syntax\n------\n\nTO_DATE(string_expression [DEFAULT string_expression ON CONVERSION ERROR],\n format_string [,NLS_FORMAT_STRING])\n\nDescription\n-----------\n\nTO_DATE was added for Oracle support.\n\n format_string has the same format elements as TO_CHAR(), except a few elements that are not supported (see below). TO_DATE() returns a datetime value.\n The allowed separators are the same as for TO_CHAR(): space ( ), tab (\\t), and any of !, #, %, '', (, ), , +, -, ., /, :, ;, <, =, or >.\n & can be used if the next character is not a character in the a-z or A-Z range. text indicates a text string that is used verbatim in the format. You cannot use the double-quote (") as a separator.\n NLS_FORMAT_STRING supports these options: NLS_CALENDAR=GREGORIAN and NLS_DATE_LANGUAGE=_language_, where _language_ can be one of the following:\n All MariaDB short locales, like en_AU.\n The following Oracle language names: ALBANIAN, AMERICAN, ARABIC, BASQUE, BELARUSIAN, BRAZILIAN PORTUGUESE, BULGARIAN, CANADIAN FRENCH, CATALAN, CROATIAN, CYRILLIC SERBIAN, CZECH, DANISH, DUTCH, ENGLISH, ESTONIAN, FINNISH, FRENCH, GERMAN, GREEK, HEBREW, HINDI, HUNGARIAN, ICELANDIC, INDONESIAN, ITALIAN, JAPANESE, KANNADA, KOREAN, LATIN AMERICAN SPANISH, LATVIAN, LITHUANIAN, MACEDONIAN, MALAY, MEXICAN SPANISH, NORWEGIAN, POLISH, PORTUGUESE, ROMANIAN, RUSSIAN, SIMPLIFIED CHINESE, SLOVAK, SLOVENIAN, SPANISH, SWAHILI, SWEDISH, TAMIL, THAI, TRADITIONAL CHINESE, TURKISH, UKRAINIAN, VIETNAMESE\n\nSupported Format Elements\n\n AD – Anno Domini ("in the year of the Lord")\n AD_DOT – Anno Domini ("in the year of the Lord") \n AM – Meridian indicator (before midday)\n AM_DOT – Meridian indicator (before midday)\n DAY – Name of day\n DD – Day (1-31)\n DDD – Day of year (1-336)\n DY – Abbreviated name of day\n FF[1-6] – Fractional seconds\n HH – Hour (1-12)\n HH12 – Hour (1-12)\n HH24 – Hour (0-23)\n MI – Minutes (0-59)\n MM – Month (1-12)\n MON – Abbreviated name of month\n MONTH – Name of Month\n PM – Meridian indicator (after midday)\n PM_DOT – Meridian indicator (after midday)\n RR – 20th century dates in the 21st century. 2 digits in the 50-99 range are assumed starting from the year 2000, and 0-49 is assumed from 1900. \n RRRR – 20th century dates in the 21st century. 4 digits\n SS – Seconds\n SYYYY – Signed 4-digit year; MariaDB only supports positive years\n Y – 1-digit year\n YY – 2-digit year\n YYY – 3-digit year\n YYYY – 4 digit year\n\nIf no datetime is given, the current datetime is used. For example, if ''MM-DD HH-MM-SS'' is given, the current year is used. (This is Oracle behavior.)\n\nUnsupported Options\n\n BC, D, DL, DS, E, EE, FM, FX, RM, SSSSS, TS, TZD, TZH, TZR, X, and SY BC are not supported by MariaDB datetime.\n Most other formats do not make sense in a MariaDB context, as we return datetime with fractions, not as a string.\n D (day-of-week) is not supported as it is not clear how it would map to MariaDB. This element depends on the NLS territory of the session.\n RR only works with 2-digit years. (In Oracle, RR may also work with 4-digit years in some context, but the rules are not clear.)\n\nExtensions and Differences Compared to Oracle\n\n MariaDB supports FF (fractional seconds). If FF[#] is used, TO_DATE returns a datetime with # of subseconds. If FF is not used, a datetime is returned. A warning (but no error) is issued if the string contains more digits than specified with F(#].\n Names can be shortened to their unique prefixes. For example, both January and Ja work fine.\n No error is issued if the datetime string is shorter than format_string and the next unused character is not a number. This is useful to get a datetime from a mixed set of strings in datetime format. By contrast, Oracle gives an error if the datetime string is too short.\n MariaDB supports short locales as language names.\n NLS_DATE_FORMAT can use double-quote (") and single-quote ('') for quoting.\n* NLS_DATE_FORMAT must be a constant string. This is to ensure that the server knows which locale to use when executing the function.\n\nExamples\n--------\n\nSELECT TO_DATE(''February 5, 2026, 20:56'',''%Y-%m-%e'')\n+-----------------------------------------------+\n| TO_DATE(''February 5, 2026, 20:56'',''%Y-%m-%e'') |\n+-----------------------------------------------+\n| 2026-02-05 |\n+-----------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/to_date', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/to_date'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (220, 31, 'TO\\_DAYS', 'Syntax\n------\n\nTO_DAYS(date)\n\nDescription\n-----------\n\nGiven a date date, returns the number of days since the start of the current calendar (0000-00-00).\n\nThe function is not designed for use with dates before the advent of the Gregorian calendar in October 1582. Results are not reliable since it doesn''t account for the lost days when the calendar changed from the Julian calendar.\n\nThis is the converse of the FROM_DAYS() function.\n\nExamples\n--------\n\nSELECT TO_DAYS(''2007-10-07'');\n+-----------------------+\n| TO_DAYS(''2007-10-07'') |\n+-----------------------+\n| 733321 |\n+-----------------------+\n\nSELECT TO_DAYS(''0000-01-01'');\n+-----------------------+\n| TO_DAYS(''0000-01-01'') |\n+-----------------------+\n| 1 |\n+-----------------------+\n\nSELECT TO_DAYS(950501);\n+-----------------+\n| TO_DAYS(950501) |\n+-----------------+\n| 728779 |\n+-----------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/to_days', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/to_days'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (221, 31, 'TO\\_SECONDS', 'Syntax\n------\n\nTO_SECONDS(expr)\n\nDescription\n-----------\n\nReturns the number of seconds from year 0 till expr, or NULL if expr is not a valid date or datetime.\n\nExamples\n--------\n\nSELECT TO_SECONDS(''2013-06-13'');\n+--------------------------+\n| TO_SECONDS(''2013-06-13'') |\n+--------------------------+\n| 63538300800 |\n+--------------------------+\n\nSELECT TO_SECONDS(''2013-06-13 21:45:13'');\n+-----------------------------------+\n| TO_SECONDS(''2013-06-13 21:45:13'') |\n+-----------------------------------+\n| 63538379113 |\n+-----------------------------------+\n\nSELECT TO_SECONDS(NOW());\n+-------------------+\n| TO_SECONDS(NOW()) |\n+-------------------+\n| 63543530875 |\n+-------------------+\n\nSELECT TO_SECONDS(20130513);\n+----------------------+\n| TO_SECONDS(20130513) |\n+----------------------+\n| 63535622400 |\n+----------------------+\n1 row in set (0.00 sec)\n\nSELECT TO_SECONDS(130513);\n+--------------------+\n| TO_SECONDS(130513) |\n+--------------------+\n| 63535622400 |\n+--------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/to_seconds', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/to_seconds'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (222, 31, 'TRUNC', 'Syntax\n------\n\nTRUNC(date[,fmt])\n\nDescription\n-----------\n\nReturns a DATETIME truncated according to fmt.\n\nSupported formats:\n\nTruncate to day: DD, DDD, J\\\nTruncate to month: MM, MON, MONTH, RM\\\nTruncate to year: SYEAR, SYYYY, Y,YEAR, YY, YYY, YYYY\n\nExamples\n--------\n\nSELECT TRUNC(''2025-09-24 12:43'',''DD'');\n+--------------------------------+\n| TRUNC(''2025-09-24 12:43'',''DD'') |\n+--------------------------------+\n| 2025-09-24 00:00:00 |\n+--------------------------------+\n\nSELECT TRUNC(''2025-09-24 12:43'',''MM'');\n+--------------------------------+\n| TRUNC(''2025-09-24 12:43'',''MM'') |\n+--------------------------------+\n| 2025-09-01 00:00:00 |\n+--------------------------------+\n\nSELECT TRUNC(''2025-09-24 12:43'',''YY'');\n+--------------------------------+\n| TRUNC(''2025-09-24 12:43'',''YY'') |\n+--------------------------------+\n| 2025-01-01 00:00:00 |\n+--------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/trunc', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/trunc'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (223, 31, 'UNIX\\_TIMESTAMP', 'Syntax\n------\n\nUNIX_TIMESTAMP()\nUNIX_TIMESTAMP(date)\n\nDescription\n-----------\n\nIf called with no argument, returns a Unix timestamp (seconds since 1970-01-01 00:00:00 UTC) as an unsigned integer. If UNIX_TIMESTAMP() is called with a date argument, it returns the value of the argument as seconds since 1970-01-01 00:00:00 UTC. date may be a DATE string, a DATETIME string, a TIMESTAMP, or a number in the format YYMMDD or YYYYMMDD. The server interprets date as a value in the current time zone and converts it to an internal value in UTC. Clients can set their time zone as described in time zones.\n\nThe inverse function of UNIX_TIMESTAMP() is FROM_UNIXTIME()\n\nUNIX_TIMESTAMP() supports microseconds.\n\nTimestamps in MariaDB have a maximum value of 4294967295, equivalent to 2106-02-07 06:28:15. This is due to the underlying 32-bit limitation. Using the function on a timestamp beyond this will result in NULL being returned. Use DATETIME as a storage type if you require dates beyond this.\n\nTimestamps in MariaDB have a maximum value of 2147483647, equivalent to 2038-01-19 05:14:07. This is due to the underlying 32-bit limitation. Using the function on a timestamp beyond this will result in NULL being returned. Use DATETIME as a storage type if you require dates beyond this.\n\nError Handling\n\nReturns NULL for wrong arguments to UNIX_TIMESTAMP().\n\nExamples\n--------\n\nSELECT UNIX_TIMESTAMP();\n+------------------+\n| UNIX_TIMESTAMP() |\n+------------------+\n| 1269711082 |\n+------------------+\n\nSELECT UNIX_TIMESTAMP(''2007-11-30 10:30:19'');\n+---------------------------------------+\n| UNIX_TIMESTAMP(''2007-11-30 10:30:19'') |\n+---------------------------------------+\n| 1196436619.000000 |\n+---------------------------------------+\n\nSELECT UNIX_TIMESTAMP("2007-11-30 10:30:19.123456");\n+----------------------------------------------+\n| unix_timestamp("2007-11-30 10:30:19.123456") |\n+----------------------------------------------+\n| 1196411419.123456 |\n+----------------------------------------------+\n\nSELECT FROM_UNIXTIME(UNIX_TIMESTAMP(''2007-11-30 10:30:19''));\n+------------------------------------------------------+\n| FROM_UNIXTIME(UNIX_TIMESTAMP(''2007-11-30 10:30:19'')) |\n+------------------------------------------------------+\n| 2007-11-30 10:30:19.000000 |\n+------------------------------------------------------+\n\nSELECT FROM_UNIXTIME(FLOOR(UNIX_TIMESTAMP(''2007-11-30 10:30:19'')));\n+-------------------------------------------------------------+\n| FROM_UNIXTIME(FLOOR(UNIX_TIMESTAMP(''2007-11-30 10:30:19''))) |\n+-------------------------------------------------------------+\n| 2007-11-30 10:30:19 |\n+-------------------------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/unix_timestamp', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/unix_timestamp'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (224, 31, 'UTC\\_DATE', 'Syntax\n------\n\nUTC_DATE, UTC_DATE()\n\nDescription\n-----------\n\nReturns the current UTC date as a value in YYYY-MM-DD or YYYYMMDD format, depending on whether the function is used in a string or numeric context.\n\nExamples\n--------\n\nSELECT UTC_DATE(), UTC_DATE() + 0;\n+------------+----------------+\n| UTC_DATE() | UTC_DATE() + 0 |\n+------------+----------------+\n| 2010-03-27 | 20100327 |\n+------------+----------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/utc_date', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/utc_date'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (225, 31, 'UTC\\_TIME', 'Syntax\n------\n\nUTC_TIME\nUTC_TIME([precision])\n\nDescription\n-----------\n\nReturns the current UTC time as a value in HH:MM:SS or HHMMSS.uuuuuu format, depending on whether the function is used in a string or numeric context.\n\nThe optional _precision_ determines the microsecond precision. See Microseconds in MariaDB.\n\nExamples\n--------\n\nSELECT UTC_TIME(), UTC_TIME() + 0;\n+------------+----------------+\n| UTC_TIME() | UTC_TIME() + 0 |\n+------------+----------------+\n| 17:32:34 | 173234.000000 |\n+------------+----------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/utc_time', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/utc_time'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (226, 31, 'UTC\\_TIMESTAMP', 'Syntax\n------\n\nUTC_TIMESTAMP\nUTC_TIMESTAMP([precision])\n\nDescription\n-----------\n\nReturns the current UTC date and time as a value in YYYY-MM-DD HH:MM:SS or YYYYMMDDHHMMSS.uuuuuu format, depending on whether the function is used in a string or numeric context.\n\nThe optional _precision_ determines the microsecond precision. See Microseconds in MariaDB.\n\nExamples\n--------\n\nSELECT UTC_TIMESTAMP(), UTC_TIMESTAMP() + 0;\n+---------------------+-----------------------+\n| UTC_TIMESTAMP() | UTC_TIMESTAMP() + 0 |\n+---------------------+-----------------------+\n| 2010-03-27 17:33:16 | 20100327173316.000000 |\n+---------------------+-----------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/utc_timestamp', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/utc_timestamp'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (227, 31, 'WEEK', 'Syntax\n------\n\nWEEK(date[,mode])\n\nDescription\n-----------\n\nThis function returns the week number for date. The two-argument form ofWEEK() allows you to specify whether the week starts on Sunday or Monday and whether the return value should be in the range from 0 to 53 or from 1 to 53. If the mode argument is omitted, the value of the default_week_format system variable is used.\n\nModes\n\n| Mode | 1st day of week | Range | Week 1 is the 1st week with |\n| ---- | --------------- | ----- | --------------------------- |\n| 0 | Sunday | 0-53 | a Sunday in this year |\n| 1 | Monday | 0-53 | more than 3 days this year |\n| 2 | Sunday | 1-53 | a Sunday in this year |\n| 3 | Monday | 1-53 | more than 3 days this year |\n| 4 | Sunday | 0-53 | more than 3 days this year |\n| 5 | Monday | 0-53 | a Monday in this year |\n| 6 | Sunday | 1-53 | more than 3 days this year |\n| 7 | Monday | 1-53 | a Monday in this year |\n\nWith the mode value of 3, which means ''more than 3 days this year'', weeks are numbered according to ISO 8601:1988.\n\nExamples\n--------\n\nSELECT WEEK(''2008-02-20'');\n+--------------------+\n| WEEK(''2008-02-20'') |\n+--------------------+\n| 7 |\n+--------------------+\n\nSELECT WEEK(''2008-02-20'',0);\n+----------------------+\n| WEEK(''2008-02-20'',0) |\n+----------------------+\n| 7 |\n+----------------------+\n\nSELECT WEEK(''2008-02-20'',1);\n+----------------------+\n| WEEK(''2008-02-20'',1) |\n+----------------------+\n| 8 |\n+----------------------+\n\nSELECT WEEK(''2008-12-31'',0);\n+----------------------+\n| WEEK(''2008-12-31'',0) |\n+----------------------+\n| 52 |\n+----------------------+\n\nSELECT WEEK(''2008-12-31'',1);\n+----------------------+\n| WEEK(''2008-12-31'',1) |\n+----------------------+\n| 53 |\n+----------------------+\n\n SELECT WEEK(''2019-12-30'',3);\n+----------------------+\n| WEEK(''2019-12-30'',3) |\n+----------------------+\n| 1 |\n+----------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/week', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/week'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (228, 31, 'WEEKDAY', 'Syntax\n------\n\nWEEKDAY(date)\n\nDescription\n-----------\n\nReturns the weekday index for date (0 = Monday, 1 = Tuesday, ... 6 = Sunday).\n\nThis contrasts with DAYOFWEEK() which follows the ODBC standard (1 = Sunday, 2 = Monday, ..., 7 = Saturday).\n\nExamples\n--------\n\nSELECT WEEKDAY(''2008-02-03 22:23:00'');\n+--------------------------------+\n| WEEKDAY(''2008-02-03 22:23:00'') |\n+--------------------------------+\n| 6 |\n+--------------------------------+\n\nSELECT WEEKDAY(''2007-11-06'');\n+-----------------------+\n| WEEKDAY(''2007-11-06'') |\n+-----------------------+\n| 1 |\n+-----------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/weekday', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/weekday'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (229, 31, 'WEEKOFYEAR', 'Syntax\n------\n\nWEEKOFYEAR(date)\n\nDescription\n-----------\n\nReturns the calendar week of the date as a number in the range from 1 sqto 53. WEEKOFYEAR() is a compatibility function that is equivalent to WEEK(date,3).\n\nExamples\n--------\n\nSELECT WEEKOFYEAR(''2008-02-20'');\n+--------------------------+\n| WEEKOFYEAR(''2008-02-20'') |\n+--------------------------+\n| 8 |\n+--------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/weekofyear', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/weekofyear'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (230, 31, 'YEAR', 'Syntax\n------\n\nYEAR(date)\n\nDescription\n-----------\n\nReturns the year for the given date, in the range 1000 to 9999, or 0 for the "zero" date.\n\nSQL_TSI_YEAR is a synonym for YEAR:\n\nExamples\n--------\n\nCREATE TABLE t1 (d DATETIME);\nINSERT INTO t1 VALUES\n ("2007-01-30 21:31:07"),\n ("1983-10-15 06:42:51"),\n ("2011-04-21 12:34:56"),\n ("2011-10-30 06:31:41"),\n ("2011-01-30 14:03:25"),\n ("2004-10-07 11:19:34");\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/year', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/year'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (231, 31, 'YEARWEEK', 'Syntax\n------\n\nYEARWEEK(date), YEARWEEK(date,mode)\n\nDescription\n-----------\n\nReturns year and week for a date. The mode argument works exactly like the mode argument to WEEK(). The year in the result may be different from the year in the date argument for the first and the last week of the year.\n\nExamples\n--------\n\nSELECT YEARWEEK(''1987-01-01'');\n+------------------------+\n| YEARWEEK(''1987-01-01'') |\n+------------------------+\n| 198652 |\n+------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/yearweek', '', 'https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/yearweek'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (232, 35, 'Functions & Operators', 'Description\n-----------\n\n| Name | Description | Added |\n| --------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| + | Addition operator | |\n| / | Division operator | |\n| \\* | Multiplication operator | |\n| % | Modulo operator. Returns the remainder of N divided by M | |\n| - | Subtraction operator | |\n| != | Not equals | |\n| < | Less than | |\n| <= | Less than or equal | |\n| <=> | NULL-safe equal | |\n| = | Equal | |\n| > | Greater than | |\n| >= | Greater than or equal | |\n| & | Bitwise AND | |\n| << | Shift left | |\n| >> | Shift right | |\n| ^ | Bitwise XOR | |\n| ! | Logical NOT | |\n| && | Logical AND | |\n| XOR\n\n[Truncated — full content at mariadb.com/docs]', '', 'https://mariadb.com/docs/server/reference/sql-functions/function-and-operator-reference'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (233, 4, 'ABS', 'Syntax\n------\n\nABS(X)\n\nDescription\n-----------\n\nReturns the absolute (non-negative) value of X. If X is not a number, it is converted to a numeric type.\n\nExamples\n--------\n\nSELECT ABS(42);\n+---------+\n| ABS(42) |\n+---------+\n| 42 |\n+---------+\n\nSELECT ABS(-42);\n+----------+\n| ABS(-42) |\n+----------+\n| 42 |\n+----------+\n\nSELECT ABS(DATE ''1994-01-01'');\n+------------------------+\n| ABS(DATE ''1994-01-01'') |\n+------------------------+\n| 19940101 |\n+------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/abs', '', 'https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/abs'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (234, 4, 'ACOS', 'Syntax\n------\n\nACOS(X)\n\nDescription\n-----------\n\nReturns the arc cosine of X, that is, the value whose cosine is X. Returns NULL if X is not in the range -1 to 1.\n\nExamples\n--------\n\nSELECT ACOS(1);\n+---------+\n| ACOS(1) |\n+---------+\n| 0 |\n+---------+\n\nSELECT ACOS(1.0001);\n+--------------+\n| ACOS(1.0001) |\n+--------------+\n| NULL |\n+--------------+\n\nSELECT ACOS(0);\n+-----------------+\n| ACOS(0) |\n+-----------------+\n| 1.5707963267949 |\n+-----------------+\n\nSELECT ACOS(0.234);\n+------------------+\n| ACOS(0.234) |\n+------------------+\n| 1.33460644244679 |\n+------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/acos', '', 'https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/acos'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (235, 4, 'ASIN', 'Syntax\n------\n\nASIN(X)\n\nDescription\n-----------\n\nReturns the arc sine of X, that is, the value whose sine is X. Returns NULL if X is not in the range -1 to 1.\n\nExamples\n--------\n\nSELECT ASIN(0.2);\n+--------------------+\n| ASIN(0.2) |\n+--------------------+\n| 0.2013579207903308 |\n+--------------------+\n\nSELECT ASIN(''foo'');\n+-------------+\n| ASIN(''foo'') |\n+-------------+\n| 0 |\n+-------------+\n\nSHOW WARNINGS;\n+---------+------+-----------------------------------------+\n| Level | Code | Message |\n+---------+------+-----------------------------------------+\n| Warning | 1292 | Truncated incorrect DOUBLE value: ''foo'' |\n+---------+------+-----------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/asin', '', 'https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/asin'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (236, 4, 'ATAN', 'Syntax\n------\n\nATAN(X)\n\nDescription\n-----------\n\nReturns the arc tangent of X, that is, the value whose tangent is X.\n\nExamples\n--------\n\nSELECT ATAN(2);\n+--------------------+\n| ATAN(2) |\n+--------------------+\n| 1.1071487177940904 |\n+--------------------+\n\nSELECT ATAN(-2);\n+---------------------+\n| ATAN(-2) |\n+---------------------+\n| -1.1071487177940904 |\n+---------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/atan', '', 'https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/atan'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (237, 4, 'ATAN2', 'Syntax\n------\n\nATAN(Y,X), ATAN2(Y,X)\n\nDescription\n-----------\n\nReturns the arc tangent of the two variables X and Y. It is similar to calculating the arc tangent of Y / X, except that the signs of both arguments are used to determine the quadrant of the result.\n\nExamples\n--------\n\nSELECT ATAN(-2,2);\n+---------------------+\n| ATAN(-2,2) |\n+---------------------+\n| -0.7853981633974483 |\n+---------------------+\n\nSELECT ATAN2(PI(),0);\n+--------------------+\n| ATAN2(PI(),0) |\n+--------------------+\n| 1.5707963267948966 |\n+--------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/atan2', '', 'https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/atan2'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (238, 4, 'CEIL', 'Syntax\n------\n\nCEIL(X)\n\nDescription\n-----------\n\nCEIL() is a synonym for CEILING().\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/ceil', '', 'https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/ceil'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (239, 4, 'CEILING', 'Syntax\n------\n\nCEILING(X)\n\nDescription\n-----------\n\nReturns the smallest integer value not less than X.\n\nExamples\n--------\n\nSELECT CEILING(1.23);\n+---------------+\n| CEILING(1.23) |\n+---------------+\n| 2 |\n+---------------+\n\nSELECT CEILING(-1.23);\n+----------------+\n| CEILING(-1.23) |\n+----------------+\n| -1 |\n+----------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/ceiling', '', 'https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/ceiling'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (240, 4, 'CONV', 'Syntax\n------\n\nCONV(N,from_base,to_base)\n\nDescription\n-----------\n\nConverts numbers between different number bases. Returns a string representation of the number _N_, converted from base _from_base_ to base _to_base_.\n\nReturns NULL if any argument is NULL, or if the second or third argument are not in the allowed range.\n\nThe argument _N_ is interpreted as an integer, but may be specified as an integer or a string. The minimum base is 2 and the maximum base is 62. If _to_base_ is a negative number, _N_ is regarded as a signed number. Otherwise, _N_ is treated as unsigned. CONV() works with 64-bit precision.\n\nThe argument _N_ is interpreted as an integer, but may be specified as an integer or a string. The minimum base is 2 and the maximum base is 36. If _to_base_ is a negative number, _N_ is regarded as a signed number. Otherwise, _N_ is treated as unsigned. CONV() works with 64-bit precision.\n\nSome shortcuts for this function are also available: BIN(), OCT(), HEX(), UNHEX(). Also, MariaDB allows binary literal values and hexadecimal literal values.\n\nExamples\n--------\n\nSELECT CONV(''a'',16,2);\n+----------------+\n| CONV(''a'',16,2) |\n+----------------+\n| 1010 |\n+----------------+\n\nSELECT CONV(''6E'',18,8);\n+-----------------+\n| CONV(''6E'',18,8) |\n+-----------------+\n| 172 |\n+-----------------+\n\nSELECT CONV(-17,10,-18);\n+------------------+\n| CONV(-17,10,-18) |\n+------------------+\n| -H |\n+------------------+\n\nSELECT CONV(12+''10''+''10''+0xa,10,10);\n+------------------------------+\n| CONV(12+''10''+''10''+0xa,10,10) |\n+------------------------------+\n| 42 |\n+------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/conv', '', 'https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/conv'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (241, 4, 'COS', 'Syntax\n------\n\nCOS(X)\n\nDescription\n-----------\n\nReturns the cosine of X, where X is given in radians.\n\nExamples\n--------\n\nSELECT COS(PI());\n+-----------+\n| COS(PI()) |\n+-----------+\n| -1 |\n+-----------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/cos', '', 'https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/cos'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (242, 4, 'COT', 'Syntax\n------\n\nCOT(X)\n\nDescription\n-----------\n\nReturns the cotangent of X.\n\nExamples\n--------\n\nSELECT COT(42);\n+--------------------+\n| COT(42) |\n+--------------------+\n| 0.4364167060752729 |\n+--------------------+\n\nSELECT COT(12);\n+---------------------+\n| COT(12) |\n+---------------------+\n| -1.5726734063976893 |\n+---------------------+\n\nSELECT COT(0);\nERROR 1690 (22003): DOUBLE value is out of range in ''cot(0)''\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/cot', '', 'https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/cot'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (243, 4, 'CRC32', 'Syntax\n------\n\nCRC32([par,]expr)\n\nDescription\n-----------\n\nComputes a cyclic redundancy check (CRC) value and returns a 32-bit unsigned value. The result is NULL if the argument is NULL. The argument is expected to be a string and (if possible) is treated as one if it is not.\n\nUses the alternate Castagnoli polynomia.\n\nOften, CRC is computed in pieces. To facilitate this, there''s an optional parameter: CRC32(''MariaDB'')=CRC32(CRC32(''Maria''),''DB'').\n\nUses the ISO 3309 polynomial that used by zlib and many others.\n\nExamples\n--------\n\nSELECT CRC32(CRC32(''Maria''),''DB'');\n+----------------------------+\n| CRC32(CRC32(''Maria''),''DB'') |\n+----------------------------+\n| 4227209140 |\n+----------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/crc32', '', 'https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/crc32'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (244, 4, 'CRC32C', 'Syntax\n------\n\nCRC32C([par,]expr)\n\nDescription\n-----------\n\nMariaDB has always included a native unary function CRC32() that computes the CRC-32 of a string using the ISO 3309 polynomial that used by zlib and many others.\n\nInnoDB and MyRocks use a different polynomial, which was implemented in SSE4.2 instructions that were introduced in the Intel Nehalem microarchitecture. This is commonly called CRC-32C (Castagnoli).\n\nThe CRC32C function uses the Castagnoli polynomial.\n\nThis allows SELECT…INTO DUMPFILE to be used for the creation of files with valid checksums, such as a logically empty InnoDB redo log fileib_logfile0 corresponding to a particular log sequence number.\n\nThe optional parameter allows the checksum to be computed in pieces:\\\nCRC32C(''MariaDB'')=CRC32C(CRC32C(''Maria''),''DB'').\n\nExamples\n--------\n\nSELECT CRC32C(''MariaDB'');\n+-------------------+\n| CRC32C(''MariaDB'') |\n+-------------------+\n| 809606978 |\n+-------------------+\n\nSELECT CRC32C(CRC32C(''Maria''),''DB'');\n+------------------------------+\n| CRC32C(CRC32C(''Maria''),''DB'') |\n+------------------------------+\n| 809606978 |\n+------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/crc32c', '', 'https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/crc32c'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (245, 4, 'DEGREES', 'Syntax\n------\n\nDEGREES(X)\n\nDescription\n-----------\n\nReturns the argument _X_, converted from radians to degrees.\n\nThis is the converse of the RADIANS() function.\n\nExamples\n--------\n\nSELECT DEGREES(PI());\n+---------------+\n| DEGREES(PI()) |\n+---------------+\n| 180 |\n+---------------+\n\nSELECT DEGREES(PI() / 2);\n+-------------------+\n| DEGREES(PI() / 2) |\n+-------------------+\n| 90 |\n+-------------------+\n\nSELECT DEGREES(45);\n+-----------------+\n| DEGREES(45) |\n+-----------------+\n| 2578.3100780887 |\n+-----------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/degrees', '', 'https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/degrees'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (246, 4, 'DIV', 'Syntax\n------\n\nDIV\n\nDescription\n-----------\n\nInteger division. Similar to FLOOR(), but is safe with BIGINT values. Incorrect results may occur for non-integer operands that exceed the BIGINT range.\n\nIf the ERROR_ON_DIVISION_BY_ZERO SQL_MODE is used, a division by zero produces an error. Otherwise, it returns NULL.\n\nThe remainder of a division can be obtained using the MOD operator.\n\nExamples\n--------\n\nSELECT 300 DIV 7;\n+-----------+\n| 300 DIV 7 |\n+-----------+\n| 42 |\n+-----------+\n\nSELECT 300 DIV 0;\n+-----------+\n| 300 DIV 0 |\n+-----------+\n| NULL |\n+-----------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/div', '', 'https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/div'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (247, 4, 'EXP', 'Syntax\n------\n\nEXP(X)\n\nDescription\n-----------\n\nReturns the value of e (the base of natural logarithms) raised to the power of X. The inverse of this function is LOG() (using a single argument only) or LN().\n\nIf X is NULL, this function returns NULL.\n\nExamples\n--------\n\nSELECT EXP(2);\n+------------------+\n| EXP(2) |\n+------------------+\n| 7.38905609893065 |\n+------------------+\n\nSELECT EXP(-2);\n+--------------------+\n| EXP(-2) |\n+--------------------+\n| 0.1353352832366127 |\n+--------------------+\n\nSELECT EXP(0);\n+--------+\n| EXP(0) |\n+--------+\n| 1 |\n+--------+\n\nSELECT EXP(NULL);\n+-----------+\n| EXP(NULL) |\n+-----------+\n| NULL |\n+-----------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/exp', '', 'https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/exp'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (248, 4, 'FLOOR', 'Syntax\n------\n\nFLOOR(X)\n\nDescription\n-----------\n\nReturns the largest integer value not greater than X.\n\nExamples\n--------\n\nSELECT FLOOR(1.23);\n+-------------+\n| FLOOR(1.23) |\n+-------------+\n| 1 |\n+-------------+\n\nSELECT FLOOR(-1.23);\n+--------------+\n| FLOOR(-1.23) |\n+--------------+\n| -2 |\n+--------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/floor', '', 'https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/floor'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (249, 4, 'LN', 'Syntax\n------\n\nLN(X)\n\nDescription\n-----------\n\nReturns the natural logarithm of X; that is, the base-e logarithm of X. If X is less than or equal to 0, or NULL, then NULL is returned.\n\nThe inverse of this function is EXP().\n\nExamples\n--------\n\nSELECT LN(2);\n+-------------------+\n| LN(2) |\n+-------------------+\n| 0.693147180559945 |\n+-------------------+\n\nSELECT LN(-2);\n+--------+\n| LN(-2) |\n+--------+\n| NULL |\n+--------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/ln', '', 'https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/ln'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (250, 4, 'LOG', 'Syntax\n------\n\nLOG(X), LOG(B,X)\n\nDescription\n-----------\n\nIf called with one parameter, this function returns the natural logarithm of X. If X is less than or equal to 0, then NULL is returned.\n\nIf called with two parameters, it returns the logarithm of X to the base B. If B is <= 1 or X <= 0, the function returns NULL.\n\nIf any argument is NULL, the function returns NULL.\n\nThe inverse of this function (when called with a single argument) is the EXP() function.\n\nExamples\n--------\n\nSELECT LOG(2);\n+-------------------+\n| LOG(2) |\n+-------------------+\n| 0.693147180559945 |\n+-------------------+\n\nSELECT LOG(-2);\n+---------+\n| LOG(-2) |\n+---------+\n| NULL |\n+---------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/log', '', 'https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/log'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (251, 4, 'LOG10', 'Syntax\n------\n\nLOG10(X)\n\nDescription\n-----------\n\nReturns the base-10 logarithm of X.\n\nExamples\n--------\n\nSELECT LOG10(2);\n+-------------------+\n| LOG10(2) |\n+-------------------+\n| 0.301029995663981 |\n+-------------------+\n\nSELECT LOG10(100);\n+------------+\n| LOG10(100) |\n+------------+\n| 2 |\n+------------+\n\nSELECT LOG10(-100);\n+-------------+\n| LOG10(-100) |\n+-------------+\n| NULL |\n+-------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/log10', '', 'https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/log10'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (252, 4, 'LOG2', 'Syntax\n------\n\nLOG2(X)\n\nDescription\n-----------\n\nReturns the base-2 logarithm of X.\n\nExamples\n--------\n\nSELECT LOG2(4398046511104);\n+---------------------+\n| LOG2(4398046511104) |\n+---------------------+\n| 42 |\n+---------------------+\n\nSELECT LOG2(65536);\n+-------------+\n| LOG2(65536) |\n+-------------+\n| 16 |\n+-------------+\n\nSELECT LOG2(-100);\n+------------+\n| LOG2(-100) |\n+------------+\n| NULL |\n+------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/log2', '', 'https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/log2'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (253, 4, 'MOD', 'Syntax\n------\n\nMOD(N,M), N % M, N MOD M\n\nDescription\n-----------\n\nModulo operation. Returns the remainder of N divided by M. See also Modulo Operator.\n\nIf the ERROR_ON_DIVISION_BY_ZERO SQL_MODE is used, any number modulus zero produces an error. Otherwise, it returns NULL.\n\nThe integer part of a division can be obtained using DIV.\n\nExamples\n--------\n\nSELECT 1042 % 50;\n+-----------+\n| 1042 % 50 |\n+-----------+\n| 42 |\n+-----------+\n\nSELECT MOD(234, 10);\n+--------------+\n| MOD(234, 10) |\n+--------------+\n| 4 |\n+--------------+\n\nSELECT 253 % 7;\n+---------+\n| 253 % 7 |\n+---------+\n| 1 |\n+---------+\n\nSELECT MOD(29,9);\n+-----------+\n| MOD(29,9) |\n+-----------+\n| 2 |\n+-----------+\n\nSELECT 29 MOD 9;\n+----------+\n| 29 MOD 9 |\n+----------+\n| 2 |\n+----------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/mod', '', 'https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/mod'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (254, 4, 'OCT', 'Syntax\n------\n\nOCT(N)\n\nDescription\n-----------\n\nReturns a string representation of the octal value of N, where N is a longlong (BIGINT) number. This is equivalent to CONV(N,10,8). Returns NULL if N is NULL.\n\nExamples\n--------\n\nSELECT OCT(34);\n+---------+\n| OCT(34) |\n+---------+\n| 42 |\n+---------+\n\nSELECT OCT(12);\n+---------+\n| OCT(12) |\n+---------+\n| 14 |\n+---------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/oct', '', 'https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/oct'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (255, 4, 'PI', 'Syntax\n------\n\nPI()\n\nDescription\n-----------\n\nReturns the value of π (pi). The default number of decimal places displayed is six, but MariaDB uses the full double-precision value internally.\n\nExamples\n--------\n\nSELECT PI();\n+----------+\n| PI() |\n+----------+\n| 3.141593 |\n+----------+\n\nSELECT PI()+0.0000000000000000000000;\n+-------------------------------+\n| PI()+0.0000000000000000000000 |\n+-------------------------------+\n| 3.1415926535897931159980 |\n+-------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/pi', '', 'https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/pi'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (256, 4, 'POW', 'Syntax\n------\n\nPOW(X,Y)\n\nDescription\n-----------\n\nReturns the value of X raised to the power of Y.\n\nPOWER() is a synonym.\n\nExamples\n--------\n\nSELECT POW(2,3);\n+----------+\n| POW(2,3) |\n+----------+\n| 8 |\n+----------+\n\nSELECT POW(2,-2);\n+-----------+\n| POW(2,-2) |\n+-----------+\n| 0.25 |\n+-----------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/pow', '', 'https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/pow'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (257, 4, 'POWER', 'Syntax\n------\n\nPOWER(X,Y)\n\nDescription\n-----------\n\nThis is a synonym for POW(), which returns the value of X raised to the power of Y.\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/power', '', 'https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/power'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (258, 4, 'RADIANS', 'Syntax\n------\n\nRADIANS(X)\n\nDescription\n-----------\n\nReturns the argument _X_, converted from degrees to radians. Note that π radians equals 180 degrees.\n\nThis is the converse of the DEGREES() function.\n\nExamples\n--------\n\nSELECT RADIANS(45);\n+-------------------+\n| RADIANS(45) |\n+-------------------+\n| 0.785398163397448 |\n+-------------------+\n\nSELECT RADIANS(90);\n+-----------------+\n| RADIANS(90) |\n+-----------------+\n| 1.5707963267949 |\n+-----------------+\n\nSELECT RADIANS(PI());\n+--------------------+\n| RADIANS(PI()) |\n+--------------------+\n| 0.0548311355616075 |\n+--------------------+\n\nSELECT RADIANS(180);\n+------------------+\n| RADIANS(180) |\n+------------------+\n| 3.14159265358979 |\n+------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/radians', '', 'https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/radians'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (259, 4, 'RAND', 'Description\n-----------\n\nReturns a random DOUBLE precision floating point value v in the range 0 <= v < 1.0. If a constant integer argument N is specified, it is used as the seed value, which produces a repeatable sequence of column values. In the example below, note that the sequences of values produced by RAND(3) is the same both places where it occurs.\n\nIn a WHERE clause, RAND() is evaluated each time the WHERE is executed.\n\nStatements using the RAND() function are not safe for statement-based replication.\n\nPractical uses\n\nThe expression to get a random integer from a given range is the following:\n\n``sql\nFLOOR(min_value + RAND() (max_value - min_value +1))\n`\n\nRAND() is often used to read random rows from a table, as follows:\n\n`sql\nSELECT FROM my_table ORDER BY RAND() LIMIT 10;\n`\n\nNote, however, that this technique should never be used on a large table as it will be extremely slow. MariaDB will read all rows in the table, generate a random value for each of them, order them, and finally will apply the LIMIT` clause.\n\nExamples\n--------\n\nCREATE TABLE t (i INT);\n\nINSERT INTO t VALUES(1),(2),(3);\n\nSELECT i, RAND() FROM t;\n+------+-------------------+\n| i | RAND() |\n+------+-------------------+\n| 1 | 0.255651095188829 |\n| 2 | 0.833920199269355 |\n| 3 | 0.40264774151393 |\n+------+-------------------+\n\nSELECT i, RAND(3) FROM t;\n+------+-------------------+\n| i | RAND(3) |\n+------+-------------------+\n| 1 | 0.90576975597606 |\n| 2 | 0.373079058130345 |\n| 3 | 0.148086053457191 |\n+------+-------------------+\n\nSELECT i, RAND() FROM t;\n+------+-------------------+\n| i | RAND() |\n+------+-------------------+\n| 1 | 0.511478140495232 |\n| 2 | 0.349447508668012 |\n| 3 | 0.212803152588013 |\n+------+-------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/rand', '', 'https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/rand'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (260, 4, 'ROUND', 'Description\n-----------\n\nRounds the argument X to D decimal places. D defaults to 0 if not specified.D can be negative to cause D digits left of the decimal point of the value X to become zero.\n\nThe rounding algorithm depends on the data type of X:\n\n For floating-point types (FLOAT, DOUBLE) the C libraries rounding function is used, so the behavior _may_ differ between operating systems.\n For fixed-point types (DECIMAL, DEC/NUMBER/FIXED) the "round half up" rule is used, meaning that e.g. a value ending in exactly .5 is always rounded up.\n\nExamples\n--------\n\nSELECT ROUND(-1.23);\n+--------------+\n| ROUND(-1.23) |\n+--------------+\n| -1 |\n+--------------+\n\nSELECT ROUND(-1.58);\n+--------------+\n| ROUND(-1.58) |\n+--------------+\n| -2 |\n+--------------+\n\nSELECT ROUND(1.58); \n+-------------+\n| ROUND(1.58) |\n+-------------+\n| 2 |\n+-------------+\n\nSELECT ROUND(1.298, 1);\n+-----------------+\n| ROUND(1.298, 1) |\n+-----------------+\n| 1.3 |\n+-----------------+\n\nSELECT ROUND(1.298, 0);\n+-----------------+\n| ROUND(1.298, 0) |\n+-----------------+\n| 1 |\n+-----------------+\n\nSELECT ROUND(23.298, -1);\n+-------------------+\n| ROUND(23.298, -1) |\n+-------------------+\n| 20 |\n+-------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/round', '', 'https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/round'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (261, 4, 'SIGN', 'Syntax\n------\n\nSIGN(X)\n\nDescription\n-----------\n\nReturns the sign of the argument as -1, 0, or 1, depending on whether X is negative, zero, or positive.\n\nExamples\n--------\n\nSELECT SIGN(-32);\n+-----------+\n| SIGN(-32) |\n+-----------+\n| -1 |\n+-----------+\n\nSELECT SIGN(0);\n+---------+\n| SIGN(0) |\n+---------+\n| 0 |\n+---------+\n\nSELECT SIGN(234);\n+-----------+\n| SIGN(234) |\n+-----------+\n| 1 |\n+-----------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/sign', '', 'https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/sign'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (262, 4, 'SIN', 'Syntax\n------\n\nSIN(X)\n\nDescription\n-----------\n\nReturns the sine of X, where X is given in radians.\n\nExamples\n--------\n\nSELECT SIN(1.5707963267948966);\n+-------------------------+\n| SIN(1.5707963267948966) |\n+-------------------------+\n| 1 |\n+-------------------------+\n\nSELECT SIN(PI());\n+----------------------+\n| SIN(PI()) |\n+----------------------+\n| 1.22460635382238e-16 |\n+----------------------+\n\nSELECT ROUND(SIN(PI()));\n+------------------+\n| ROUND(SIN(PI())) |\n+------------------+\n| 0 |\n+------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/sin', '', 'https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/sin'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (263, 4, 'SQRT', 'Syntax\n------\n\nSQRT(X)\n\nDescription\n-----------\n\nReturns the square root of X. If X is negative, NULL is returned.\n\nExamples\n--------\n\nSELECT SQRT(4);\n+---------+\n| SQRT(4) |\n+---------+\n| 2 |\n+---------+\n\nSELECT SQRT(20);\n+------------------+\n| SQRT(20) |\n+------------------+\n| 4.47213595499958 |\n+------------------+\n\nSELECT SQRT(-16);\n+-----------+\n| SQRT(-16) |\n+-----------+\n| NULL |\n+-----------+\n\nSELECT SQRT(1764);\n+------------+\n| SQRT(1764) |\n+------------+\n| 42 |\n+------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/sqrt', '', 'https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/sqrt'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (264, 4, 'TAN', 'Syntax\n------\n\nTAN(X)\n\nDescription\n-----------\n\nReturns the tangent of X, where X is given in radians.\n\nExamples\n--------\n\nSELECT TAN(0.7853981633974483);\n+-------------------------+\n| TAN(0.7853981633974483) |\n+-------------------------+\n| 0.9999999999999999 |\n+-------------------------+\n\nSELECT TAN(PI());\n+-----------------------+\n| TAN(PI()) |\n+-----------------------+\n| -1.22460635382238e-16 |\n+-----------------------+\n\nSELECT TAN(PI()+1);\n+-----------------+\n| TAN(PI()+1) |\n+-----------------+\n| 1.5574077246549 |\n+-----------------+\n\nSELECT TAN(RADIANS(PI()));\n+--------------------+\n| TAN(RADIANS(PI())) |\n+--------------------+\n| 0.0548861508080033 |\n+--------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/tan', '', 'https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/tan'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (265, 4, 'TO\\_NUMBER', 'Syntax\n------\n\nTO_NUMBER(number_or_string_subject)\nTO_NUMBER(string_subject,string_format)\n\nDescription\n-----------\n\nThe function returns the DOUBLE data type for all signatures and input data types.\n\nThe format parser understands the following components:\n\n Digits: 0, 9\n Hex digits: X\n Group separators: comma (,) and G\n Decimal delimiters: period (.) and D\n Approximate number signature: EEEE\n Currency/numeric flags: $ and B\n Currency signatures: C, L, U\n Sign signatures: S, MI, PR\n Special format signatures: V, TM, TM9, TME\n Format flag: FM\n\nThe function was introduced for Oracle compatibility, but does not include the following features:\n\n The ON CONVERSION ERROR clause\n The third parameter (nlsparam)\n* Internationalized components: G, D, C, L, U\n\nThese features are planned to be be implemented via MDEV-36978.\n\nExamples\n--------\n\nSELECT TO_NUMBER(''100.00'');\n+---------------------+\n| TO_NUMBER(''100.00'') |\n+---------------------+\n| 100 |\n+---------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/to_number', '', 'https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/to_number'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (266, 4, 'TRUNCATE', 'Syntax\n------\n\nTRUNCATE(X,D)\n\nDescription\n-----------\n\nReturns the number X, truncated to D decimal places. If D is 0, the result has no decimal point or fractional part. D can be negative to cause D digits left of the decimal point of the value X to become\\\nzero.\n\nExamples\n--------\n\nSELECT TRUNCATE(1.223,1);\n+-------------------+\n| TRUNCATE(1.223,1) |\n+-------------------+\n| 1.2 |\n+-------------------+\n\nSELECT TRUNCATE(1.999,1);\n+-------------------+\n| TRUNCATE(1.999,1) |\n+-------------------+\n| 1.9 |\n+-------------------+\n\nSELECT TRUNCATE(1.999,0); \n+-------------------+\n| TRUNCATE(1.999,0) |\n+-------------------+\n| 1 |\n+-------------------+\n\nSELECT TRUNCATE(-1.999,1);\n+--------------------+\n| TRUNCATE(-1.999,1) |\n+--------------------+\n| -1.9 |\n+--------------------+\n\nSELECT TRUNCATE(122,-2);\n+------------------+\n| TRUNCATE(122,-2) |\n+------------------+\n| 100 |\n+------------------+\n\nSELECT TRUNCATE(10.28100,0);\n+-----------------------+\n| TRUNCATE(10.28100,0) |\n+-----------------------+\n| 1028 |\n+-----------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/truncate', '', 'https://mariadb.com/docs/server/reference/sql-functions/numeric-functions/truncate'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (267, 35, '\\_rowid', 'Syntax\n------\n\n_rowid\n\nDescription\n-----------\n\nThe _rowid pseudo column is mapped to the primary key in the related table. This can be used as a replacement of the rowid pseudo column in other databases. Another usage is to simplify sql queries as one doesn''t have to know the name of the primary key.\n\nExamples\n--------\n\nCREATE TABLE t1 (a INT PRIMARY KEY, b VARCHAR(80));\nINSERT INTO t1 VALUES (1,"one"),(2,"two");\nSELECT * FROM t1 WHERE _rowid=1;\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/pseudo-columns/_rowid', '', 'https://mariadb.com/docs/server/reference/sql-functions/pseudo-columns/_rowid'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (268, 19, 'BIT\\_COUNT', 'Syntax\n------\n\nBIT_COUNT(N)\n\nDescription\n-----------\n\nReturns the number of bits that are set in the argument N.\n\nExamples\n--------\n\nSELECT BIT_COUNT(29), BIT_COUNT(b''101010'');\n+---------------+----------------------+\n| BIT_COUNT(29) | BIT_COUNT(b''101010'') |\n+---------------+----------------------+\n| 4 | 3 |\n+---------------+----------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/bit-functions-and-operators/bit_count', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/bit-functions-and-operators/bit_count'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (269, 19, '\\~', 'Syntax\n------\n\n~\n\nDescription\n-----------\n\nBitwise NOT. Converts the value to 4 bytes binary and inverts all bits.\n\nExamples\n--------\n\nSELECT 3 & ~1;\n+--------+\n| 3 & ~1 |\n+--------+\n| 2 |\n+--------+\n\nSELECT 5 & ~1;\n+--------+\n| 5 & ~1 |\n+--------+\n| 4 |\n+--------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/bit-functions-and-operators/bitwise-not', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/bit-functions-and-operators/bitwise-not'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (270, 19, '|', 'Syntax\n------\n\n|\n\nDescription\n-----------\n\nBitwise OR. Converts the values to binary and compares bits. If either of the corresponding bits has a value of 1, the resulting bit is also 1.\n\nSee also bitwise AND.\n\nExamples\n--------\n\nSELECT 2|1;\n+-----+\n| 2|1 |\n+-----+\n| 3 |\n+-----+\n\nSELECT 29 | 15;\n+---------+\n| 29 | 15 |\n+---------+\n| 31 |\n+---------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/bit-functions-and-operators/bitwise-or', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/bit-functions-and-operators/bitwise-or'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (271, 19, '^', 'Syntax\n------\n\n^\n\nDescription\n-----------\n\nBitwise XOR. Converts the values to binary and compares bits. If one (and only one) of the corresponding bits is 1 is the resulting bit also 1.\n\nExamples\n--------\n\nSELECT 1 ^ 1;\n+-------+\n| 1 ^ 1 |\n+-------+\n| 0 |\n+-------+\n\nSELECT 1 ^ 0;\n+-------+\n| 1 ^ 0 |\n+-------+\n| 1 |\n+-------+\n\nSELECT 11 ^ 3;\n+--------+\n| 11 ^ 3 |\n+--------+\n| 8 |\n+--------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/bit-functions-and-operators/bitwise-xor', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/bit-functions-and-operators/bitwise-xor'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (272, 19, '&', 'Syntax\n------\n\n&\n\nDescription\n-----------\n\nBitwise AND. Converts the values to binary and compares bits. Only if both the corresponding bits are 1 is the resulting bit also 1.\n\nSee also bitwise OR.\n\nExamples\n--------\n\nSELECT 2&1;\n+-----+\n| 2&1 |\n+-----+\n| 0 |\n+-----+\n\nSELECT 3&1;\n+-----+\n| 3&1 |\n+-----+\n| 1 |\n+-----+\n\nSELECT 29 & 15;\n+---------+\n| 29 & 15 |\n+---------+\n| 13 |\n+---------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/bit-functions-and-operators/bitwise_and', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/bit-functions-and-operators/bitwise_and'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (273, 19, 'Parentheses', 'Description\n-----------\n\nParentheses are sometimes called precedence operators - this means that they can be used to change the other operator''s precedence in an expression. The expressions that are written between parentheses are computed before the expressions that are written outside. Parentheses must always contain an expression (that is, they cannot be empty), and can be nested.\n\nFor example, the following expressions could return different results:\n\n NOT a OR b\n NOT (a OR b)\n\nIn the first case, NOT applies to a, so if a is FALSE or b is TRUE, the expression returns TRUE. In the second case, NOT applies to the result of a OR b, so if at least one of a or b is TRUE, the expression is TRUE.\n\nWhen the precedence of operators is not intuitive, you can use parentheses to make it immediately clear for whoever reads the statement.\n\nThe precedence of the NOT operator can also be affected by the HIGH_NOT_PRECEDENCE SQL_MODE flag.\n\nOther uses\n\nParentheses must always be used to enclose subqueries.\n\nParentheses can also be used in a JOIN statement between multiple tables to determine which tables must be joined first.\n\nAlso, parentheses are used to enclose the list of parameters to be passed to built-in functions, user-defined functions and stored routines. However, when no parameter is passed to a stored procedure, parentheses are optional. For builtin functions and user-defined functions, spaces are not allowed between the function name and the open parenthesis, unless the IGNORE_SPACE SQL_MODE is set. For stored routines (and for functions if IGNORE_SPACE is set) spaces are allowed before the open parenthesis, including tab characters and new line characters.\n\nSyntax errors\n\nIf there are more open parentheses than closed parentheses, the error usually looks like this:\n\n``sql\nERROR 1064 (42000): You have an error in your SQL syntax; check the manual that\ncorresponds to your MariaDB server version for the right syntax to use near '''' a\nt line 1\n`\n\nNote the empty string.\n\nIf there are more closed parentheses than open parentheses, the error usually looks like this:\n\n`sql\nERROR 1064 (42000): You have an error in your SQL syntax; check the manual that\ncorresponds to your MariaDB server version for the right syntax to use near '')''\nat line 1\n``\n\nNote the quoted closed parenthesis.\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/bit-functions-and-operators/parentheses', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/bit-functions-and-operators/parentheses'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (274, 19, '<<', 'Syntax\n------\n\nvalue1 << value2\n\nDescription\n-----------\n\nConverts a longlong (BIGINT) number (_value1_) to binary and shifts _value2_ units to the left.\n\nExamples\n--------\n\nSELECT 1 << 2;\n+--------+\n| 1 << 2 |\n+--------+\n| 4 |\n+--------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/bit-functions-and-operators/shift-left', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/bit-functions-and-operators/shift-left'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (275, 19, '>>', 'Syntax\n------\n\nvalue1 >> value2\n\nDescription\n-----------\n\nConverts a longlong (BIGINT) number (_value1_) to binary and shifts _value2_ units to the right.\n\nExamples\n--------\n\nSELECT 4 >> 2;\n+--------+\n| 4 >> 2 |\n+--------+\n| 1 |\n+--------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/bit-functions-and-operators/shift-right', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/bit-functions-and-operators/shift-right'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (276, 19, 'TRUE FALSE', 'Description\n-----------\n\nThe constants TRUE and FALSE evaluate to 1 and 0, respectively. The constant names can be written in any lettercase.\n\nExamples\n--------\n\nSELECT TRUE, true, FALSE, false;\n+------+------+-------+-------+\n| TRUE | TRUE | FALSE | FALSE |\n+------+------+-------+-------+\n| 1 | 1 | 0 | 0 |\n+------+------+-------+-------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/bit-functions-and-operators/true-false', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/bit-functions-and-operators/true-false'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (277, 35, 'AES\\_DECRYPT', 'Syntax\n------\n\nAES_ENCRYPT(crypt_str, key_str, [, iv [, mode]])\n\nDescription\n-----------\n\nThis function allows decryption of data using the official AES (Advanced Encryption Standard) algorithm. For more information, see the description of AES_ENCRYPT().\n\nThe function supports an initialization vector, and control of the block encryption mode. The default mode is specified by the block_encryption_mode system variable, which can be changed when calling the function with a mode. _mode_ is aes-{128,192,256}-{ecb,cbc,ctr} for example: "AES-128-cbc".\n\nFor modes that require it, the initialization_vector _iv_ should be 16 bytes (it can be longer, but the extra bytes are ignored). A shorter _iv_, where one is required, results in the function returning NULL. Calling RANDOM_BYTES(16) will generate a random series of bytes that can be used for the _iv_.\n\nExamples\n\n``sql\nSELECT HEX(AES_ENCRYPT(''foo'', ''bar'', ''0123456789abcdef'', ''aes-128-ctr'')) AS x; \n+--------+\n| x |\n+--------+\n| C57C4B |\n+--------+\n\nSELECT AES_DECRYPT(x''C57C4B'', ''bar'', ''0123456789abcdef'', ''aes-128-ctr''); \n+------------------------------------------------------------------+\n| AES_DECRYPT(x''C57C4B'', ''bar'', ''0123456789abcdef'', ''aes-128-ctr'') |\n+------------------------------------------------------------------+\n| foo |\n+------------------------------------------------------------------+\n``\n\nThe function does not support an initialization vector.\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/encryption-hashing-and-compression-functions/aes_decrypt', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/encryption-hashing-and-compression-functions/aes_decrypt'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (278, 35, 'AES\\_ENCRYPT', 'Syntax\n------\n\nAES_ENCRYPT(str, key, [, iv [, mode]])\n\nDescription\n-----------\n\nAES_ENCRYPT() and AES_DECRYPT() allow encryption and decryption of data using the official AES (Advanced Encryption Standard) algorithm, previously known as "Rijndael." Encoding with a 128-bit key length is used (from MariaDB 11.2.0, this is the default, and can be changed). 128 bits is much faster and is secure enough for most purposes.\n\nAES_ENCRYPT() encrypts a string _str_ using the key _key_str_, and returns a binary string.\n\nAES_DECRYPT() decrypts the encrypted string and returns the original string.\n\nThe input arguments may be any length. If either argument is NULL, the result of this function is also NULL.\n\nBecause AES is a block-level algorithm, padding is used to encode uneven length strings and so the result string length may be calculated using this formula:\n\n``sql\n16 x (trunc(string_length / 16) + 1)\n`\n\nIf AES_DECRYPT() detects invalid data or incorrect padding, it returns NULL. However, it is possible for AES_DECRYPT() to return a non-NULL value (possibly garbage) if the input data or the key is invalid.\n\nMariaDB starting with 11.2\n\nThe function supports an initialization vector, and control of the block encryption mode. The default mode is specified by the block_encryption_mode system variable, which can be changed when calling the function with a mode. _mode_ is aes-{128,192,256}-{ecb,cbc,ctr} for example: "AES-128-cbc".\\\nAES_ENCRYPT(str, key)` can no longer be used in persistent virtual columns (and the like).\n\nThe function does not support an initialization vector.\n\nExamples\n--------\n\nSELECT HEX(AES_ENCRYPT(''foo'', ''bar'', ''0123456789abcdef'', ''aes-256-cbc'')) AS x;\n+----------------------------------+\n| x |\n+----------------------------------+\n| 42A3EB91E6DFC40A900D278F99E0726E |\n+----------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/encryption-hashing-and-compression-functions/aes_encrypt', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/encryption-hashing-and-compression-functions/aes_encrypt'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (279, 35, 'COMPRESS', 'Syntax\n------\n\nCOMPRESS(string_to_compress)\n\nDescription\n-----------\n\nCompresses a string and returns the result as a binary string. This function requires MariaDB to have been compiled with a compression library such as zlib. Otherwise, the return value is always NULL. The\\\ncompressed string can be uncompressed with UNCOMPRESS().\n\nThe have_compress server system variable indicates whether a compression library is present.\n\nExamples\n--------\n\nSELECT LENGTH(COMPRESS(REPEAT(''a'',1000)));\n+------------------------------------+\n| LENGTH(COMPRESS(REPEAT(''a'',1000))) |\n+------------------------------------+\n| 21 |\n+------------------------------------+\n\nSELECT LENGTH(COMPRESS(''''));\n+----------------------+\n| LENGTH(COMPRESS('''')) |\n+----------------------+\n| 0 |\n+----------------------+\n\nSELECT LENGTH(COMPRESS(''a''));\n+-----------------------+\n| LENGTH(COMPRESS(''a'')) |\n+-----------------------+\n| 13 |\n+-----------------------+\n\nSELECT LENGTH(COMPRESS(REPEAT(''a'',16)));\n+----------------------------------+\n| LENGTH(COMPRESS(REPEAT(''a'',16))) |\n+----------------------------------+\n| 15 |\n+----------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/encryption-hashing-and-compression-functions/compress', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/encryption-hashing-and-compression-functions/compress'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (280, 35, 'DECODE', 'Syntax\n------\n\nDECODE(crypt_str,pass_str)\n\nDescription\n-----------\n\nIn the default mode, DECODE decrypts the encrypted string _crypt_str_ using _pass_str_ as the password. _crypt_str_ should be a string returned from ENCODE(). The resulting string will be the original string only if _pass_str_ is the same.\n\nIn Oracle mode, DECODE compares _expr_ to the search expressions, in order. If it finds a match, the corresponding result expression is returned. If no matches are found, the default expression is returned, or NULL if no default is provided.\n\nNULL values are treated as equivalent.\n\nDECODE_ORACLE is a synonym for the Oracle-mode version of the function, and is available in all modes.\n\nExamples\n--------\n\nSELECT DECODE_ORACLE(2+1,31,''found1'',32,''found2'',''default'');\n+--------------------------------------------------------+\n| DECODE_ORACLE(2+1,31,''found1'',32,''found2'',''default'') |\n+--------------------------------------------------------+\n| found1 |\n+--------------------------------------------------------+\n\nSELECT DECODE_ORACLE(2+4,31,''found1'',32,''found2'',''default'');\n+--------------------------------------------------------+\n| DECODE_ORACLE(2+4,31,''found1'',32,''found2'',''default'') |\n+--------------------------------------------------------+\n| found2 |\n+--------------------------------------------------------+\n\nSELECT DECODE_ORACLE(2+2,31,''found1'',32,''found2'',''default'');\n+--------------------------------------------------------+\n| DECODE_ORACLE(2+2,31,''found1'',32,''found2'',''default'') |\n+--------------------------------------------------------+\n| default |\n+--------------------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/encryption-hashing-and-compression-functions/decode', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/encryption-hashing-and-compression-functions/decode'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (281, 35, 'DES\\_DECRYPT', 'Syntax\n------\n\nDES_DECRYPT(crypt_str[,key_str])\n\nDescription\n-----------\n\nDecrypts a string encrypted with DES_ENCRYPT(). If an error occurs, this function returns NULL.\n\nThis function works only if MariaDB has been configured with TLS support.\n\nIf no key_str argument is given, DES_DECRYPT() examines the first byte of the encrypted string to determine the DES key number that was used to encrypt the original string, and then reads the key from the DES key file to decrypt the message. For this to work, the user must have the SUPER privilege. The key file can be specified with the--des-key-file server option.\n\nIf you pass this function a key_str argument, that string is used as the key for decrypting the message.\n\nIf the crypt_str argument does not appear to be an encrypted string, MariaDB returns the given crypt_str.\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/encryption-hashing-and-compression-functions/des_decrypt', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/encryption-hashing-and-compression-functions/des_decrypt'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (282, 35, 'DES\\_ENCRYPT', 'Syntax\n------\n\nDES_ENCRYPT(str[,{key_num|key_str}])\n\nDescription\n-----------\n\nEncrypts the string with the given key using the Triple-DES algorithm.\n\nThis function works only if MariaDB has been configured with TLS support.\n\nThe encryption key to use is chosen based on the second argument toDES_ENCRYPT(), if one was given. With no argument, the first key from the DES key file is used. With a _key_num_ argument, the given key\\\nnumber (0-9) from the DES key file is used. With a _key_str_ argument, the given key string is used to encrypt _str_.\n\nThe key file can be specified with the --des-key-file server option.\n\nThe return string is a binary string where the first character isCHAR(128 | key_num). If an error occurs, DES_ENCRYPT() returns NULL.\n\nThe 128 is added to make it easier to recognize an encrypted key. If you use a string key, _key_num_ is 127.\n\nThe string length for the result is given by this formula:\n\n``sql\nnew_len = orig_len + (8 - (orig_len % 8)) + 1\n`\n\nEach line in the DES key file has the following format:\n\n`sql\nkey_num des_key_str\n`\n\nEach _key_num_ value must be a number in the range from 0 to 9. Lines in the file may be in any order. _des_key_str_ is the string that is used to encrypt the message. There should be at least one space between the number and the key. The first key is the default key that is used if you do not specify any key argument to DES_ENCRYPT().\n\nYou can tell MariaDB to read new key values from the key file with the FLUSH DES_KEY_FILE` statement. This requires the RELOAD privilege.\n\nOne benefit of having a set of default keys is that it gives applications a way to check for the existence of encrypted column values, without giving the end user the right to decrypt those values.\n\nExamples\n--------\n\nSELECT customer_address FROM customer_table \n WHERE crypted_credit_card = DES_ENCRYPT(''credit_card_number'');\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/encryption-hashing-and-compression-functions/des_encrypt', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/encryption-hashing-and-compression-functions/des_encrypt'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (283, 35, 'ENCODE', 'Syntax\n------\n\nENCODE(str,pass_str)\n\nDescription\n-----------\n\nENCODE is not considered cryptographically secure, and should not be used for password encryption.\n\nEncrypt str using pass_str as the password. To decrypt the result, use DECODE().\n\nThe result is a binary string of the same length as str.\n\nThe strength of the encryption is based on how good the random generator is.\n\nIt is not recommended to rely on the encryption performed by the ENCODE function. Using a salt value (changed when a password is updated) will improve matters somewhat, but for storing passwords, consider a more cryptographically secure function, such as SHA2().\n\nExamples\n--------\n\nENCODE(''not so secret text'', CONCAT(''random_salt'',''password''))\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/encryption-hashing-and-compression-functions/encode', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/encryption-hashing-and-compression-functions/encode'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (284, 35, 'ENCRYPT', 'Syntax\n------\n\nENCRYPT(str[,salt])\n\nDescription\n-----------\n\nEncrypts a string using the Unix crypt() system call, returning an encrypted binary string. The salt argument should be a string with at least two characters or the returned result will be NULL. If no salt argument is given, a random value of sufficient length is used.\n\nIt is not recommended to use ENCRYPT() with utf16, utf32 or ucs2 multi-byte character sets because the crypt() system call expects a string terminated with a zero byte.\n\nNote that the underlying crypt() system call may have some limitations, such as ignoring all but the first eight characters.\n\nIf the have_crypt system variable is set to NO (because the crypt() system call is not available), the ENCRYPT function will always return NULL.\n\nExamples\n--------\n\nSELECT ENCRYPT(''encrypt me'');\n+-----------------------+\n| ENCRYPT(''encrypt me'') |\n+-----------------------+\n| 4I5BsEx0lqTDk |\n+-----------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/encryption-hashing-and-compression-functions/encrypt', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/encryption-hashing-and-compression-functions/encrypt'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (285, 35, 'KDF', 'Syntax\n------\n\nKDF(key_str, salt [, {info | iterations} [, kdf_name [, width ]]])\n\nDescription\n-----------\n\nKDF is a key derivation function, similar to OpenSSL''s EVP_KDF_derive(). The purpose of a KDF is to be slow, so if the calculated value is lost/stolen, the original key_str is not achievable easily with modern GPU. KDFs are therefore an ideal replacement for password hashes. KDFs can also pad out a password secret to the number of bits used in encryption algorithms.\n\nFor generating good encryption keys for AES_ENCRYPT a less expensive but cryptographically secure function like RANDOM_BYTES is recommended.\n\n kdf_name is "hkdf" or "pbkdf2_hmac" (default).\n Width (in bits) can be any number divisible by 8, by default it''s taken from @@block_encryption_mode.\n* Iterations must be positive, and is 1000 by default.\n\nNote that OpenSSL 1.0 doesn''t support HKDF, so in this case NULL is returned. This OpenSSL version is still used in SLES 12 and CentOS 7.\n\nExamples\n--------\n\nselect hex(kdf(''foo'', ''bar'', ''infa'', ''hkdf'')); \n+----------------------------------------+\n| hex(kdf(''foo'', ''bar'', ''infa'', ''hkdf'')) |\n+----------------------------------------+\n| 612875F859CFB4EE0DFEFF9F2A18E836 |\n+----------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/encryption-hashing-and-compression-functions/kdf', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/encryption-hashing-and-compression-functions/kdf'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (286, 35, 'MD5', 'Syntax\n------\n\nMD5(str)\n\nDescription\n-----------\n\nCalculates an MD5 128-bit checksum for the string.\n\nThe return value is a 32-hex digit string, and a nonbinary string in the connection character set and collation, determined by the values of the character_set_connection and collation_connection system variables.\n\nNULL is returned if the argument was NULL.\n\nDon''t use this function as an encryption function.\n\nMD5 can be used as a checksum to verify data integrity against unintentional corruption. Historically it was widely used as a cryptographic hash function; however it has been found to suffer from extensive vulnerabilities.\n\nSee https://en.wikipedia.org/wiki/MD5 for details.\n\nExamples\n--------\n\nSELECT MD5(''testing'');\n+----------------------------------+\n| MD5(''testing'') |\n+----------------------------------+\n| ae2b1fca515949e5d54fb22b8ed95575 |\n+----------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/encryption-hashing-and-compression-functions/md5', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/encryption-hashing-and-compression-functions/md5'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (287, 35, 'OLD\\_PASSWORD', 'Syntax\n------\n\nOLD_PASSWORD(str)\n\nDescription\n-----------\n\nOLD_PASSWORD() was added to MySQL when the implementation of PASSWORD() was changed to improve security. OLD_PASSWORD() returns the value of the old (pre-MySQL 4.1) implementation of PASSWORD() as a string, and is intended to permit you to reset passwords for any pre-4.1 clients that need to connect to a more recent MySQL server version, or any version of MariaDB, without locking them out.\n\nThe return value is a nonbinary string in the connection character set and collation, determined by the values of the character_set_connection and collation_connection system variables.\n\nThe return value is 16 bytes in length, or NULL if the argument was NULL.\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/encryption-hashing-and-compression-functions/old_password', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/encryption-hashing-and-compression-functions/old_password'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (288, 35, 'PASSWORD', 'Syntax\n------\n\nPASSWORD(str)\n\nDescription\n-----------\n\nThe PASSWORD() function is used for hashing passwords for use in authentication by the MariaDB server. It is not intended for use in other applications.\n\nCalculates and returns a hashed password string from the plaintext password _str_. Returns an empty string if the argument is NULL.\n\nThe return value is a nonbinary string in the connection character set and collation, determined by the values of the character_set_connection and collation_connection system variables.\n\nThis is the function that is used for hashing MariaDB passwords for storage in the Password column of the user table (see privileges), usually used with the SET PASSWORD statement. It is not intended for use in other applications.\n\nThe function takes into account the authentication plugin where applicable (a CREATE USER or SET PASSWORD statement). For example, when used in conjunction with a user authenticated by the ed25519 plugin, the statement will create a longer hash:\n\n``sql\nCREATE USER edtest@localhost IDENTIFIED VIA ed25519 USING PASSWORD(''secret'');\n\nCREATE USER edtest2@localhost IDENTIFIED BY ''secret'';\n\nSELECT CONCAT(user, ''@'', host, '' => '', JSON_DETAILED(priv)) FROM mysql.global_priv\n WHERE user LIKE ''edtest%''\\G\n************************ 1. row *********************\nCONCAT(user, ''@'', host, '' => '', JSON_DETAILED(priv)): edtest@localhost => {\n...\n "plugin": "ed25519",\n "authentication_string": "ZIgUREUg5PVgQ6LskhXmO+eZLS0nC8be6HPjYWR4YJY",\n...\n}\n********************* 2. row ***********************\nCONCAT(user, ''@'', host, '' => '', JSON_DETAILED(priv)): edtest2@localhost => {\n...\n "plugin": "mysql_native_password",\n "authentication_string": "14E65567ABDB5135D0CFD9A70B3032C179A49EE7",\n...\n}\n`\n\nThe behavior of this function is affected by the value of the old_passwords system variable. If this is set to 1 (0` is default), MariaDB reverts to using the mysql_old_password authentication plugin by default for newly created users and passwords.\n\nExamples\n--------\n\nSELECT PASSWORD(''notagoodpwd'');\n+-------------------------------------------+\n| PASSWORD(''notagoodpwd'') |\n+-------------------------------------------+\n| *3A70EE9FC6594F88CE9E959CD51C5A1C002DC937 |\n+-------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/encryption-hashing-and-compression-functions/password', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/encryption-hashing-and-compression-functions/password'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (289, 35, 'RANDOM\\_BYTES', 'Syntax\n------\n\nRANDOM_BYTES(length)\n\nDescription\n-----------\n\nGiven a _length_ from 1 to 1024, generates a binary string of _length_ consisting of random bytes generated by the SSL library''s random number generator.\n\nSee the RAND_bytes() function documentation of your SSL library for information on the random number generator. In the case of OpenSSL, a cryptographically secure pseudo random generator (CSPRNG) is used.\n\nStatements containing the RANDOM_BYTES function are unsafe for statement-based replication.\n\nAn error occurs if _length_ is outside the range 1 to 1024.\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/encryption-hashing-and-compression-functions/random_bytes', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/encryption-hashing-and-compression-functions/random_bytes'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (290, 35, 'SHA1', 'Syntax\n------\n\nSHA1(str), SHA(str)\n\nDescription\n-----------\n\nCalculates an SHA-1 160-bit checksum for the string _str_, as described in RFC 3174 (Secure Hash Algorithm).\n\nThe value is returned as a string of 40 hex digits, or NULL if the argument was NULL. The return value is a nonbinary string in the connection character set and collation, determined by the values of the character_set_connection and collation_connection system variables.\n\nExamples\n--------\n\nSELECT SHA1(''some boring text'');\n+------------------------------------------+\n| SHA1(''some boring text'') |\n+------------------------------------------+\n| af969fc2085b1bb6d31e517d5c456def5cdd7093 |\n+------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/encryption-hashing-and-compression-functions/sha1', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/encryption-hashing-and-compression-functions/sha1'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (291, 35, 'SHA2', 'Syntax\n------\n\nSHA2(str,hash_len)\n\nDescription\n-----------\n\nGiven a string _str_, calculates an SHA-2 checksum, which is considered more cryptographically secure than its SHA-1 equivalent. The SHA-2 family includes SHA-224, SHA-256, SHA-384, and SHA-512, and the _hash_len_ must correspond to one of these, i.e. 224, 256, 384 or 512. 0 is equivalent to 256.\n\nThe return value is a nonbinary string in the connection character set and collation, determined by the values of the character_set_connection and collation_connection system variables.\n\nNULL is returned if the hash length is not valid, or the string str is NULL.\n\nSHA2 only works if MariaDB is configured with TLS support.\n\nExamples\n--------\n\nSELECT SHA2(''Maria'',224);\n+----------------------------------------------------------+\n| SHA2(''Maria'',224) |\n+----------------------------------------------------------+\n| 6cc67add32286412efcab9d0e1675a43a5c2ef3cec8879f81516ff83 |\n+----------------------------------------------------------+\n\nSELECT SHA2(''Maria'',256);\n+------------------------------------------------------------------+\n| SHA2(''Maria'',256) |\n+------------------------------------------------------------------+\n| 9ff18ebe7449349f358e3af0b57cf7a032c1c6b2272cb2656ff85eb112232f16 |\n+------------------------------------------------------------------+\n\nSELECT SHA2(''Maria'',0);\n+------------------------------------------------------------------+\n| SHA2(''Maria'',0) |\n+------------------------------------------------------------------+\n| 9ff18ebe7449349f358e3af0b57cf7a032c1c6b2272cb2656ff85eb112232f16 |\n+------------------------------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/encryption-hashing-and-compression-functions/sha2', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/encryption-hashing-and-compression-functions/sha2'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (292, 35, 'UNCOMPRESS', 'Syntax\n------\n\nUNCOMPRESS(string_to_uncompress)\n\nDescription\n-----------\n\nUncompresses a string compressed by the COMPRESS() function. If the argument is not a compressed value, the result is NULL. This function requires MariaDB to have been compiled with a compression library such as zlib. Otherwise, the return value is always NULL. The have_compress server system variable indicates whether a compression library is present.\n\nExamples\n--------\n\nSELECT UNCOMPRESS(COMPRESS(''a string''));\n+----------------------------------+\n| UNCOMPRESS(COMPRESS(''a string'')) |\n+----------------------------------+\n| a string |\n+----------------------------------+\n\nSELECT UNCOMPRESS(''a string'');\n+------------------------+\n| UNCOMPRESS(''a string'') |\n+------------------------+\n| NULL |\n+------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/encryption-hashing-and-compression-functions/uncompress', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/encryption-hashing-and-compression-functions/uncompress'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (293, 35, 'UNCOMPRESSED\\_LENGTH', 'Syntax\n------\n\nUNCOMPRESSED_LENGTH(compressed_string)\n\nDescription\n-----------\n\nReturns the length that the compressed string had before being compressed with COMPRESS().\n\nUNCOMPRESSED_LENGTH() returns NULL or an incorrect result if the string is not compressed.\n\nReturns MYSQL_TYPE_LONG, or int(10), if the result fits within 32-bits.\n\nExamples\n--------\n\nSELECT UNCOMPRESSED_LENGTH(COMPRESS(REPEAT(''a'',30)));\n+-----------------------------------------------+\n| UNCOMPRESSED_LENGTH(COMPRESS(REPEAT(''a'',30))) |\n+-----------------------------------------------+\n| 30 |\n+-----------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/encryption-hashing-and-compression-functions/uncompressed_length', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/encryption-hashing-and-compression-functions/uncompressed_length'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (294, 17, 'BENCHMARK', 'Syntax\n------\n\nBENCHMARK(count,expr)\n\nDescription\n-----------\n\nThe BENCHMARK() function executes the expression expr repeatedly count times. It may be used to time how quickly MariaDB processes the expression. The result value is always 0. The intended use is from within the mariadb client, which reports query execution times.\n\nExamples\n--------\n\nSELECT BENCHMARK(1000000,ENCODE(''hello'',''goodbye''));\n+----------------------------------------------+\n| BENCHMARK(1000000,ENCODE(''hello'',''goodbye'')) |\n+----------------------------------------------+\n| 0 |\n+----------------------------------------------+\n1 row in set (0.21 sec)\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions/benchmark', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions/benchmark'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (295, 17, 'BINLOG\\_GTID\\_POS', 'Syntax\n------\n\nBINLOG_GTID_POS(binlog_filename,binlog_offset)\n\nDescription\n-----------\n\nThe BINLOG_GTID_POS() function takes as input an old-style binary log position in the form of a file name and a file offset. It looks up the position in the current binlog, and returns a string representation of the corresponding GTID position. If the position is not found in the current binlog, NULL is returned.\n\nExamples\n--------\n\nSELECT BINLOG_GTID_POS("master-bin.000001", 600);\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions/binlog_gtid_pos', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions/binlog_gtid_pos'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (296, 17, 'CHARSET', 'Syntax\n------\n\nCHARSET(str)\n\nDescription\n-----------\n\nReturns the character set of the string argument. If str is not a string, it is considered as a binary string (so the function returns ''binary''). This applies to NULL, too. The return value is a string in the utf8 character set.\n\nExamples\n--------\n\nSELECT CHARSET(''abc'');\n+----------------+\n| CHARSET(''abc'') |\n+----------------+\n| latin1 |\n+----------------+\n\nSELECT CHARSET(CONVERT(''abc'' USING utf8));\n+------------------------------------+\n| CHARSET(CONVERT(''abc'' USING utf8)) |\n+------------------------------------+\n| utf8 |\n+------------------------------------+\n\nSELECT CHARSET(USER());\n+-----------------+\n| CHARSET(USER()) |\n+-----------------+\n| utf8 |\n+-----------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions/charset', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions/charset'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (297, 17, 'COERCIBILITY', 'Syntax\n------\n\nCOERCIBILITY(str)\n\nDescription\n-----------\n\nReturns the collation coercibility value of the string argument. Coercibility defines what will be converted to what in case of collation conflict, with an expression with higher coercibility being converted to the collation of an expression with lower coercibility.\n\n| Coercibility | Description | Example |\n| ------------ | --------------- | ----------------------------------------------------------- |\n| 0 | Explicit | Value using a COLLATE clause |\n| 1 | No collation | Concatenated strings using different collations |\n| 2 | Implicit | A string data type column value, CAST to a string data type |\n| 3 | System constant | DATABASE(), USER() return value |\n| 4 | Coercible | Literal string |\n| 5 | Numeric | Numeric and temporal values |\n| 6 | Ignorable | NULL or derived from NULL |\n\nExamples\n--------\n\nSELECT COERCIBILITY(_latin1 ''abc'' COLLATE latin1_swedish_ci);\n+-----------------------------------------------+\n| COERCIBILITY(_latin1 ''abc'' COLLATE latin1_swedish_ci) |\n+-----------------------------------------------+\n| 0 |\n+-----------------------------------------------+\n\nCREATE TABLE t (a VARCHAR(30) COLLATE uca1400_swedish_ai_ci, b VARCHAR(30) COLLATE uca1400_german2_ai_ci) CHARSET utf8mb4;\nINSERT INTO t VALUES (''abc'', ''def''); / a 2 coercibility /\nSELECT COERCIBILITY(CONCAT(a, b)) FROM t;\n+----------------------------+\n| COERCIBILITY(CONCAT(a, b)) |\n+----------------------------+\n| 1 |\n+----------------------------+\n\nSELECT COERCIBILITY(CAST(1 AS CHAR));\n+-------------------------------+\n| COERCIBILITY(CAST(1 AS CHAR)) |\n+-------------------------------+\n| 2 |\n+-------------------------------+\n\nSELECT COERCIBILITY(USER());\n+----------------------+\n| COERCIBILITY(USER()) |\n+----------------------+\n| 3 |\n+----------------------+\n\nSELECT COERCIBILITY(''abc'');\n+---------------------+\n| COERCIBILITY(''abc'') |\n+---------------------+\n| 4 |\n+---------------------+\n\nSELECT COERCIBILITY(1);\n+-----------------+\n| COERCIBILITY(1) |\n+-----------------+\n| 5 |\n+-----------------+\n\nSELECT COERCIBILITY(NULL);\n+--------------------+\n| COERCIBILITY(NULL) |\n+--------------------+\n| 6 |\n+--------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions/coercibility', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions/coercibility'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (298, 17, 'COLLATION', 'Syntax\n------\n\nCOLLATION(str)\n\nDescription\n-----------\n\nReturns the collation of the string argument. If str is not a string, it is considered as a binary string (so the function returns ''binary''). This applies to NULL, too. The return value is a string in the utf8 character set.\n\nSee Character Sets and Collations.\n\nExamples\n--------\n\nSELECT COLLATION(''abc'');\n+-------------------+\n| COLLATION(''abc'') |\n+-------------------+\n| latin1_swedish_ci |\n+-------------------+\n\nSELECT COLLATION(_utf8''abc'');\n+-----------------------+\n| COLLATION(_utf8''abc'') |\n+-----------------------+\n| utf8_general_ci |\n+-----------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions/collation', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions/collation'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (299, 17, 'CONNECTION\\_ID', 'Syntax\n------\n\nCONNECTION_ID()\n\nDescription\n-----------\n\nReturns the connection ID for the connection. Every connection (including events) has an ID that is unique among the set of currently connected clients.\n\nReturns MYSQL_TYPE_LONG, or int(10).\n\nExamples\n--------\n\nSELECT CONNECTION_ID();\n+-----------------+\n| CONNECTION_ID() |\n+-----------------+\n| 3 |\n+-----------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions/connection_id', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions/connection_id'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (300, 17, 'CURRENT\\_ROLE', 'Syntax\n------\n\nCURRENT_ROLE, CURRENT_ROLE()\n\nDescription\n-----------\n\nReturns the current role name. The return value is a string in the\\\nutf8 character set.\n\nIf there is no current role, NULL is returned.\n\nUSER() returns the combination of user and host used to login. CURRENT_USER() returns the account used to determine current connection''s privileges.\n\nStatements using the CURRENT_ROLE function are not safe for statement-based replication.\n\nExamples\n--------\n\nSELECT CURRENT_ROLE;\n+--------------+\n| CURRENT_ROLE |\n+--------------+\n| NULL |\n+--------------+\n\nSET ROLE staff;\n\nSELECT CURRENT_ROLE;\n+--------------+\n| CURRENT_ROLE |\n+--------------+\n| staff |\n+--------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions/current_role', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions/current_role'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (301, 17, 'CURRENT\\_USER', 'Syntax\n------\n\nCURRENT_USER, CURRENT_USER()\n\nDescription\n-----------\n\nReturns the user name and host name combination for the MariaDB account that the server used to authenticate the current client. This account determines your access privileges. The return value is a string in the utf8 character set.\n\nThe value of CURRENT_USER() can differ from the value of USER(). CURRENT_ROLE() returns the current active role.\n\nStatements using the CURRENT_USER function are not safe for statement-based replication.\n\nExamples\n--------\n\nshell> mysql --user="anonymous"\n\nSELECT USER(),CURRENT_USER();\n+---------------------+----------------+\n| USER() | CURRENT_USER() |\n+---------------------+----------------+\n| anonymous@localhost | @localhost |\n+---------------------+----------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions/current_user', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions/current_user'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (302, 17, 'DATABASE', 'Syntax\n------\n\nDATABASE()\nSCHEMA()\n\nDescription\n-----------\n\nReturns the default (current) database name as a string in the utf8 character set. If there is no default database, DATABASE() returns NULL. Within a stored routine, the default database is the database that the routine is associated with, which is not necessarily the same as the database that is the default in the calling context.\n\nSCHEMA() is a synonym for DATABASE().\n\nTo select a default database, the USE statement can be run. Another way to set the default database is specifying its name at mariadb command line client startup.\n\nExamples\n--------\n\nSELECT DATABASE();\n+------------+\n| DATABASE() |\n+------------+\n| NULL |\n+------------+\n\nUSE test;\nDatabase changed\n\nSELECT DATABASE();\n+------------+\n| DATABASE() |\n+------------+\n| test |\n+------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions/database', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions/database'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (303, 17, 'DECODE\\_HISTOGRAM', 'Syntax\n------\n\nDECODE_HISTOGRAM(hist_type,histogram)\n\nDescription\n-----------\n\nReturns a string of comma separated numeric values corresponding to a probability distribution represented by the histogram of type hist_type (SINGLE_PREC_HB or DOUBLE_PREC_HB). The hist_type and histogram would be commonly used from the mysql.column_stats table.\n\nSee Histogram Based Statistics for details.\n\nExamples\n--------\n\nCREATE TABLE origin (\n i INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,\n v INT UNSIGNED NOT NULL\n);\n\nINSERT INTO origin(v) VALUES \n (1),(2),(3),(4),(5),(10),(20),\n (30),(40),(50),(60),(70),(80),\n (90),(100),(200),(400),(800);\n\nSET histogram_size=10,histogram_type=SINGLE_PREC_HB;\n\nANALYZE TABLE origin PERSISTENT FOR ALL;\n+-------------+---------+----------+-----------------------------------------+\n| Table | Op | Msg_type | Msg_text |\n+-------------+---------+----------+-----------------------------------------+\n| test.origin | analyze | status | Engine-independent statistics collected |\n| test.origin | analyze | status | OK |\n+-------------+---------+----------+-----------------------------------------+\n\nSELECT db_name,table_name,column_name,hist_type,\n hex(histogram),decode_histogram(hist_type,histogram) \n FROM mysql.column_stats WHERE db_name=''test'' and table_name=''origin'';\n+---------+------------+-------------+----------------+----------------------+-------------------------------------------------------------------+\n| db_name | table_name | column_name | hist_type | hex(histogram) | decode_histogram(hist_type,histogram) |\n+---------+------------+-------------+----------------+----------------------+-------------------------------------------------------------------+\n| test | origin | i | SINGLE_PREC_HB | 0F2D3C5A7887A5C3D2F0 | 0.059,0.118,0.059,0.118,0.118,0.059,0.118,0.118,0.059,0.118,0.059 |\n| test | origin | v | SINGLE_PREC_HB | 000001060C0F161C1F7F | 0.000,0.000,0.004,0.020,0.024,0.012,0.027,0.024,0.012,0.376,0.502 |\n+---------+------------+-------------+----------------+----------------------+-------------------------------------------------------------------+\n\nSET histogram_size=20,histogram_type=DOUBLE_PREC_HB;\n\nANALYZE TABLE origin PERSISTENT FOR ALL;\n+-------------+---------+----------+-----------------------------------------+\n| Table | Op | Msg_type | Msg_text |\n+-------------+---------+----------+-----------------------------------------+\n| test.origin | analyze | status | Engine-independent statistics collected |\n| test.origin | analyze | status | OK |\n+-------------+---------+----------+-----------------------------------------+\n\nSELECT db_name,table_name,column_name,\n hist_type,hex(histogram),decode_histogram(hist_type,histogram) \n FROM mysql.column_stats WHERE db_name=''test'' and table_name=''origin'';\n+---------+------------+-------------+----------------+------------------------------------------+-----------------------------------------------------------------------------------------+\n| db_name | table_name | column_name | hist_type | hex(histogram) | decode_histogram(hist_type,histogram) |\n+---------+------------+-------------+----------------+------------------------------------------+-----------------------------------------------------------------------------------------+\n| test | origin | i | DOUBLE_PREC_HB | 0F0F2D2D3C3C5A5A78788787A5A5C3C3D2D2F0F0 | 0.05882,0.11765,0.05882,0.11765,0.11765,0.05882,0.11765,0.11765,0.05882,0.11765,0.05882 |\n| test | origin | v | DOUBLE_PREC_HB | 5200F600480116067E0CB30F1B16831CB81FD67F | 0.00125,0.00250,0.00125,0.01877,0.02502,0.01253,0.02502,0.02502,0.01253,0.37546,0.50063 |\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions/decode_histogram', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions/decode_histogram'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (304, 17, 'DEFAULT', 'Syntax\n------\n\nDEFAULT(col_name)\n\nDescription\n-----------\n\nReturns the default value for a table column. If the column has no default value (and is not NULLABLE - NULLABLE fields have a NULL default), an error is returned.\n\nFor integer columns using AUTO_INCREMENT, 0 is returned.\n\nWhen using DEFAULT as a value to set in an INSERT or UPDATE statement, you can use the bare keyword DEFAULT without the parentheses and argument to refer to the column in context. You can only use DEFAULT as a bare keyword if you are using it alone without a surrounding expression or function.\n\nExamples\n--------\n\nSELECT i FROM t WHERE i != DEFAULT(i);\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions/default', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions/default'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (305, 17, 'FOUND\\_ROWS', 'Syntax\n------\n\nFOUND_ROWS()\n\nDescription\n-----------\n\nA SELECT statement may include a LIMIT clause to restrict the number of rows the server returns to the client. In some cases, it is desirable to know how many rows the statement would have returned without the LIMIT, but without running the statement again. To obtain this row count, include an SQL_CALC_FOUND_ROWS option in the SELECT statement, and then invoke FOUND_ROWS() afterwards.\n\nYou can also use FOUND_ROWS() to obtain the number of rows returned by a SELECT which does not contain a LIMIT clause. In this case you don''t need to use the SQL_CALC_FOUND_ROWS option. This can be useful for example in a stored procedure.\n\nAlso, this function works with some other statements which return a result set, including SHOW, DESC and HELP. For DELETE ... RETURNING you should use ROW_COUNT(). It also works as a prepared statement, or after executing a prepared statement.\n\nStatements which don''t return any results don''t affect FOUND_ROWS() - the previous value will still be returned.\n\nWarning: When used after a CALL statement, this function returns the number of rows selected by the last query in the procedure, not by the whole procedure.\n\nStatements using the FOUND_ROWS() function are not safe for statement-based replication.\n\nExamples\n--------\n\nSHOW ENGINES\\G\n************************ 1. row *********************\n Engine: CSV\n Support: YES\n Comment: Stores tables as CSV files\nTransactions: NO\n XA: NO\n Savepoints: NO\n********************* 2. row *********************\n Engine: MRG_MyISAM\n Support: YES\n Comment: Collection of identical MyISAM tables\nTransactions: NO\n XA: NO\n Savepoints: NO\n\n...\n\n********************* 8. row ************************\n Engine: PERFORMANCE_SCHEMA\n Support: YES\n Comment: Performance Schema\nTransactions: NO\n XA: NO\n Savepoints: NO\n8 rows in set (0.000 sec)\n\nSELECT FOUND_ROWS();\n+--------------+\n| FOUND_ROWS() |\n+--------------+\n| 8 |\n+--------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions/found_rows', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions/found_rows'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (306, 17, 'LAST\\_INSERT\\_ID', 'Syntax\n------\n\nLAST_INSERT_ID(), LAST_INSERT_ID(expr)\n\nDescription\n-----------\n\nLAST_INSERT_ID() (no arguments) returns the first automatically generated value successfully inserted for an AUTO_INCREMENT column as a result of the most recently executed INSERT\\\nstatement. The value of LAST_INSERT_ID() remains unchanged if no rows are successfully inserted.\n\nIf one gives an argument to LAST_INSERT_ID(), then it will return the value of the expression and\\\nthe next call to LAST_INSERT_ID() will return the same value. The value is also sent to the client\\\nand can be accessed by the mysql_insert_id function.\n\nFor example, after inserting a row that generates an AUTO_INCREMENT value, you can get the value like this:\n\n``sql\nSELECT LAST_INSERT_ID();\n+------------------+\n| LAST_INSERT_ID() |\n+------------------+\n| 9 |\n+------------------+\n`\n\nYou can also use LAST_INSERT_ID() to delete the last inserted row:\n\n`sql\nDELETE FROM product WHERE id = LAST_INSERT_ID();\n`\n\nIf no rows were successfully inserted, LAST_INSERT_ID() returns 0.\n\nYou can also use INSERT...RETURNING for this purpose.\n\nThe value of LAST_INSERT_ID() will be consistent across all versions if all rows in the INSERT or UPDATE statement were successful.\n\nThe currently executing statement does not affect the value of LAST_INSERT_ID(). Suppose that you generate an AUTO_INCREMENT value with one statement, and then refer to LAST_INSERT_ID() in a\\\nmultiple-row INSERT statement that inserts rows into a table with its own AUTO_INCREMENT column. The value of LAST_INSERT_ID() will remain stable in the second statement; its value for the second and later rows is not affected by the earlier row insertions. (However, if you mix references to LAST_INSERT_ID() and LAST_INSERT_ID(expr), the effect is undefined.)\n\nIf the previous statement returned an error, the value of LAST_INSERT_ID() is undefined. For transactional tables, if the statement is rolled back due to an error, the value of LAST_INSERT_ID() is left undefined. For manual ROLLBACK, the value of LAST_INSERT_ID() is not restored to that before the transaction; it remains as it was at the point of the ROLLBACK.\n\nWithin the body of a stored routine (procedure or function) or a trigger, the value of LAST_INSERT_ID() changes the same way as for statements executed outside the body of these kinds of objects. The\\\neffect of a stored routine or trigger upon the value of LAST_INSERT_ID() that is seen by following statements depends on the kind of routine:\n\n If a stored procedure executes statements that change the value of LAST_INSERT_ID()`, the new value will be seen by statements that follow the procedure call.\n For stored functions and triggers that change the value, the value is restored when the function or trigger ends, so following statements will not see a changed value.\n\nExamples\n--------\n\nCREATE TABLE t (\n id INTEGER UNSIGNED AUTO_INCREMENT PRIMARY KEY, \n f VARCHAR(1)) \nENGINE = InnoDB;\n\nINSERT INTO t(f) VALUES(''a'');\n\nSELECT LAST_INSERT_ID();\n+------------------+\n| LAST_INSERT_ID() |\n+------------------+\n| 1 |\n+------------------+\n\nINSERT INTO t(f) VALUES(''b'');\n\nINSERT INTO t(f) VALUES(''c'');\n\nSELECT LAST_INSERT_ID();\n+------------------+\n| LAST_INSERT_ID() |\n+------------------+\n| 3 |\n+------------------+\n\nINSERT INTO t(f) VALUES(''d''),(''e'');\n\nSELECT LAST_INSERT_ID();\n+------------------+\n| LAST_INSERT_ID() |\n+------------------+\n| 4 |\n+------------------+\n\nSELECT FROM t;\n+----+------+\n| id | f |\n+----+------+\n| 1 | a |\n| 2 | b |\n| 3 | c |\n| 4 | d |\n| 5 | e |\n+----+------+\n\nSELECT LAST_INSERT_ID(12);\n+--------------------+\n| LAST_INSERT_ID(12) |\n+--------------------+\n| 12 |\n+--------------------+\n\nSELECT LAST_INSERT_ID();\n+------------------+\n| LAST_INSERT_ID() |\n+------------------+\n| 12 |\n+------------------+\n\nINSERT INTO t(f) VALUES(''f'');\n\nSELECT LAST_INSERT_ID();\n+------------------+\n| LAST_INSERT_ID() |\n+------------------+\n| 6 |\n+------------------+\n\nSELECT FROM t;\n+----+------+\n| id | f |\n+----+------+\n| 1 | a |\n| 2 | b |\n| 3 | c |\n| 4 | d |\n| 5 | e |\n| 6 | f |\n+----+------+\n\nSELECT LAST_INSERT_ID(12);\n+--------------------+\n| LAST_INSERT_ID(12) |\n+--------------------+\n| 12 |\n+--------------------+\n\nINSERT INTO t(f) VALUES(''g'');\n\nSELECT * FROM t;\n+----+------+\n| id | f |\n+----+------+\n| 1 | a |\n| 2 | b |\n| 3 | c |\n| 4 | d |\n| 5 | e |\n| 6 | f |\n| 7 | g |\n+----+------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions/last_insert_id', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions/last_insert_id'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (307, 17, 'LAST\\_VALUE', 'Syntax\n------\n\nLAST_VALUE(expr,[expr,...])\n\nDescription\n-----------\n\nLAST_VALUE() evaluates all expressions and returns the last. This is useful together with setting user variables to a value with @var:=expr, for example when you want to get data of rows updated/deleted without having to do two queries against the table.\n\nLAST_VALUE can be used as a window function.\n\nReturns NULL if no last value exists.\n\nExamples\n--------\n\nCREATE TABLE t1 (a int, b int);\nINSERT INTO t1 VALUES(1,10),(2,20);\nDELETE FROM t1 WHERE a=1 AND last_value(@a:=a,@b:=b,1);\nSELECT @a,@b;\n+------+------+\n| @a | @b |\n+------+------+\n| 1 | 10 |\n+------+------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions/last_value', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions/last_value'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (308, 17, 'PROCEDURE ANALYSE', 'Syntax\n------\n\nANALYSE([max_elements[,max_memory]])\n\nDescription\n-----------\n\nThis procedure is defined in the sql/sql_analyse.cc file. It examines the result from a query and returns an analysis of the results that suggests optimal data types for each column. To obtain this analysis, append PROCEDURE ANALYSE to the end of a SELECT statement:\n\n``sql\nSELECT ... FROM ... WHERE ... PROCEDURE ANALYSE([max_elements,[max_memory]])\n`\n\nFor example:\n\n`sql\nSELECT col1, col2 FROM table1 PROCEDURE ANALYSE(10, 2000);\n`\n\nThe results show some statistics for the values returned by the query, and propose an optimal data type for the columns. This can be helpful for checking your existing tables, or after importing new data. You may need to try different settings for the arguments so that PROCEDURE ANALYSE() does not suggest the ENUM data type when it is not appropriate.\n\nThe arguments are optional and are used as follows:\n\n max_elements (default 256) is the maximum number of distinct values that analyse notices per column. This is used by analyse to check whether the optimal data type should be of type ENUM; if there are more than max_elements distinct values, then ENUM` is not a suggested type.\n max_memory (default 8192) is the maximum amount of memory that analyse should allocate per column while trying to find all distinct values.\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions/procedure-analyse', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions/procedure-analyse'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (309, 17, 'ROW\\_COUNT', 'Syntax\n------\n\nROW_COUNT()\n\nDescription\n-----------\n\nROW_COUNT() returns the number of rows updated, inserted or deleted by the preceding statement. This is the same as the row count that the mariadb client displays and the value from the mysql_affected_rows() C API function.\n\nGenerally:\n\n For statements which return a result set (such as SELECT, SHOW, DESC or HELP), returns -1, even when the result set is empty. This is also true for administrative statements, such as OPTIMIZE.\n For DML statements other than SELECT and for ALTER TABLE, returns the number of affected rows.\n For DDL statements (including TRUNCATE) and for other statements which don''t return any result set (such as USE, DO, SIGNAL or DEALLOCATE PREPARE), returns 0.\n\nFor UPDATE, affected rows is by default the number of rows that were actually changed. If the CLIENT_FOUND_ROWS flag to mysql_real_connect() is specified when connecting to mariadbd, affected rows is instead the number of rows matched by the WHERE clause.\n\nFor REPLACE, deleted rows are also counted. So, if REPLACE deletes a row and adds a new row, ROW_COUNT() returns 2.\n\nFor INSERT ... ON DUPLICATE KEY, values returned are as follows:\n\n 0: an existing row is set to its current values, and the CLIENT_FOUND_ROWS is not set.\n 1: the values are inserted as a new row, or an existing row is set to its current values, and the CLIENT_FOUND_ROWS is set.\n 2: an existing row is updated with new values.\n\nROW_COUNT() does not take into account rows that are not directly deleted/updated by the last statement. This means that rows deleted by foreign keys or triggers are not counted.\n\nWarning: You can use ROW_COUNT() with prepared statements, but you need to call it after EXECUTE, not after DEALLOCATE PREPARE, because the row count for allocate prepare is always 0.\n\nWarning: When used after a CALL statement, this function returns the number of rows affected by the last statement in the procedure, not by the whole procedure.\n\nWarning: After INSERT DELAYED, ROW_COUNT() returns the number of the rows you tried to insert, not the number of the successful writes.\n\nThis information can also be found in the diagnostics area.\n\nStatements using the ROW_COUNT() function are not safe for statement-based replication.\n\nExamples\n--------\n\nCREATE TABLE t (A INT);\n\nINSERT INTO t VALUES(1),(2),(3);\n\nSELECT ROW_COUNT();\n+-------------+\n| ROW_COUNT() |\n+-------------+\n| 3 |\n+-------------+\n\nDELETE FROM t WHERE A IN(1,2);\n\nSELECT ROW_COUNT(); \n+-------------+\n| ROW_COUNT() |\n+-------------+\n| 2 |\n+-------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions/row_count', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions/row_count'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (310, 17, 'ROWNUM', 'Syntax\n------\n\nROWNUM()\n\nDescription\n-----------\n\nROWNUM() returns the current number of accepted rows in the current context. It main purpose is to emulate the ROWNUM pseudo column in Oracle. For MariaDB native applications, we recommend the usage of LIMIT, as it is easier to use and gives more predictable results than the usage of ROWNUM().\n\nThe main difference between using LIMIT andROWNUM() to limit the rows in the result is thatLIMIT works on the result set while ROWNUM works on the number of accepted rows (before any ORDER orGROUP BY clauses).\n\nThe following queries will return the same results:\n\n``sql\nSELECT FROM t1 LIMIT 10;\nSELECT FROM t1 WHERE ROWNUM() <= 10;\n`\n\nWhile the following may return different results based on in which orders the rows are found:\n\n`sql\nSELECT FROM t1 ORDER BY a LIMIT 10;\nSELECT FROM t1 ORDER BY a WHERE ROWNUM() <= 10;\n`\n\nThe recommended way to use ROWNUM to limit the number of returned rows and get predictable results is to have the query in a subquery and test for ROWNUM() in the outer query:\n\n`sql\nSELECT FROM (SELECT FROM t1 ORDER BY a) WHERE ROWNUM() <= 10;\n`\n\nROWNUM() can be used in the following contexts:\n\n SELECT\n INSERT\n UPDATE\n DELETE\n* LOAD DATA INFILE\n\nUsed in other contexts, ROWNUM()` will return 0.\n\nExamples\n--------\n\nINSERT INTO t1 VALUES (1,ROWNUM()),(2,ROWNUM()),(3,ROWNUM());\n\nINSERT INTO t1 VALUES (1),(2) RETURNING a, ROWNUM();\n\nUPDATE t1 SET row_num_column=ROWNUM();\n\nDELETE FROM t1 WHERE a < 10 AND ROWNUM() < 2;\n\nLOAD DATA INFILE ''filename'' INTO TABLE t1 fields terminated BY '','' \n lines terminated BY "\\r\\n" (a,b) SET c=ROWNUM();\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions/rownum', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions/rownum'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (311, 17, 'SCHEMA', 'Syntax\n------\n\nSCHEMA()\n\nDescription\n-----------\n\nThis function is a synonym for DATABASE().\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions/schema', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions/schema'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (312, 17, 'SESSION\\_USER', 'Syntax\n------\n\nSESSION_USER()\n\nDescription\n-----------\n\nShows the value of CURRENT_USER() when the session was created, that is, it shows a user@host pair from the mysql.global_priv table, like CURRENT_USER(), but unlike CURRENT_USER() it will not change inside stored routines and views. This is SQL Standard behavior for the SESSION_USER function.\n\nSESSION_USER() is a synonym for USER().\n\nBackward-compatible behavior can be restored by setting old mode to SESSION_USER_IS_USER.\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions/session_user', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions/session_user'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (313, 17, 'SYSTEM\\_USER', 'Syntax\n------\n\nSYSTEM_USER()\n\nDescription\n-----------\n\nSYSTEM_USER() is a synonym for USER().\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions/system_user', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions/system_user'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (314, 17, 'USER', 'Syntax\n------\n\nUSER()\n\nDescription\n-----------\n\nReturns the current MariaDB user name and host name, given when authenticating to MariaDB, as a string in the utf8 character set.\n\nThe value of USER() may differ from the value of CURRENT_USER(), which is the user used to authenticate the current client. CURRENT_ROLE() returns the currently active role.\n\nSYSTEM_USER() is a synonym for USER().\n\nSYSTEM_USER() and SESSION_USER are synonyms for USER().\n\nStatements using the USER() function or one of its synonyms are not safe for statement level replication.\n\nExamples\n--------\n\nshell> mysql --user="anonymous"\n\nSELECT USER(),CURRENT_USER();\n+---------------------+----------------+\n| USER() | CURRENT_USER() |\n+---------------------+----------------+\n| anonymous@localhost | @localhost |\n+---------------------+----------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions/user', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions/user'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (315, 17, 'VERSION', 'Syntax\n------\n\nVERSION()\n\nDescription\n-----------\n\nReturns a string that indicates the MariaDB server version. The string uses the utf8 character set.\n\nExamples\n--------\n\nSELECT VERSION();\n+----------------+\n| VERSION() |\n+----------------+\n| 10.4.7-MariaDB |\n+----------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions/version', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions/version'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (316, 14, 'GET\\_LOCK', 'Syntax\n------\n\nGET_LOCK(str,timeout)\n\nDescription\n-----------\n\nTries to obtain a lock with a name given by the string str, using a timeout of timeout seconds. Returns 1 if the lock was obtained successfully, 0 if the attempt timed out (for example, because another client has previously locked the name), or NULL if an error occurred (such as running out of memory or the thread was killed with mariadb-admin kill).\n\nA lock is released with RELEASE_LOCK(), when the connection terminates (either normally or abnormally). A connection can hold multiple locks at the same time, so a lock that is no longer needed needs to be explicitly released.\n\nThe IS_FREE_LOCK function returns whether a specified lock is free or not, and the IS_USED_LOCK whether the function is in use or not.\n\nLocks obtained with GET_LOCK() do not interact with transactions. That is, committing a transaction does not release any such locks obtained during the transaction.\n\nIt is also possible to recursively set the same lock. If a lock with the same name is set n times, it needs to be released n times as well.\n\nstr is case insensitive for GET_LOCK() and related functions. If str is an empty string or NULL, GET_LOCK() returns NULL and does nothing. timeout supports microseconds.\n\nIf the metadata_lock_info plugin is installed, locks acquired with this function are visible in the Information Schema METADATA_LOCK_INFO table.\n\nThis function can be used to implement application locks or to simulate record locks. Names are locked on a server-wide basis. If a name has been locked by one client, GET_LOCK() blocks any request by another client for a lock with the same name. This allows clients that agree on a given lock name to use the name to perform cooperative advisory locking. But be aware that it also allows a client that is not among the set of cooperating clients to lock a name, either inadvertently or deliberately, and thus prevent any of the cooperating clients from locking that name. One way to reduce the likelihood of this is to use lock names that are database-specific or application-specific. For example, use lock names of the form db_name.str or app_name.str.\n\nStatements using the GET_LOCK function are not safe for statement-based replication.\n\nThe patch to permit multiple locks was contributed by Konstantin "Kostja" Osipov (MDEV-3917).\n\nExamples\n--------\n\nSELECT GET_LOCK(''lock1'',10);\n+----------------------+\n| GET_LOCK(''lock1'',10) |\n+----------------------+\n| 1 |\n+----------------------+\n\nSELECT IS_FREE_LOCK(''lock1''), IS_USED_LOCK(''lock1'');\n+-----------------------+-----------------------+\n| IS_FREE_LOCK(''lock1'') | IS_USED_LOCK(''lock1'') |\n+-----------------------+-----------------------+\n| 0 | 46 |\n+-----------------------+-----------------------+\n\nSELECT IS_FREE_LOCK(''lock2''), IS_USED_LOCK(''lock2'');\n+-----------------------+-----------------------+\n| IS_FREE_LOCK(''lock2'') | IS_USED_LOCK(''lock2'') |\n+-----------------------+-----------------------+\n| 1 | NULL |\n+-----------------------+-----------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/get_lock', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/get_lock'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (317, 14, 'INET6\\_ATON', 'Syntax\n------\n\nINET6_ATON(expr)\n\nDescription\n-----------\n\nGiven an IPv6 or IPv4 network address as a string, returns a binary string that represents the numeric value of the address.\n\nNo trailing zone ID''s or traling network masks are permitted. For IPv4 addresses, or IPv6 addresses with IPv4 address parts, no classful addresses or trailing port numbers are permitted and octal numbers are not supported.\n\nThe returned binary string will be VARBINARY(16) or VARBINARY(4) for IPv6 and IPv4 addresses respectively.\n\nReturns NULL if the argument is not understood.\n\nMariaDB starting with 10.5.0\n\nINET6_ATON can take INET6 as an argument.\n\nINET6_ATON cannot take INET6 as an argument.\n\nExamples\n--------\n\nSELECT HEX(INET6_ATON(''10.0.1.1''));\n+-----------------------------+\n| HEX(INET6_ATON(''10.0.1.1'')) |\n+-----------------------------+\n| 0A000101 |\n+-----------------------------+\n\nSELECT HEX(INET6_ATON(''48f3::d432:1431:ba23:846f''));\n+----------------------------------------------+\n| HEX(INET6_ATON(''48f3::d432:1431:ba23:846f'')) |\n+----------------------------------------------+\n| 48F3000000000000D4321431BA23846F |\n+----------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/inet6_aton', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/inet6_aton'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (318, 14, 'INET6\\_NTOA', 'Syntax\n------\n\nINET6_NTOA(expr)\n\nDescription\n-----------\n\nGiven an IPv6 or IPv4 network address as a numeric binary string, returns the address as a nonbinary string in the connection character set.\n\nThe return string is lowercase, and is platform independent, since it does not use functions specific to the operating system. It has a maximum length of 39 characters.\n\nReturns NULL if the argument is not understood.\n\nExamples\n--------\n\nSELECT INET6_NTOA(UNHEX(''0A000101''));\n+-------------------------------+\n| INET6_NTOA(UNHEX(''0A000101'')) |\n+-------------------------------+\n| 10.0.1.1 |\n+-------------------------------+\n\nSELECT INET6_NTOA(UNHEX(''48F3000000000000D4321431BA23846F''));\n+-------------------------------------------------------+\n| INET6_NTOA(UNHEX(''48F3000000000000D4321431BA23846F'')) |\n+-------------------------------------------------------+\n| 48f3::d432:1431:ba23:846f |\n+-------------------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/inet6_ntoa', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/inet6_ntoa'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (319, 14, 'INET\\_ATON', 'Syntax\n------\n\nINET_ATON(expr)\n\nDescription\n-----------\n\nGiven the dotted-quad representation of an IPv4 network address as a string, returns an integer that represents the numeric value of the address. Addresses may be 4- or 8-byte addresses.\n\nReturns NULL if the argument is not understood.\n\nExamples\n--------\n\nSELECT INET_ATON(''192.168.1.1'');\n+--------------------------+\n| INET_ATON(''192.168.1.1'') |\n+--------------------------+\n| 3232235777 |\n+--------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/inet_aton', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/inet_aton'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (320, 14, 'INET\\_NTOA', 'Syntax\n------\n\nINET_NTOA(expr)\n\nDescription\n-----------\n\nGiven a numeric IPv4 network address in network byte order (4 or 8 byte), returns the dotted-quad representation of the address as a string.\n\nExamples\n--------\n\nSELECT INET_NTOA(3232235777);\n+-----------------------+\n| INET_NTOA(3232235777) |\n+-----------------------+\n| 192.168.1.1 |\n+-----------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/inet_ntoa', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/inet_ntoa'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (321, 14, 'IS\\_FREE\\_LOCK', 'Syntax\n------\n\nIS_FREE_LOCK(str)\n\nDescription\n-----------\n\nChecks whether the lock named str is free to use (that is, not locked). Returns 1 if the lock is free (no one is using the lock),0 if the lock is in use, and NULL if an error occurs (such as an incorrect argument, like an empty string or NULL). str is case insensitive.\n\nIf the metadata_lock_info plugin is installed, the Information Schema metadata_lock_info table contains information about locks of this kind (as well as metadata locks).\n\nStatements using the IS_FREE_LOCK function are not safe for statement-based replication.\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/is_free_lock', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/is_free_lock'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (322, 14, 'IS\\_IPV4', 'Syntax\n------\n\nIS_IPV4(expr)\n\nDescription\n-----------\n\nIf the expression is a valid IPv4 address, returns 1, otherwise returns 0.\n\nIS_IPV4() is stricter than INET_ATON(), but as strict as INET6_ATON(), in determining the validity of an IPv4 address. This implies that if IS_IPV4 returns 1, the same expression will always return a non-NULL result when passed to INET_ATON(), but that the reverse may not apply.\n\nExamples\n--------\n\nSELECT IS_IPV4(''1110.0.1.1'');\n+-----------------------+\n| IS_IPV4(''1110.0.1.1'') |\n+-----------------------+\n| 0 |\n+-----------------------+\n\nSELECT IS_IPV4(''48f3::d432:1431:ba23:846f'');\n+--------------------------------------+\n| IS_IPV4(''48f3::d432:1431:ba23:846f'') |\n+--------------------------------------+\n| 0 |\n+--------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/is_ipv4', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/is_ipv4'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (323, 14, 'IS\\_IPV4\\_COMPAT', 'Syntax\n------\n\nIS_IPV4_COMPAT(expr)\n\nDescription\n-----------\n\nReturns 1 if a given numeric binary string IPv6 address, such as returned by INET6_ATON(), is IPv4-compatible, otherwise returns 0.\n\nWhen the argument is not INET6, automatic implicit CAST to INET6 is applied. As a consequence, IS_IPV4_COMPAT now understands arguments in both text representation and binary(16) representation.\n\nThe function understands only binary(16) representation.\n\nExamples\n--------\n\nSELECT IS_IPV4_COMPAT(INET6_ATON(''::10.0.1.1''));\n+------------------------------------------+\n| IS_IPV4_COMPAT(INET6_ATON(''::10.0.1.1'')) |\n+------------------------------------------+\n| 1 |\n+------------------------------------------+\n\nSELECT IS_IPV4_COMPAT(INET6_ATON(''::48f3::d432:1431:ba23:846f''));\n+-----------------------------------------------------------+\n| IS_IPV4_COMPAT(INET6_ATON(''::48f3::d432:1431:ba23:846f'')) |\n+-----------------------------------------------------------+\n| 0 |\n+-----------------------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/is_ipv4_compat', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/is_ipv4_compat'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (324, 14, 'IS\\_IPV4\\_MAPPED', 'Syntax\n------\n\nIS_IPV4_MAPPED(expr)\n\nDescription\n-----------\n\nReturns 1 if a given a numeric binary string IPv6 address, such as returned by INET6_ATON(), is a valid IPv4-mapped address, otherwise returns 0.\n\nWhen the argument is not INET6, automatic implicit CAST to INET6 is applied. As a consequence, IS_IPV4_MAPPED now understands arguments in both text representation and binary(16) representation.\n\nThe function understands only binary(16) representation.\n\nExamples\n--------\n\nSELECT IS_IPV4_MAPPED(INET6_ATON(''::10.0.1.1''));\n+------------------------------------------+\n| IS_IPV4_MAPPED(INET6_ATON(''::10.0.1.1'')) |\n+------------------------------------------+\n| 0 |\n+------------------------------------------+\n\nSELECT IS_IPV4_MAPPED(INET6_ATON(''::ffff:10.0.1.1''));\n+-----------------------------------------------+\n| IS_IPV4_MAPPED(INET6_ATON(''::ffff:10.0.1.1'')) |\n+-----------------------------------------------+\n| 1 |\n+-----------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/is_ipv4_mapped', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/is_ipv4_mapped'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (325, 14, 'IS\\_IPV6', 'Syntax\n------\n\nIS_IPV6(expr)\n\nDescription\n-----------\n\nReturns 1 if the expression is a valid IPv6 address specified as a string, otherwise returns 0. Does not consider IPv4 addresses to be valid IPv6 addresses.\n\nExamples\n--------\n\nSELECT IS_IPV6(''48f3::d432:1431:ba23:846f'');\n+--------------------------------------+\n| IS_IPV6(''48f3::d432:1431:ba23:846f'') |\n+--------------------------------------+\n| 1 |\n+--------------------------------------+\n1 row in set (0.02 sec)\n\nSELECT IS_IPV6(''10.0.1.1'');\n+---------------------+\n| IS_IPV6(''10.0.1.1'') |\n+---------------------+\n| 0 |\n+---------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/is_ipv6', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/is_ipv6'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (326, 14, 'IS\\_USED\\_LOCK', 'Syntax\n------\n\nIS_USED_LOCK(str)\n\nDescription\n-----------\n\nChecks whether the lock named str is in use (that is, locked). If so, it returns the connection identifier of the client that holds the lock. Otherwise, it returns NULL. str is case insensitive.\n\nIf the metadata_lock_info plugin is installed, the Information Schema metadata_lock_info table contains information about locks of this kind (as well as metadata locks).\n\nStatements using the IS_USED_LOCK function are not safe for statement-based replication.\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/is_used_lock', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/is_used_lock'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (327, 14, 'MASTER\\_GTID\\_WAIT', 'Syntax\n------\n\nMASTER_GTID_WAIT(gtid-list, timeout)\n\nDescription\n-----------\n\nThis function takes a string containing a comma-separated list of [global transaction id''s (similar to the value of, for example, gtid_binlog_pos). It waits until the value of gtid_slave_pos has the same or higher seq_no within all replication domains specified in the gtid-list; in other words, it waits until the replica has reached the specified GTID position.\n\nAn optional second argument gives a timeout in seconds. If the timeout expires before the specified GTID position is reached, then the function returns -1. Passing NULL or a negative number for the timeout means no timeout, and the function will wait indefinitely.\n\nIf the wait completes without a timeout, 0 is returned. Passing NULL for the gtid-list makes the function return NULL immediately, without waiting.\n\nThe gtid-list may be the empty string, in which case MASTER_GTID_WAIT() returns immediately. If the gtid-list contains fewer domains than gtid_slave_pos, then only those domains are waited upon. If gtid-list contains a domain that is not present in @@gtid_slave_pos, then MASTER_GTID_WAIT() will wait until an event containing such domain_id arrives on the replica (or until timed out or killed).\n\nMASTER_GTID_WAIT() can be useful to ensure that a replica has caught up to a master. Simply take the value of gtid_binlog_pos on the master, and use it in a MASTER_GTID_WAIT() call on the replica; when the call completes, the replica will have caught up with that master position.\n\nMASTER_GTID_WAIT() can also be used in client applications together with the last_gtid session variable. This is useful in a read-scaleout replication setup, where the application writes to a single master but divides the reads out to a number of replica to distribute the load. In such a setup, there\\\nis a risk that an application could first do an update on the master, and then a bit later do a read on a replica, and if the replica is not fast enough, the data read from the slave might not include the update just made, possibly confusing the application and/or the end-user. One way to avoid this is to request the value of last_gtid on the master just after the update. Then before doing the read on the replica, do a MASTER_GTID_WAIT() on the value obtained from the master; this will ensure that the read is not performed until the replica has replicated sufficiently far for the update to have become visible.\n\nNote that MASTER_GTID_WAIT() can be used even if the replica is configured not to use GTID for connections (CHANGE MASTER TO master_use_gtid=no). This is because from MariaDB 10, GTIDs are always logged on the master server, and always recorded on the replica servers.\n\nDifferences to MASTER_POS_WAIT()\n\n MASTER_GTID_WAIT() is global; it waits for any master connection to reach the specified GTID position. MASTER_POS_WAIT() works only against a specific connection. This also means that while MASTER_POS_WAIT() aborts if its master connection is terminated with STOP REPLICA or due to an error, MASTER_GTID_WAIT() continues to wait while replicas are stopped.\n MASTER_GTID_WAIT() can take its timeout as a floating-point value, so a timeout in fractional seconds is supported, eg. MASTER_GTID_WAIT("0-1-100", 0.5). (The minimum wait is one microsecond, 0.000001 seconds).\n MASTER_GTID_WAIT() allows one to specify a timeout of zero in order to do a non-blocking check to see if the replicas have progressed to a specific GTID position (MASTER_POS_WAIT() takes a zero timeout as meaning an infinite wait). To do an infinite MASTER_GTID_WAIT(), specify a negative timeout, or omit the timeout argument.\n MASTER_GTID_WAIT() does not return the number of events executed since the wait started, nor does it return NULL if a replica thread is stopped. It always returns either 0 for successful wait completed, or -1 for timeout reached (or NULL if the specified gtid-pos is NULL).\n\nSince MASTER_GTID_WAIT() looks only at the seq_no part of the GTIDs, not the server_id, care is needed if a replica becomes diverged from another server so that two different GTIDs with the same seq_no (in the same domain) arrive at the same server. This situation is in any case best avoided; setting gtid_strict_mode is recommended, as this will prevent any such out-of-order sequence numbers from ever being replicated on a replica.\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/master_gtid_wait', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/master_gtid_wait'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (328, 14, 'MASTER\\_POS\\_WAIT', 'Syntax\n------\n\nMASTER_POS_WAIT(log_name,log_pos[,timeout,["connection_name"]])\n\nDescription\n-----------\n\nThis function is useful in replication for controlling primary/replica synchronization. It blocks until the replica has read and applied all updates up to the specified position (log_name,log_pos) in the primary log. The return value is the number of log events the replica had to wait for to advance to the specified position. The function returns NULL if the replica SQL thread is not started, the replica''s primary information is not initialized, the arguments are incorrect, or an error occurs. It returns -1 if\\\nthe timeout has been exceeded. If the replica SQL thread stops whileMASTER_POS_WAIT() is waiting, the function returns NULL. If the replica is past the specified position, the function returns immediately.\n\nIf a timeout value is specified, MASTER_POS_WAIT() stops waiting when timeout seconds have elapsed. timeout must be greater than 0; a zero or negative timeout means no timeout.\n\nThe connection_name is used when you are using multi-source-replication. If you don''t specify it, it''s set to the value of the default_master_connection system variable.\n\nStatements using the MASTER_POS_WAIT() function are not safe for statement-based replication.\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/master_pos_wait', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/master_pos_wait'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (329, 14, 'FORMAT\\_BYTES', 'Syntax\n------\n\nFORMAT_BYTES(double)\n\nDescription\n-----------\n\nGiven a byte count, returns a string consisting of a value and the units in a human-readable format. The units will be in bytes, KiB (kibibytes), MiB (mebibytes), GiB (gibibytes), TiB (tebibytes), PiB (pebibytes) or EiB (exbibytes).\n\nThe binary prefixes (kibi, mebi, gibi, tebi, pebi and exbi) were created in December 1998 by the International Electrotechnical Commission to avoid possible ambiguity, as the widely-used prefixes kilo, mega, giga, tera, peta and exa can be used to refer to both the power-of-10 decimal system multipliers and the power-of-two binary system multipliers.\n\nThis function is similar to the Sys Schema format_bytes function, except that function does not display exbibytes.\n\nExamples\n--------\n\nSELECT FORMAT_BYTES(1000)FORMAT_BYTES(1024);\n+--------------------+--------------------+\n| FORMAT_BYTES(1000) | FORMAT_BYTES(1024) |\n+--------------------+--------------------+\n| 1000 bytes | 1.00 KiB |\n+--------------------+--------------------+\n\nSELECT FORMAT_BYTES(1000000),FORMAT_BYTES(1048576);\n+-----------------------+-----------------------+\n| FORMAT_BYTES(1000000) | FORMAT_BYTES(1048576) |\n+-----------------------+-----------------------+\n| 976.56 KiB | 1.00 MiB |\n+-----------------------+-----------------------+\n\nSELECT FORMAT_BYTES(1000000000),FORMAT_BYTES(1073741874);\n+--------------------------+--------------------------+\n| FORMAT_BYTES(1000000000) | FORMAT_BYTES(1073741874) |\n+--------------------------+--------------------------+\n| 953.67 MiB | 1.00 GiB |\n+--------------------------+--------------------------+\n\nSELECT FORMAT_BYTES(1000000000000),FORMAT_BYTES(1099511627776);\n+-----------------------------+-----------------------------+\n| FORMAT_BYTES(1000000000000) | FORMAT_BYTES(1099511627776) |\n+-----------------------------+-----------------------------+\n| 931.32 GiB | 1.00 TiB |\n+-----------------------------+-----------------------------+\n\nSELECT FORMAT_BYTES(1000000000000000),FORMAT_BYTES(1125899906842624);\n+--------------------------------+--------------------------------+\n| FORMAT_BYTES(1000000000000000) | FORMAT_BYTES(1125899906842624) |\n+--------------------------------+--------------------------------+\n| 909.49 TiB | 1.00 PiB |\n+--------------------------------+--------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/miscellaneous-functions-format_bytes', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/miscellaneous-functions-format_bytes'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (330, 14, 'NAME\\_CONST', 'Syntax\n------\n\nNAME_CONST(name,value)\n\nDescription\n-----------\n\nReturns the given value. When used to produce a result set column,NAME_CONST() causes the column to have the given name. The arguments should be constants.\n\nThis function is used internally when replicating stored procedures. It makes little sense to use it explicitly in SQL statements, and it was not supposed to be used like that.\n\n``sql\nSELECT NAME_CONST(''myname'', 14);\n+--------+\n| myname |\n+--------+\n| 14 |\n+--------+\n``\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/name_const', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/name_const'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (331, 14, 'OLD\\_VALUE', 'Syntax\n------\n\nOLD_VALUE(val)\n\nDescription\n-----------\n\nIn the RETURNING clause of an UPDATE statement, OLD_VALUE() returns the value before the update. The function is meaningful only in this context.\n\nExamples\n--------\n\nUPDATE t SET a=a+1 RETURNING OLD_VALUE(a) AS old, a as new;\n+------+------+\n| old | new |\n+------+------+\n| 1 | 2 |\n+------+------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/old-value', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/old-value'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (332, 14, 'RELEASE\\_ALL\\_LOCKS', 'Syntax\n------\n\nRELEASE_ALL_LOCKS()\n\nDescription\n-----------\n\nReleases all named locks held by the current session. Returns the number of locks released, or 0 if none were held.\n\nStatements using the RELEASE_ALL_LOCKS function are not safe for statement-based replication.\n\nExamples\n--------\n\nSELECT RELEASE_ALL_LOCKS();\n+---------------------+\n| RELEASE_ALL_LOCKS() | \n+---------------------+\n| 0 |\n+---------------------+\n\nSELECT GET_LOCK(''lock1'',10);\n+----------------------+\n| GET_LOCK(''lock1'',10) |\n+----------------------+\n| 1 |\n+----------------------+\n\nSELECT RELEASE_ALL_LOCKS();\n+---------------------+\n| RELEASE_ALL_LOCKS() | \n+---------------------+\n| 1 |\n+---------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/release_all_locks', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/release_all_locks'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (333, 14, 'RELEASE\\_LOCK', 'Syntax\n------\n\nRELEASE_LOCK(str)\n\nDescription\n-----------\n\nReleases the lock named by the string str that was obtained with GET_LOCK(). Returns 1 if the lock was released, 0 if the lock was not established by this connection (in which case the lock is not released), and NULL if the named lock did not exist. The lock does not exist if it was never obtained by a call to GET_LOCK() or if it has previously been released.\n\nstr is case insensitive. If str is an empty string or NULL, RELEASE_LOCK() returns NULL and does nothing.\n\nStatements using the RELEASE_LOCK function are not safe for statement-based replication.\n\nThe DO statement is convenient to use with RELEASE_LOCK().\n\nExamples\n--------\n\nSELECT GET_LOCK(''lock1'',10);\n+----------------------+\n| GET_LOCK(''lock1'',10) |\n+----------------------+\n| 1 |\n+----------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/release_lock', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/release_lock'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (334, 14, 'SLEEP', 'Syntax\n------\n\nSLEEP(duration)\n\nDescription\n-----------\n\nSleeps (pauses) for the number of seconds given by the duration argument, then returns 0. If SLEEP() is interrupted, it returns 1. The duration may have a fractional part given in microseconds.\n\nStatements using the SLEEP() function are not safe for statement-based replication.\n\nExamples\n--------\n\nSELECT SLEEP(5.5);\n+------------+\n| SLEEP(5.5) |\n+------------+\n| 0 |\n+------------+\n1 row in set (5.50 sec)\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/sleep', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/sleep'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (335, 14, 'SYS\\_GUID', 'Syntax\n------\n\nSYS_GUID()\n\nDescription\n-----------\n\nReturns a 16-byte globally unique identifier (GUID), similar to the UUID function, but without the - character.\n\nExamples\n--------\n\nSELECT SYS_GUID();\n+----------------------------------+\n| SYS_GUID() |\n+----------------------------------+\n| 2C574E45BA2811EBB265F859713E4BE4 |\n+----------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/sys_guid', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/sys_guid'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (336, 14, 'UUID', 'Syntax\n------\n\nUUID()\n\nDescription\n-----------\n\nReturns a Universally Unique Identifier (UUID) version 1. Functions to generate v4 and v7 UUIDs are available from MariaDB 11.7. See UUIDv4 and UUIDv7 respectively.\n\nA UUID is designed as a number that is globally unique in space and time. Two calls to UUID() are expected to generate two different values, even if these calls are performed on two separate computers that are not connected to each other.\n\nUUID() results are intended to be unique, but cannot always be relied upon to be unpredictable and unguessable.\n\nA UUID is a 128-bit number represented by a utf8 string of five hexadecimal numbers in aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee format:\n\n The first three numbers are generated from a timestamp.\n The fourth number preserves temporal uniqueness in case the timestamp value\\\n loses monotonicity (for example, due to daylight saving time).\n* The fifth number is an IEEE 802 node number that provides spatial uniqueness.\\\n A random number is substituted if the latter is not available (for example,\\\n because the host computer has no Ethernet card, or we do not know how to find\\\n the hardware address of an interface on your operating system). In this case,\\\n spatial uniqueness cannot be guaranteed. Nevertheless, a collision should\\\n have very low probability.\n\nCurrently, the MAC address of an interface is taken into account only on FreeBSD and Linux. On other operating systems, MariaDB uses a randomly generated 48-bit number.\n\nStatements using the UUID() function are not safe for statement-based replication.\n\nThe function generates a UUIDv1 and the results are generated according to the "DCE 1.1:Remote Procedure Call" (Appendix A) CAE (Common Applications Environment) Specifications published by The Open Group in October 1997 (Document Number C706).\n\nExamples\n--------\n\nSELECT UUID();\n+--------------------------------------+\n| UUID() |\n+--------------------------------------+\n| cd41294a-afb0-11df-bc9b-00241dd75637 |\n+--------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/uuid', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/uuid'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (337, 14, 'UUID\\_SHORT', 'Syntax\n------\n\nUUID_SHORT()\n\nDescription\n-----------\n\nReturns a "short" universally unique identifier as a 64-bit unsigned integer (rather than a string-form 128-bit identifier as returned by the UUID() function).\n\nThe value of UUID_SHORT() is guaranteed to be unique if the following conditions hold:\n\n The server_id of the current host is unique among your set of master and replica servers.\n server_id is between 0 and 255.\n You don''t set back your system time for your server between mariadbd restarts.\n You do not invoke UUID_SHORT() on average more than 16 million times per second between mariadbd restarts\n\nThe UUID_SHORT() return value is constructed this way:\n\n``sql\n(server_id & 255) << 56\n+ (server_startup_time_in_seconds << 24)\n+ incremented_variable++;\n``\n\nStatements using the UUID_SHORT() function are not safe for statement-based replication.\n\nExamples\n--------\n\nSELECT UUID_SHORT();\n+-------------------+\n| UUID_SHORT() |\n+-------------------+\n| 21517162376069120 |\n+-------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/uuid_short', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/uuid_short'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (338, 14, 'UUID\\_v4', 'Syntax\n------\n\nUUID_v4()\n\nDescription\n-----------\n\nReturns a Universally Unique Identifier (UUID) version 4. To generate a version 1 UUID, see the UUID function. To generate a version 7 UUID, see UUIDv7.\n\nA UUID is designed as a number that is globally unique in space and time. Two calls to UUID() are expected to generate two different values, even if these calls are performed on two separate computers that are not connected to each other.\n\nUUID_v4() results are intended to be unique, but cannot always be relied upon to be unpredictable and unguessable.\n\nA UUID is a 128-bit number represented by a utf8 string of five hexadecimal numbers in aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee format.\n\nStatements using the UUID_v4() function are not safe for statement-based replication.\n\nExamples\n--------\n\nSELECT UUID(),UUID_v4(),UUID_v7()\\G \n************************ 1. row ************************\n UUID(): 63ae8c92-799a-11ef-98b2-f859713e4be4\nUUID_v4(): a2443495-1b94-415b-b6fa-fe8e79ba4812\nUUID_v7(): 01921e85-f198-7490-9b89-7dd0d468543b\n\nCREATE TABLE t1 (a INT PRIMARY KEY NOT NULL, u UUID DEFAULT UUID_v4(), UNIQUE KEY(u));\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/uuid_v4', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/uuid_v4'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (339, 14, 'UUID\\_v7', 'Syntax\n------\n\nUUID_v7()\n\nDescription\n-----------\n\nReturns a Universally Unique Identifier (UUID) version 7. To generate a version 1 UUID, see the UUID function. To generate a version 4 UUID, see UUID_v4.\n\nA UUID is designed as a number that is globally unique in space and time. Two calls to UUID() are expected to generate two different values, even if these calls are performed on two separate computers that are not connected to each other.\n\nA UUID is a 128-bit number represented by a utf8 string of five hexadecimal numbers in aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee format.\n\nStatements using the UUID_v7() function are not safe for statement-based replication.\n\nExamples\n--------\n\nSELECT UUID(),UUID_v4(),UUID_v7()\\G \n************************ 1. row ************************\n UUID(): 63ae8c92-799a-11ef-98b2-f859713e4be4\nUUID_v4(): a2443495-1b94-415b-b6fa-fe8e79ba4812\nUUID_v7(): 01921e85-f198-7490-9b89-7dd0d468543b\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/uuid_v7', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/uuid_v7'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (340, 14, 'VALUES / VALUE', 'Syntax\n------\n\nVALUE(col_name)\n\nDescription\n-----------\n\nIn an INSERT ... ON DUPLICATE KEY UPDATE statement, you can use the VALUES(col_name) function in the UPDATE clause to refer to column values from the INSERT portion of the statement. In other words, VALUES(col_name) in the UPDATE clause refers to the value of col_name that would be inserted, had no duplicate-key conflict occurred. This function is especially useful in multiple-row inserts.\n\nThe VALUES() function is meaningful only in INSERT ... ON DUPLICATE KEY UPDATE statements and returns NULL otherwise.\n\nThis function was renamed to VALUE(), because it''s incompatible with the standard Table Value Constructors syntax.\n\nThe VALUES() function can still be used but only in INSERT ... ON DUPLICATE KEY UPDATE statements; it''s a syntax error otherwise.\n\nExamples\n--------\n\nINSERT INTO t (a,b,c) VALUES (1,2,3),(4,5,6)\n ON DUPLICATE KEY UPDATE c=VALUE(a)+VALUE(b);\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/values-value', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/values-value'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (341, 35, 'COLUMN\\_ADD', 'Syntax\n------\n\nCOLUMN_ADD(dyncol_blob, column_nr, value [as type], [column_nr, value [as type]]...)\nCOLUMN_ADD(dyncol_blob, column_name, value [as type], [column_name, value [as type]]...)\n\nDescription\n-----------\n\nAdds or updates dynamic columns.\n\n dyncol_blob must be either a valid dynamic columns blob (for example, COLUMN_CREATE returns such blob), or an empty string.\n column_name specifies the name of the column to be added. If dyncol_blob already has a column with this name, it will be overwritten.\n value specifies the new value for the column. Passing a NULL value will cause the column to be deleted.\n as type is optional. See #datatypes section for a discussion about types.\n\nThe return value is a dynamic column blob after the modifications.\n\nExamples\n--------\n\nUPDATE t1 SET dyncol_blob=COLUMN_ADD(dyncol_blob, "column_name", "value") WHERE id=1;\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/dynamic-columns-functions/column_add', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/dynamic-columns-functions/column_add'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (342, 35, 'COLUMN\\_CHECK', 'Syntax\n------\n\nCOLUMN_CHECK(dyncol_blob);\n\nDescription\n-----------\n\nCheck if dyncol_blob is a valid packed dynamic columns blob. Return value of 1 means the blob is valid, return value of 0 means it is not.\n\nRationale:\\\nNormally, one works with valid dynamic column blobs. Functions like COLUMN_CREATE, COLUMN_ADD, COLUMN_DELETE always return valid dynamic column blobs. However, if a dynamic column blob is accidentally truncated, or transcoded from one character set to another, it will be corrupted. This function can be used to check if a value in a blob field is a valid dynamic column blob.\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/dynamic-columns-functions/column_check', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/dynamic-columns-functions/column_check'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (343, 35, 'COLUMN\\_CREATE', 'Syntax\n------\n\nCOLUMN_CREATE(column_nr, value [as type], [column_nr, value [as type]]...)\nCOLUMN_CREATE(column_name, value [as type], [column_name, value [as type]]...)\n\nDescription\n-----------\n\nReturns a dynamic columns blob that stores the specified columns with values.\n\nThe return value is suitable for\n\n storing in a table;\n further modification with other dynamic columns functions.\n\nThe as type part allows one to specify the value type. In most cases, this is redundant because MariaDB will be able to deduce the type of the value. Explicit type specification may be needed when the type of the value is not apparent. For example, a literal ''2012-12-01'' has a CHAR type by default, one will need to specify ''2012-12-01'' AS DATE to have it stored as a date. See Dynamic Columns:Datatypes for further details.\n\nExamples\n--------\n\nINSERT INTO tbl SET dyncol_blob=COLUMN_CREATE("column_name", "value");\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/dynamic-columns-functions/column_create', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/dynamic-columns-functions/column_create'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (344, 35, 'COLUMN\\_DELETE', 'Syntax\n------\n\nCOLUMN_DELETE(dyncol_blob, column_nr, column_nr...)\nCOLUMN_DELETE(dyncol_blob, column_name, column_name...)\n\nDescription\n-----------\n\nDeletes a dynamic column with the specified name. Multiple names can be given. The return value is a dynamic column blob after the modification.\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/dynamic-columns-functions/column_delete', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/dynamic-columns-functions/column_delete'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (345, 35, 'COLUMN\\_EXISTS', 'Syntax\n------\n\nCOLUMN_EXISTS(dyncol_blob, column_nr)\nCOLUMN_EXISTS(dyncol_blob, column_name)\n\nDescription\n-----------\n\nChecks if a column with name column_name exists in dyncol_blob. If yes, return 1, otherwise return 0. See dynamic columns for more information.\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/dynamic-columns-functions/column_exists', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/dynamic-columns-functions/column_exists'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (346, 35, 'COLUMN\\_GET', 'Syntax\n------\n\nCOLUMN_GET(dyncol_blob, column_nr as type)\nCOLUMN_GET(dyncol_blob, column_name as type)\n\nDescription\n-----------\n\nGets the value of a dynamic column by its name. If no column with the given name exists, NULL will be returned.\n\ncolumn_name as type requires that one specify the datatype of the dynamic column they are reading.\n\nThis may seem counter-intuitive: why would one need to specify which datatype they''re retrieving? Can''t the dynamic columns system figure the datatype from the data being stored?\n\nThe answer is: SQL is a statically-typed language. The SQL interpreter needs to know the datatypes of all expressions before the query is run (for example, when one is using prepared statements and runs "select COLUMN_GET(...)", the prepared statement API requires the server to inform the client about the datatype of the column being read before the query is executed and the server can see what datatype the column actually has).\n\nLengths\n\nSuppose running a query like this:\n\n``sql\nSELECT COLUMN_GET(BLOB, ''colname'' AS CHAR) ...\n`\n\nWithout specifying a maximum length (i.e. using as CHAR, not as CHAR(n)`), MariaDB will report the maximum length of the result set column to be 16,777,216. This may cause excessive memory usage in some client libraries, because they try to pre-allocate a buffer of maximum result set width. To avoid this problem, use CHAR(n) whenever you''re using COLUMN_GET in the select list.\n\nSee Dynamic Columns:Datatypes for more information about datatypes.\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/dynamic-columns-functions/column_get', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/dynamic-columns-functions/column_get'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (347, 35, 'COLUMN\\_JSON', 'Syntax\n------\n\nCOLUMN_JSON(dyncol_blob)\n\nDescription\n-----------\n\nReturns a JSON representation of data in dyncol_blob. Can also be used to display nested columns. See dynamic columns for more information.\n\nExamples\n--------\n\nSELECT item_name, COLUMN_JSON(dynamic_cols) FROM assets;\n+-----------------+----------------------------------------+\n| item_name | COLUMN_JSON(dynamic_cols) |\n+-----------------+----------------------------------------+\n| MariaDB T-shirt | {"size":"XL","color":"blue"} |\n| Thinkpad Laptop | {"color":"black","warranty":"3 years"} |\n+-----------------+----------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/dynamic-columns-functions/column_json', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/dynamic-columns-functions/column_json'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (348, 35, 'COLUMN\\_LIST', 'Syntax\n------\n\nCOLUMN_LIST(dyncol_blob);\n\nDescription\n-----------\n\nReturns a comma-separated list of column names. The names are quoted with backticks.\n\nSee dynamic columns for more information.\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/dynamic-columns-functions/column_list', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/dynamic-columns-functions/column_list'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (349, 35, 'WSREP\\_LAST\\_SEEN\\_GTID', 'Syntax\n------\n\nWSREP_LAST_SEEN_GTID()\n\nDescription\n-----------\n\nReturns the Global Transaction ID of the most recent write transaction observed by the client.\n\nThe result can be useful to determine the transaction to provide to WSREP_SYNC_WAIT_UPTO_GTID for waiting and unblocking purposes.\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/galera-functions/wsrep_last_seen_gtid', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/galera-functions/wsrep_last_seen_gtid'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (350, 35, 'WSREP\\_LAST\\_WRITTEN\\_GTID', 'Syntax\n------\n\nWSREP_LAST_WRITTEN_GTID()\n\nDescription\n-----------\n\nReturns the Global Transaction ID of the most recent write transaction performed by the client.\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/galera-functions/wsrep_last_written_gtid', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/galera-functions/wsrep_last_written_gtid'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (351, 35, 'WSREP\\_SYNC\\_WAIT\\_UPTO\\_GTID', 'Syntax\n------\n\nWSREP_SYNC_WAIT_UPTO_GTID(gtid[,timeout])\n\nDescription\n-----------\n\nBlocks the client until the transaction specified by the given Global Transaction ID is applied and committed by the node.\n\nThe optional _timeout_ argument can be used to specify a block timeout in seconds. If not provided, the timeout will be indefinite.\n\nReturns the node that applied and committed the Global Transaction ID, ER_LOCAL_WAIT_TIMEOUT if the function is timed out before this, or ER_WRONG_ARGUMENTS if the function is given an invalid GTID.\n\nThe result from WSREP_LAST_SEEN_GTID can be useful to determine the transaction to provide to WSREP_SYNC_WAIT_UPTO_GTID for waiting and unblocking purposes.\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/galera-functions/wsrep_sync_wait_upto_gtid', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/galera-functions/wsrep_sync_wait_upto_gtid'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (352, 35, 'Geographic Functions', 'Description\n-----------\n\nGeographic and geometry functions. See Geographic Features for a full discussion of MariaDB''s spatial extensions.\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/geographic-functions', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/geographic-functions'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (353, 35, 'Differences between JSON\\_QUERY and JSON\\_VALUE', 'Description\n-----------\n\nThe primary difference between the two functions is that _JSON_QUERY_ returns an object or an array, while _JSON_VALUE_ returns a scalar.\n\nTake the following JSON document as an example:\n\n``sql\nSET @json=''{ "x": [0,1], "y": "[0,1]", "z": "Monty" }'';\n`\n\nNote that data member "x" is an array, and data members "y" and "z" are strings. The following examples demonstrate the differences between the two functions.\n\n`sql\nSELECT JSON_QUERY(@json,''$''), JSON_VALUE(@json,''$'');\n+--------------------------------------------+-----------------------+\n| JSON_QUERY(@json,''$'') | JSON_VALUE(@json,''$'') |\n+--------------------------------------------+-----------------------+\n| { "x": [0,1], "y": "[0,1]", "z": "Monty" } | NULL |\n+--------------------------------------------+-----------------------+\n\nSELECT JSON_QUERY(@json,''$.x''), JSON_VALUE(@json,''$.x'');\n+-------------------------+-------------------------+\n| JSON_QUERY(@json,''$.x'') | JSON_VALUE(@json,''$.x'') |\n+-------------------------+-------------------------+\n| [0,1] | NULL |\n+-------------------------+-------------------------+\n\nSELECT JSON_QUERY(@json,''$.y''), JSON_VALUE(@json,''$.y'');\n+-------------------------+-------------------------+\n| JSON_QUERY(@json,''$.y'') | JSON_VALUE(@json,''$.y'') |\n+-------------------------+-------------------------+\n| NULL | [0,1] |\n+-------------------------+-------------------------+\n\nSELECT JSON_QUERY(@json,''$.z''), JSON_VALUE(@json,''$.z'');\n+-------------------------+-------------------------+\n| JSON_QUERY(@json,''$.z'') | JSON_VALUE(@json,''$.z'') |\n+-------------------------+-------------------------+\n| NULL | Monty |\n+-------------------------+-------------------------+\n\nSELECT JSON_QUERY(@json,''$.x[0]''), JSON_VALUE(@json,''$.x[0]'');\n+----------------------------+----------------------------+\n| JSON_QUERY(@json,''$.x[0]'') | JSON_VALUE(@json,''$.x[0]'') |\n+----------------------------+----------------------------+\n| NULL | 0 |\n+----------------------------+----------------------------+\n``\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/differences-between-json_query-and-json_value', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/differences-between-json_query-and-json_value'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (354, 35, 'JSON Validation Function', 'Description\n-----------\n\nThe IS JSON is a variant of IS predicate that checks whether an expression contains valid JSON data, with optional constraints on JSON type (VALUE, ARRAY, OBJECT, SCALAR) and key uniqueness.\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json-validation-function', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json-validation-function'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (355, 35, 'JSON\\_ARRAY', 'Syntax\n------\n\nJSON_ARRAY([value[, value2] ...])\n\nDescription\n-----------\n\nReturns a JSON array containing the listed values. The list can be empty.\n\nExamples\n--------\n\nSELECT Json_Array(56, 3.1416, ''My name is "Foo"'', NULL);\n+--------------------------------------------------+\n| Json_Array(56, 3.1416, ''My name is "Foo"'', NULL) |\n+--------------------------------------------------+\n| [56, 3.1416, "My name is \\"Foo\\"", null] |\n+--------------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_array', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_array'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (356, 35, 'JSON\\_ARRAY\\_APPEND', 'Syntax\n------\n\nJSON_ARRAY_APPEND(json_doc, path, value[, path, value] ...)\n\nDescription\n-----------\n\nAppends values to the end of the specified arrays within a JSON document, returning the result, or NULL if any of the arguments are NULL.\n\nEvaluation is performed from left to right, with the resulting document from the previous pair becoming the new value against which the next pair is evaluated.\n\nIf the json_doc is not a valid JSON document, or if any of the paths are not valid, or contain a or * wildcard, an error is returned.\n\nExamples\n--------\n\nSET @json = ''[1, 2, [3, 4]]'';\n\nSELECT JSON_ARRAY_APPEND(@json, ''$[0]'', 5)\n+-------------------------------------+\n| JSON_ARRAY_APPEND(@json, ''$[0]'', 5) |\n+-------------------------------------+\n| [[1, 5], 2, [3, 4]] |\n+-------------------------------------+\n\nSELECT JSON_ARRAY_APPEND(@json, ''$[1]'', 6);\n+-------------------------------------+\n| JSON_ARRAY_APPEND(@json, ''$[1]'', 6) |\n+-------------------------------------+\n| [1, [2, 6], [3, 4]] |\n+-------------------------------------+\n\nSELECT JSON_ARRAY_APPEND(@json, ''$[1]'', 6, ''$[2]'', 7);\n+------------------------------------------------+\n| JSON_ARRAY_APPEND(@json, ''$[1]'', 6, ''$[2]'', 7) |\n+------------------------------------------------+\n| [1, [2, 6], [3, 4, 7]] |\n+------------------------------------------------+\n\nSELECT JSON_ARRAY_APPEND(@json, ''$'', 5);\n+----------------------------------+\n| JSON_ARRAY_APPEND(@json, ''$'', 5) |\n+----------------------------------+\n| [1, 2, [3, 4], 5] |\n+----------------------------------+\n\nSET @json = ''{"A": 1, "B": [2], "C": [3, 4]}'';\n\nSELECT JSON_ARRAY_APPEND(@json, ''$.B'', 5);\n+------------------------------------+\n| JSON_ARRAY_APPEND(@json, ''$.B'', 5) |\n+------------------------------------+\n| {"A": 1, "B": [2, 5], "C": [3, 4]} |\n+------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_array_append', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_array_append'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (357, 35, 'JSON\\_ARRAY\\_INSERT', 'Syntax\n------\n\nJSON_ARRAY_INSERT(json_doc, path, value[, path, value] ...)\n\nDescription\n-----------\n\nInserts a value into a JSON document, returning the modified document, or NULL if any of the arguments are NULL.\n\nEvaluation is performed from left to right, with the resulting document from the previous pair becoming the new value against which the next pair is evaluated.\n\nIf the json_doc is not a valid JSON document, or if any of the paths are not valid, or contain a or * wildcard, an error is returned.\n\nExamples\n--------\n\nSET @json = ''[1, 2, [3, 4]]'';\n\nSELECT JSON_ARRAY_INSERT(@json, ''$[0]'', 5);\n+-------------------------------------+\n| JSON_ARRAY_INSERT(@json, ''$[0]'', 5) |\n+-------------------------------------+\n| [5, 1, 2, [3, 4]] |\n+-------------------------------------+\n\nSELECT JSON_ARRAY_INSERT(@json, ''$[1]'', 6);\n+-------------------------------------+\n| JSON_ARRAY_INSERT(@json, ''$[1]'', 6) |\n+-------------------------------------+\n| [1, 6, 2, [3, 4]] |\n+-------------------------------------+\n\nSELECT JSON_ARRAY_INSERT(@json, ''$[1]'', 6, ''$[2]'', 7);\n+------------------------------------------------+\n| JSON_ARRAY_INSERT(@json, ''$[1]'', 6, ''$[2]'', 7) |\n+------------------------------------------------+\n| [1, 6, 7, 2, [3, 4]] |\n+------------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_array_insert', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_array_insert'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (358, 35, 'JSON\\_ARRAY\\_INTERSECT', 'Syntax\n------\n\nJSON_ARRAY_INTERSECT(arr1, arr2)\n\nDescription\n-----------\n\nFinds intersection between two json arrays and returns an array of items found in both array.\n\nExamples\n--------\n\nSET @json1= ''[1,2,3]'';\nSET @json2= ''[1,2,4]'';\n\nSELECT json_array_intersect(@json1, @json2); \n+--------------------------------------+\n| json_array_intersect(@json1, @json2) |\n+--------------------------------------+\n| [1, 2] |\n+--------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_array_intersect', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_array_intersect'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (359, 35, 'JSON\\_ARRAYAGG', 'Syntax\n------\n\nJSON_ARRAYAGG(column_or_expression)\n\nDescription\n-----------\n\nJSON_ARRAYAGG returns a JSON array containing an element for each value in a given set of JSON or SQL values. It acts on a column or an expression that evaluates to a single value.\n\nThe maximum returned length in bytes is determined by the group_concat_max_len server system variable.\n\nReturns NULL in the case of an error, or if the result contains no rows.\n\nJSON_ARRAYAGG cannot currently be used as a window function.\n\nThe full syntax is as follows:\n\n``sql\nJSON_ARRAYAGG([DISTINCT] expr\n [ORDER BY {unsigned_integer | col_name | expr}\n [ASC | DESC] [,col_name ...]]\n [LIMIT {[offset,] row_count | row_count OFFSET offset}])\n``\n\nExamples\n--------\n\nCREATE TABLE t1 (a INT, b INT);\n\nINSERT INTO t1 VALUES (1, 1),(2, 1), (1, 1),(2, 1), (3, 2),(2, 2),(2, 2),(2, 2);\n\nSELECT JSON_ARRAYAGG(a), JSON_ARRAYAGG(b) FROM t1;\n+-------------------+-------------------+\n| JSON_ARRAYAGG(a) | JSON_ARRAYAGG(b) |\n+-------------------+-------------------+\n| [1,2,1,2,3,2,2,2] | [1,1,1,1,2,2,2,2] |\n+-------------------+-------------------+\n\nSELECT JSON_ARRAYAGG(a), JSON_ARRAYAGG(b) FROM t1 GROUP BY b;\n+------------------+------------------+\n| JSON_ARRAYAGG(a) | JSON_ARRAYAGG(b) |\n+------------------+------------------+\n| [1,2,1,2] | [1,1,1,1] |\n| [3,2,2,2] | [2,2,2,2] |\n+------------------+------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_arrayagg', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_arrayagg'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (360, 35, 'JSON\\_COMPACT', 'Syntax\n------\n\nJSON_COMPACT(json_doc)\n\nDescription\n-----------\n\nRemoves all unnecessary spaces so the json document is as short as possible.\n\nExamples\n--------\n\nSET @j = ''{ "A": 1, "B": [2, 3]}'';\n\nSELECT JSON_COMPACT(@j), @j;\n+-------------------+------------------------+\n| JSON_COMPACT(@j) | @j |\n+-------------------+------------------------+\n| {"A":1,"B":[2,3]} | { "A": 1, "B": [2, 3]} |\n+-------------------+------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_compact', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_compact'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (361, 35, 'JSON\\_CONTAINS', 'Syntax\n------\n\nJSON_CONTAINS(json_doc, val[, path])\n\nDescription\n-----------\n\nReturns whether or not the specified value is found in the given JSON document or, optionally, at the specified path within the document. Returns 1 if it does, 0 if not and NULL if any of the arguments are null. An error occurs if the document or path is not valid, or contains the or * wildcards.\n\nExamples\n--------\n\nSET @json = ''{"A": 0, "B": {"C": 1}, "D": 2}'';\n\nSELECT JSON_CONTAINS(@json, ''2'', ''$.A'');\n+----------------------------------+\n| JSON_CONTAINS(@json, ''2'', ''$.A'') |\n+----------------------------------+\n| 0 |\n+----------------------------------+\n\nSELECT JSON_CONTAINS(@json, ''2'', ''$.D'');\n+----------------------------------+\n| JSON_CONTAINS(@json, ''2'', ''$.D'') |\n+----------------------------------+\n| 1 |\n+----------------------------------+\n\nSELECT JSON_CONTAINS(@json, ''{"C": 1}'', ''$.A'');\n+-----------------------------------------+\n| JSON_CONTAINS(@json, ''{"C": 1}'', ''$.A'') |\n+-----------------------------------------+\n| 0 |\n+-----------------------------------------+\n\nSELECT JSON_CONTAINS(@json, ''{"C": 1}'', ''$.B'');\n+-----------------------------------------+\n| JSON_CONTAINS(@json, ''{"C": 1}'', ''$.B'') |\n+-----------------------------------------+\n| 1 |\n+-----------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_contains', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_contains'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (362, 35, 'JSON\\_CONTAINS\\_PATH', 'Syntax\n------\n\nJSON_CONTAINS_PATH(json_doc, return_arg, path[, path] ...)\n\nDescription\n-----------\n\nIndicates whether the given JSON document contains data at the specified path or paths. Returns 1 if it does, 0 if not and NULL if any of the arguments are null.\n\nThe _return_arg_ can be one or all:\n\n one - Returns 1 if at least one path exists within the JSON document.\n all - Returns 1 only if all paths exist within the JSON document.\n\nExamples\n--------\n\nSET @json = ''{"A": 1, "B": [2], "C": [3, 4]}'';\n\nSELECT JSON_CONTAINS_PATH(@json, ''one'', ''$.A'', ''$.D'');\n+------------------------------------------------+\n| JSON_CONTAINS_PATH(@json, ''one'', ''$.A'', ''$.D'') |\n+------------------------------------------------+\n| 1 |\n+------------------------------------------------+\n1 row in set (0.00 sec)\n\nSELECT JSON_CONTAINS_PATH(@json, ''all'', ''$.A'', ''$.D'');\n+------------------------------------------------+\n| JSON_CONTAINS_PATH(@json, ''all'', ''$.A'', ''$.D'') |\n+------------------------------------------------+\n| 0 |\n+------------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_contains_path', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_contains_path'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (363, 35, 'JSON\\_DEPTH', 'Syntax\n------\n\nJSON_DEPTH(json_doc)\n\nDescription\n-----------\n\nReturns the maximum depth of the given JSON document, or NULL if the argument is null. An error occurs if the argument is an invalid JSON document.\n\n Scalar values or empty arrays or objects have a depth of 1.\n Arrays with only scalar values and objects with only scalar values for all keys have depth of 1.\n* In all other cases, the depth can be 2 or greater.\n\nThere is no maximum depth level — it''s unlimited.\n\nFor more information, see this blog post.\n\nThe maximum depth is 32.\n\nExamples\n--------\n\nSELECT JSON_DEPTH(''[]''), JSON_DEPTH(''true''), JSON_DEPTH(''{}'');\n+------------------+--------------------+------------------+\n| JSON_DEPTH(''[]'') | JSON_DEPTH(''true'') | JSON_DEPTH(''{}'') |\n+------------------+--------------------+------------------+\n| 1 | 1 | 1 |\n+------------------+--------------------+------------------+\n\nSELECT JSON_DEPTH(''[1, 2, 3]''), JSON_DEPTH(''[[], {}, []]'');\n+-------------------------+----------------------------+\n| JSON_DEPTH(''[1, 2, 3]'') | JSON_DEPTH(''[[], {}, []]'') |\n+-------------------------+----------------------------+\n| 2 | 2 |\n+-------------------------+----------------------------+\n\nSELECT JSON_DEPTH(''[1, 2, [3, 4, 5, 6], 7]'');\n+---------------------------------------+\n| JSON_DEPTH(''[1, 2, [3, 4, 5, 6], 7]'') |\n+---------------------------------------+\n| 3 |\n+---------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_depth', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_depth'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (364, 35, 'JSON\\_DETAILED', 'Syntax\n------\n\nJSON_DETAILED(json_doc[, tab_size])\nJSON_PRETTY(json_doc[, tab_size])\n\nDescription\n-----------\n\nRepresents JSON in the most understandable way emphasizing nested structures.\n\nJSON_PRETTY is an alias for JSON_DETAILED .\n\nJSON_PRETTY is not available as an alias for JSON_DETAILED .\n\nExamples\n--------\n\nSET @j = ''{ "A":1,"B":[2,3]}'';\n\nSELECT @j;\n+--------------------+\n| @j |\n+--------------------+\n| { "A":1,"B":[2,3]} |\n+--------------------+\n\nSELECT JSON_DETAILED(@j);\n+------------------------------------------------------------+\n| JSON_DETAILED(@j) |\n+------------------------------------------------------------+\n| {\n "A": 1,\n "B": \n [\n 2,\n 3\n ]\n} |\n+------------------------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_detailed', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_detailed'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (365, 35, 'JSON\\_EQUALS', 'Syntax\n------\n\nJSON_EQUALS(json1, json2)\n\nDescription\n-----------\n\nChecks if there is equality between two json objects. Returns 1 if it there is, 0 if not, or NULL if any of the arguments are null.\n\nExamples\n--------\n\nSELECT JSON_EQUALS(''{"a" :[1, 2, 3],"b":[4]}'', ''{"b":[4],"a":[1, 2, 3.0]}'');\n+------------------------------------------------------------------------+\n| JSON_EQUALS(''{"a" :[1, 2, 3],"b":[4]}'', ''{"b":[4],"a":[1, 2, 3.0]}'') |\n+------------------------------------------------------------------------+\n| 1 |\n+------------------------------------------------------------------------+\n\nSELECT JSON_EQUALS(''{"a":[1, 2, 3]}'', ''{"a":[1, 2, 3.01]}'');\n+------------------------------------------------------+\n| JSON_EQUALS(''{"a":[1, 2, 3]}'', ''{"a":[1, 2, 3.01]}'') |\n+------------------------------------------------------+\n| 0 |\n+------------------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_equals', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_equals'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (366, 35, 'JSON\\_EXISTS', 'Syntax\n------\n\nJSON_EXISTS(json_doc, json_path)\n\nDescription\n-----------\n\nDetermines whether json_doc has an element pointed to by path json_path. Returns 1 if the element exists, 0 if not, or NULL if any of the inputs were NULL.\n\nExamples\n--------\n\nSELECT JSON_EXISTS(''{"key1":"xxxx", "key2":[1, 2, 3]}'', "$.key2");\n+------------------------------------------------------------+\n| JSON_EXISTS(''{"key1":"xxxx", "key2":[1, 2, 3]}'', "$.key2") |\n+------------------------------------------------------------+\n| 1 |\n+------------------------------------------------------------+\n\nSELECT JSON_EXISTS(''{"key1":"xxxx", "key2":[1, 2, 3]}'', "$.key3");\n+------------------------------------------------------------+\n| JSON_EXISTS(''{"key1":"xxxx", "key2":[1, 2, 3]}'', "$.key3") |\n+------------------------------------------------------------+\n| 0 |\n+------------------------------------------------------------+\n\nSELECT JSON_EXISTS(''{"key1":"xxxx", "key2":[1, 2, 3]}'', "$.key2[1]");\n+---------------------------------------------------------------+\n| JSON_EXISTS(''{"key1":"xxxx", "key2":[1, 2, 3]}'', "$.key2[1]") |\n+---------------------------------------------------------------+\n| 1 |\n+---------------------------------------------------------------+\n\nSELECT JSON_EXISTS(''{"key1":"xxxx", "key2":[1, 2, 3]}'', "$.key2[10]");\n+----------------------------------------------------------------+\n| JSON_EXISTS(''{"key1":"xxxx", "key2":[1, 2, 3]}'', "$.key2[10]") |\n+----------------------------------------------------------------+\n| 0 |\n+----------------------------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_exists', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_exists'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (367, 35, 'JSON\\_EXTRACT', 'Syntax\n------\n\nJSON_EXTRACT(json_doc, path[, path] ...)\n\nDescription\n-----------\n\nExtracts data from a JSON document. The extracted data is selected from the parts matching the path arguments. Returns all matched values; either as a single matched value, or, if the arguments could return multiple values, a result autowrapped as an array in the matching order.\n\nReturns NULL if no paths match or if any of the arguments are NULL.\n\nAn error occurs if any path argument is not a valid path, or if the json_doc argument is not a valid JSON document.\n\nThe path expression be a JSONPath expression as supported by MariaDB\n\nExamples\n--------\n\nSET @json = ''[1, 2, [3, 4]]'';\n\nSELECT JSON_EXTRACT(@json, ''$[1]'');\n+-----------------------------+\n| JSON_EXTRACT(@json, ''$[1]'') |\n+-----------------------------+\n| 2 |\n+-----------------------------+\n\nSELECT JSON_EXTRACT(@json, ''$[2]'');\n+-----------------------------+\n| JSON_EXTRACT(@json, ''$[2]'') |\n+-----------------------------+\n| [3, 4] |\n+-----------------------------+\n\nSELECT JSON_EXTRACT(@json, ''$[2][1]'');\n+--------------------------------+\n| JSON_EXTRACT(@json, ''$[2][1]'') |\n+--------------------------------+\n| 4 |\n+--------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_extract', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_extract'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (368, 35, 'JSON\\_INSERT', 'Syntax\n------\n\nJSON_INSERT(json_doc, path, val[, path, val] ...)\n\nDescription\n-----------\n\nInserts data into a JSON document, returning the resulting document or NULL if either of the _json_doc_ or _path_ arguments are null.\n\nAn error occurs if the JSON document is invalid, or if any of the paths are invalid or contain a or * wildcard.\n\nJSON_INSERT can only insert data, while JSON_REPLACE can only update. JSON_SET can update or insert data.\n\nExamples\n--------\n\nSET @json = ''{ "A": 0, "B": [1, 2]}'';\n\nSELECT JSON_INSERT(@json, ''$.C'', ''[3, 4]'');\n+--------------------------------------+\n| JSON_INSERT(@json, ''$.C'', ''[3, 4]'') |\n+--------------------------------------+\n| { "A": 0, "B": [1, 2], "C":"[3, 4]"} |\n+--------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_insert', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_insert'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (369, 35, 'JSON\\_KEY\\_VALUE', 'Syntax\n------\n\nJSON_KEY_VALUE(obj, json_path)\n\nDescription\n-----------\n\nJSON_KEY_VALUE extracts key/value pairs from a JSON object. The JSON path parameter is used to only return key/value pairs for matching JSON objects.\n\nExamples\n--------\n\nSELECT JSON_KEY_VALUE(''[[1, {"key1":"val1", "key2":"val2"}, 3], 2, 3]'', ''$[0][1]'');\n+-----------------------------------------------------------------------------+\n| JSON_KEY_VALUE(''[[1, {"key1":"val1", "key2":"val2"}, 3], 2, 3]'', ''$[0][1]'') |\n+-----------------------------------------------------------------------------+\n| [{"key": "key1", "value": "val1"}, {"key": "key2", "value": "val2"}] |\n+-----------------------------------------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_key_value', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_key_value'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (370, 35, 'JSON\\_KEYS', 'Syntax\n------\n\nJSON_KEYS(json_doc[, path])\n\nDescription\n-----------\n\nReturns the keys as a JSON array from the top-level value of a JSON object or, if the optional path argument is provided, the top-level keys from the path.\n\nExcludes keys from nested sub-objects in the top level value. The resulting array will be empty if the selected object is empty.\n\nReturns NULL if any of the arguments are null, a given path does not locate an object, or if the json_doc argument is not an object.\n\nAn error will occur if JSON document is invalid, the path is invalid or if the path contains a or * wildcard.\n\nExamples\n--------\n\nSELECT JSON_KEYS(''{"A": 1, "B": {"C": 2}}'');\n+--------------------------------------+\n| JSON_KEYS(''{"A": 1, "B": {"C": 2}}'') |\n+--------------------------------------+\n| ["A", "B"] |\n+--------------------------------------+\n\nSELECT JSON_KEYS(''{"A": 1, "B": 2, "C": {"D": 3}}'', ''$.C'');\n+-----------------------------------------------------+\n| JSON_KEYS(''{"A": 1, "B": 2, "C": {"D": 3}}'', ''$.C'') |\n+-----------------------------------------------------+\n| ["D"] |\n+-----------------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_keys', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_keys'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (371, 35, 'JSON\\_LENGTH', 'Syntax\n------\n\nJSON_LENGTH(json_doc[, path])\n\nDescription\n-----------\n\nReturns the length of a JSON document, or, if the optional path argument is given, the length of the value within the document specified by the path.\n\nReturns NULL if any of the arguments argument are null or the path argument does not identify a value in the document.\n\nAn error occurs if the JSON document is invalid, the path is invalid or if the path contains a or wildcard.\n\nLength will be determined as follow:\n\n A scalar''s length is always 1.\n If an array, the number of elements in the array.\n If an object, the number of members in the object.\n\nThe length of nested arrays or objects are not counted.\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_length', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_length'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (372, 35, 'JSON\\_LOOSE', 'Syntax\n------\n\nJSON_LOOSE(json_doc)\n\nDescription\n-----------\n\nAdds spaces to a JSON document to make it look more readable.\n\nExamples\n--------\n\nSET @j = ''{ "A":1,"B":[2,3]}'';\n\nSELECT JSON_LOOSE(@j), @j;\n+-----------------------+--------------------+\n| JSON_LOOSE(@j) | @j |\n+-----------------------+--------------------+\n| {"A": 1, "B": [2, 3]} | { "A":1,"B":[2,3]} |\n+-----------------------+--------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_loose', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_loose'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (373, 35, 'JSON\\_MERGE', 'Syntax\n------\n\nJSON_MERGE(json_doc, json_doc[, json_doc] ...)\n\nDescription\n-----------\n\nMerges the given JSON documents.\n\nReturns the merged result, or NULL if any argument is NULL.\n\nAn error occurs if any of the arguments are not valid JSON documents.\n\nJSON_MERGE is deprecated. JSON_MERGE_PATCH is an RFC 7396-compliant replacement, and JSON_MERGE_PRESERVE is a synonym.\n\nExamples\n--------\n\nSET @json1 = ''[1, 2]'';\nSET @json2 = ''[3, 4]'';\n\nSELECT JSON_MERGE(@json1,@json2);\n+---------------------------+\n| JSON_MERGE(@json1,@json2) |\n+---------------------------+\n| [1, 2, 3, 4] |\n+---------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_merge', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_merge'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (374, 35, 'JSON\\_MERGE\\_PATCH', 'Syntax\n------\n\nJSON_MERGE_PATCH(json_doc, json_doc[, json_doc] ...)\n\nDescription\n-----------\n\nMerges the given JSON documents, returning the merged result, or NULL if any argument is NULL.\n\nJSON_MERGE_PATCH is an RFC 7396-compliant replacement for JSON_MERGE, which is deprecated.\n\nUnlike JSON_MERGE_PRESERVE, members with duplicate keys are not preserved.\n\nExamples\n--------\n\nSET @json1 = ''[1, 2]'';\nSET @json2 = ''[2, 3]'';\nSELECT JSON_MERGE_PATCH(@json1,@json2),JSON_MERGE_PRESERVE(@json1,@json2);\n+---------------------------------+------------------------------------+\n| JSON_MERGE_PATCH(@json1,@json2) | JSON_MERGE_PRESERVE(@json1,@json2) |\n+---------------------------------+------------------------------------+\n| [2, 3] | [1, 2, 2, 3] |\n+---------------------------------+------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_merge_patch', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_merge_patch'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (375, 35, 'JSON\\_MERGE\\_PRESERVE', 'Syntax\n------\n\nJSON_MERGE_PRESERVE(json_doc, json_doc[, json_doc] ...)\n\nDescription\n-----------\n\nMerges the given JSON documents, returning the merged result, or NULL if any argument is NULL.\n\nJSON_MERGE_PRESERVE is a synonym for JSON_MERGE, which has been deprecated.\n\nUnlike JSON_MERGE_PATCH, members with duplicate keys are preserved.\n\nExamples\n--------\n\nSET @json1 = ''[1, 2]'';\nSET @json2 = ''[2, 3]'';\nSELECT JSON_MERGE_PATCH(@json1,@json2),JSON_MERGE_PRESERVE(@json1,@json2);\n+---------------------------------+------------------------------------+\n| JSON_MERGE_PATCH(@json1,@json2) | JSON_MERGE_PRESERVE(@json1,@json2) |\n+---------------------------------+------------------------------------+\n| [2, 3] | [1, 2, 2, 3] |\n+---------------------------------+------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_merge_preserve', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_merge_preserve'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (376, 35, 'JSON\\_NORMALIZE', 'Syntax\n------\n\nJSON_NORMALIZE(json)\n\nDescription\n-----------\n\nRecursively sorts keys and removes spaces, allowing comparison of json documents for equality.\n\nExamples\n--------\n\nCREATE TABLE t1 (\n id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,\n val JSON,\n / other columns here /\n PRIMARY KEY (id)\n);\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_normalize', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_normalize'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (377, 35, 'JSON\\_OBJECT', 'Syntax\n------\n\nJSON_OBJECT([key, value[, key, value] ...])\n\nDescription\n-----------\n\nReturns a JSON object containing the given key/value pairs. The key/value list can be empty.\n\nAn error will occur if there are an odd number of arguments, or any key name is NULL.\n\nExamples\n--------\n\nSELECT JSON_OBJECT("id", 1, "name", "Monty");\n+---------------------------------------+\n| JSON_OBJECT("id", 1, "name", "Monty") |\n+---------------------------------------+\n| {"id": 1, "name": "Monty"} |\n+---------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_object', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_object'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (378, 35, 'JSON\\_OBJECT\\_FILTER\\_KEYS', 'Syntax\n------\n\nJSON_OBJECT_FILTER_KEYS(obj, array_keys)\n\nDescription\n-----------\n\nJSON_OBJECT_FILTER_KEYS returns a JSON object with keys from the object that are also present in the array as string. It is used when one wants to get key-value pair such that the keys are common but the values may not be common.\n\nExamples\n--------\n\nSET @obj1= ''{ "a": 1, "b": 2, "c": 3}'';\nSET @obj2= ''{"b" : 10, "c": 20, "d": 30}'';\nSELECT JSON_OBJECT_FILTER_KEYS (@obj1, JSON_ARRAY_INTERSECT(JSON_KEYS(@obj1), JSON_KEYS(@obj2)));\n+-------------------------------------------------------------------------------------------+\n| JSON_OBJECT_FILTER_KEYS (@obj1, JSON_ARRAY_INTERSECT(JSON_KEYS(@obj1), JSON_KEYS(@obj2))) |\n+-------------------------------------------------------------------------------------------+\n| {"b": 2, "c": 3} |\n+-------------------------------------------------------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_object_filter_keys', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_object_filter_keys'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (379, 35, 'JSON\\_OBJECT\\_TO\\_ARRAY', 'Syntax\n------\n\nJSON_OBJECT_TO_ARRAY(Obj)\n\nDescription\n-----------\n\nIt is used to convert all JSON objects found in a JSON document to JSON arrays where each item in the outer array represents a single key-value pair from the object. It is used when we want not just common keys, but also common values. It can be used in conjunction with JSON_ARRAY_INTERSECT().\n\nExamples\n--------\n\nSET @obj1= ''{ "a": [1, 2, 3], "b": { "key1":"val1", "key2": {"key3":"val3"} }}'';\n\nSELECT JSON_OBJECT_TO_ARRAY(@obj1);\n+-----------------------------------------------------------------------+\n| JSON_OBJECT_TO_ARRAY(@obj1) |\n+-----------------------------------------------------------------------+\n| [["a", [1, 2, 3]], ["b", {"key1": "val1", "key2": {"key3": "val3"}}]] |\n+-----------------------------------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_object_to_array', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_object_to_array'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (380, 35, 'JSON\\_OBJECTAGG', 'Syntax\n------\n\nJSON_OBJECTAGG(key, value)\n\nDescription\n-----------\n\nJSON_OBJECTAGG returns a JSON object containing key-value pairs. It takes two expressions that evaluate to a single value, or two column names, as arguments, the first used as a key, and the second as a value.\n\nThe maximum returned length in bytes is determined by the group_concat_max_len server system variable.\n\nReturns NULL in the case of an error, or if the result contains no rows.\n\nJSON_OBJECTAGG cannot currently be used as a window function.\n\nExamples\n--------\n\nSELECT * FROM t1;\n+------+-------+\n| a | b |\n+------+-------+\n| 1 | Hello |\n| 1 | World |\n| 2 | This |\n+------+-------+\n\nSELECT JSON_OBJECTAGG(a, b) FROM t1;\n+----------------------------------------+\n| JSON_OBJECTAGG(a, b) |\n+----------------------------------------+\n| {"1":"Hello", "1":"World", "2":"This"} |\n+----------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_objectagg', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_objectagg'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (381, 35, 'JSON\\_OVERLAPS', 'Syntax\n------\n\nJSON_OVERLAPS(json_doc1, json_doc2)\n\nDescription\n-----------\n\nJSON_OVERLAPS() compares two json documents and returns true if they have at least one common\\\nkey-value pair between two objects, array element common between two arrays, or array element common with scalar if one of the arguments is a scalar and other is an array. If two json documents are scalars, it returns true if they have same type and value.\n\nIf none of the above conditions are satisfied then it returns false.\n\nExamples\n--------\n\nSELECT JSON_OVERLAPS(''false'', ''false'');\n+---------------------------------+\n| JSON_OVERLAPS(''false'', ''false'') |\n+---------------------------------+\n| 1 |\n+---------------------------------+\n\nSELECT JSON_OVERLAPS(''true'', ''["abc", 1, 2, true, false]'');\n+----------------------------------------------------+\n| JSON_OVERLAPS(''true'',''["abc", 1, 2, true, false]'') |\n+----------------------------------------------------+\n| 1 |\n+----------------------------------------------------+\n\nSELECT JSON_OVERLAPS(''{"A": 1, "B": {"C":2}}'', ''{"A": 2, "B": {"C":2}}'') AS is_overlap;\n+---------------------+\n| is_overlap |\n+---------------------+\n| 1 |\n+---------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_overlaps', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_overlaps'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (382, 35, 'JSON\\_PRETTY', 'Description\n-----------\n\nJSON_PRETTY is available from MariaDB 10.10.3, 10.9.5, 10.8.7, 10.7.8, 10.6.12, 10.5.19, and 10.4.28.\n\nJSON_PRETTY is an alias for JSON_DETAILED.\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_pretty', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_pretty'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (383, 35, 'JSON\\_QUERY', 'Syntax\n------\n\nJSON_QUERY(json_doc, path)\n\nDescription\n-----------\n\nGiven a JSON document, returns an object or array specified by the path. Returns NULL if not given a valid JSON document, or if there is no match.\n\nExamples\n--------\n\nSELECT json_query(''{"key1":{"a":1, "b":[1,2]}}'', ''$.key1'');\n+-----------------------------------------------------+\n| json_query(''{"key1":{"a":1, "b":[1,2]}}'', ''$.key1'') |\n+-----------------------------------------------------+\n| {"a":1, "b":[1,2]} |\n+-----------------------------------------------------+\n\nSELECT json_query(''{"key1":123, "key1": [1,2,3]}'', ''$.key1'');\n+-------------------------------------------------------+\n| json_query(''{"key1":123, "key1": [1,2,3]}'', ''$.key1'') |\n+-------------------------------------------------------+\n| [1,2,3] |\n+-------------------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_query', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_query'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (384, 35, 'JSON\\_QUOTE', 'Syntax\n------\n\nJSON_QUOTE(json_value)\n\nDescription\n-----------\n\nQuotes a string as a JSON value, usually for producing valid JSON string literals for inclusion in JSON documents. Wraps the string with double quote characters and escapes interior quotes and other special characters, returning a utf8mb4 string.\n\nReturns NULL if the argument is NULL.\n\nExamples\n--------\n\nSELECT JSON_QUOTE(''A''), JSON_QUOTE("B"), JSON_QUOTE(''"C"'');\n+-----------------+-----------------+-------------------+\n| JSON_QUOTE(''A'') | JSON_QUOTE("B") | JSON_QUOTE(''"C"'') |\n+-----------------+-----------------+-------------------+\n| "A" | "B" | "\\"C\\"" |\n+-----------------+-----------------+-------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_quote', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_quote'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (385, 35, 'JSON\\_REMOVE', 'Syntax\n------\n\nJSON_REMOVE(json_doc, path[, path] ...)\n\nDescription\n-----------\n\nRemoves data from a JSON document returning the result, or NULL if any of the arguments are null. If the element does not exist in the document, no changes are made.\n\nThe function returns NULL and throws a warning if the JSON document is invalid, the path is invalid, contains a range, or contains a or * wildcard.\n\nPath arguments are evaluated from left to right, with the result from the earlier evaluation being used as the value for the next.\n\nExamples\n--------\n\nSELECT JSON_REMOVE(''{"A": 1, "B": 2, "C": {"D": 3}}'', ''$.C'');\n+-------------------------------------------------------+\n| JSON_REMOVE(''{"A": 1, "B": 2, "C": {"D": 3}}'', ''$.C'') |\n+-------------------------------------------------------+\n| {"A": 1, "B": 2} |\n+-------------------------------------------------------+\n\nSELECT JSON_REMOVE(''["A", "B", ["C", "D"], "E"]'', ''$[1]'');\n+----------------------------------------------------+\n| JSON_REMOVE(''["A", "B", ["C", "D"], "E"]'', ''$[1]'') |\n+----------------------------------------------------+\n| ["A", ["C", "D"], "E"] |\n+----------------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_remove', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_remove'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (386, 35, 'JSON\\_REPLACE', 'Syntax\n------\n\nJSON_REPLACE(json_doc, path, val[, path, val] ...)\n\nDescription\n-----------\n\nReplaces existing values in a JSON document, returning the result, or NULL if any of the arguments are NULL.\n\nAn error will occur if the JSON document is invalid, the path is invalid or if the path contains a or * wildcard.\n\nPaths and values are evaluated from left to right, with the result from the earlier evaluation being used as the value for the next.\n\nJSON_REPLACE can only update data, while JSON_INSERT can only insert. JSON_SET can update or insert data.\n\nExamples\n--------\n\nSELECT JSON_REPLACE(''{ "A": 1, "B": [2, 3]}'', ''$.B[1]'', 4);\n+-----------------------------------------------------+\n| JSON_REPLACE(''{ "A": 1, "B": [2, 3]}'', ''$.B[1]'', 4) |\n+-----------------------------------------------------+\n| { "A": 1, "B": [2, 4]} |\n+-----------------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_replace', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_replace'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (387, 35, 'JSON\\_SCHEMA\\_VALID', 'Syntax\n------\n\nJSON_SCHEMA_VALID(schema, json);\n\nDescription\n-----------\n\nJSON_SCHEMA_VALID allows MariaDB to support JSON schema validation. If a given json is valid against a schema it returns true. When JSON does not validate against the schema, it does not return a message about which keyword it failed against and only returns false.\n\nThe function supports JSON Schema Draft 2020 with a few exceptions:\n\n External resources are not supported.\n Hyper schema keywords are not supported.\n Formats like date, email etc are treated as annotations.\n\nExamples\n--------\n\nCREATE TABLE obj_table(val_obj JSON CHECK(JSON_SCHEMA_VALID(''{\n "type":"object",\n "properties": {\n "number1":{\n "type":"number",\n "maximum":5,\n "const":4\n },\n "string1":{\n "type":"string",\n "maxLength":5,\n "minLength":3\n },\n "object1":{\n "type":"object",\n "properties":{\n "key1": {"type":"string"},\n "key2":{"type":"array"},\n "key3":{"type":"number", "minimum":3}\n },\n "dependentRequired": { "key1":["key3"] }\n }\n },\n "required":["number1","object1"]\n }'', val_obj)));\n\nINSERT INTO obj_table VALUES(\n ''{"number1":4, "string1":"abcd", \n "object1":{"key1":"val1", "key2":[1,2,3, "string1"], "key3":4}}''\n);\n\nINSERT INTO obj_table VALUES(\n ''{"number1":3, "string1":"abcd", \n "object1":{"key1":"val1", "key2":[1,2,3, "string1"], "key3":4}}''\n);\nERROR 4025 (23000): CONSTRAINT obj_table.val_obj failed for test.obj_table\n\nSELECT FROM obj_table;\n+--------------------------------------------------------------------------------------------------+\n| val_obj |\n+--------------------------------------------------------------------------------------------------+\n| {"number1":4, "string1":"abcd", "object1":{"key1":"val1", "key2":[1,2,3, "string1"], "key3":4}} |\n+--------------------------------------------------------------------------------------------------+\n\nSET @schema= ''{\n "properties" : {\n "number1":{ "maximum":10 },\n "string1" : { "maxLength": 3} \n }\n}'';\n\nSELECT JSON_SCHEMA_VALID(@schema, ''{ "number1":25, "string1":"ab" }'');\n+----------------------------------------------------------------+\n| JSON_SCHEMA_VALID(@schema, ''{ "number1":25, "string1":"ab" }'') |\n+----------------------------------------------------------------+\n| 0 |\n+----------------------------------------------------------------+\n\nSELECT JSON_SCHEMA_VALID(@schema, ''{ "number1":10, "string1":"ab" }'');\n+----------------------------------------------------------------+\n| JSON_SCHEMA_VALID(@schema, ''{ "number1":10, "string1":"ab" }'') |\n+----------------------------------------------------------------+\n| 1 |\n+----------------------------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_schema_valid', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_schema_valid'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (388, 35, 'JSON\\_SEARCH', 'Syntax\n------\n\nJSON_SEARCH(json_doc, return_arg, search_str[, escape_char[, path] ...])\n\nDescription\n-----------\n\nReturns the path to the given string within a JSON document, or NULL if any of _json_doc_, _search_str_ or a path argument is NULL; if the search string is not found, or if no path exists within the document.\n\nA warning will occur if the JSON document is not valid, any of the path arguments are not valid, if _return_arg_ is neither _one_ nor _all_, or if the escape character is not a constant. NULL will be returned.\n\n_return_arg_ can be one of two values:\n\n ''one: Terminates after finding the first match, so will return one path string. If there is more than one match, it is undefined which is considered first.\n all: Returns all matching path strings, without duplicates. Multiple strings are autowrapped as an array. The order is undefined.\n\nExamples\n--------\n\nSET @json = ''["A", [{"B": "1"}], {"C":"AB"}, {"D":"BC"}]'';\n\nSELECT JSON_SEARCH(@json, ''one'', ''AB'');\n+---------------------------------+\n| JSON_SEARCH(@json, ''one'', ''AB'') |\n+---------------------------------+\n| "$[2].C" |\n+---------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_search', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_search'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (389, 35, 'JSON\\_SET', 'Syntax\n------\n\nJSON_SET(json_doc, path, val[, path, val] ...)\n\nDescription\n-----------\n\nUpdates or inserts data into a JSON document, returning the result, or NULL if any of the arguments are NULL or the optional path fails to find an object.\n\nAn error will occur if the JSON document is invalid, the path is invalid or if the path contains a or a wildcard\\\\.\\\\*\n\nJSON_SET can update or insert data, while JSON_REPLACE can only update, and JSON_INSERT only insert.\n\nExamples\n--------\n\nSELECT JSON_SET(Priv, ''$.locked'', ''true'') FROM mysql.global_priv\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_set', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_set'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (390, 35, 'JSON\\_TABLE', 'Syntax\n------\n\nJSON_TABLE(json_doc, \n context_path COLUMNS (column_list)\n) [AS] alias\n\nDescription\n-----------\n\nJSON_TABLE can be used in contexts where a table reference can be used; in the FROM clause of a SELECT statement, and in multi-table UPDATE/DELETE statements.\n\njson_doc is the JSON document to extract data from. In the simplest case, it is a string literal containing JSON. In more complex cases it can be an arbitrary expression returning JSON. The expression may have references to columns of other tables. However, one can only refer to tables that precede this JSON_TABLE invocation. For RIGHT JOIN, it is assumed that its outer side precedes the inner. All tables in outer selects are also considered preceding.\n\ncontext_path is a JSON Path expression pointing to a collection of nodes in json_doc that will be used as the source of rows.\n\nThe COLUMNS clause declares the names and types of the columns that JSON_TABLE returns, as well as how the values of the columns are produced.\n\nColumn Definitions\n\nThe following types of columns are supported:\n\nPath Columns\n\n``sql\nname type PATH path_str [on_empty] [on_error]\n`\n\nLocates the JSON node pointed to by path_str and returns its value. The path_str is evaluated using the current row source node as the context node.\n\n`sql\nSET @json=''\n[\n {"name":"Laptop", "color":"black", "price":"1000"},\n {"name":"Jeans", "color":"blue"}\n]'';\n\nSELECT FROM json_table(@json, ''$[]'' \n COLUMNS(\n name VARCHAR(10) path ''$.name'', \n color VARCHAR(10) path ''$.color'',\n price DECIMAL(8,2) path ''$.price'' ) \n) AS jt;\n+--------+-------+---------+\n| name | color | price |\n+--------+-------+---------+\n| Laptop | black | 1000.00 |\n| Jeans | blue | NULL |\n+--------+-------+---------+\n`\n\nThe on_empty and on_error clauses specify the actions to be performed when the value was not found or there was an error condition. See the ON EMPTY and ON ERROR clauses section for details.\n\nORDINALITY Columns\n\n`sql\nname FOR ORDINALITY\n`\n\nCounts the rows, starting from 1.\n\nExample:\n\n`sql\nset @json=''\n[\n {"name":"Laptop", "color":"black"},\n {"name":"Jeans", "color":"blue"}\n]'';\n\nselect from json_table(@json, ''$[]'' \n columns(\n id for ordinality, \n name varchar(10) path ''$.name'')\n) as jt;\n+------+--------+\n| id | name |\n+------+--------+\n| 1 | Laptop |\n| 2 | Jeans |\n+------+--------+\n`\n\nEXISTS PATH Columns\n\n`sql\nname type EXISTS PATH path_str\n`\n\nChecks whether the node pointed to by value_path exists. The value_path is evaluated using the current row source node as the context node.\n\n`sql\nset @json=''\n[\n {"name":"Laptop", "color":"black", "price":1000},\n {"name":"Jeans", "color":"blue"}\n]'';\n\nselect from json_table(@json, ''$[]'' \n columns(\n name varchar(10) path ''$.name'',\n has_price integer exists path ''$.price'')\n) as jt;\n+--------+-----------+\n| name | has_price |\n+--------+-----------+\n| Laptop | 1 |\n| Jeans | 0 |\n+--------+-----------+\n`\n\nNESTED PATHs\n\nNESTED PATH converts nested JSON structures into multiple rows.\n\n`sql\nNESTED PATH path COLUMNS (column_list)\n`\n\nIt finds the sequence of JSON nodes pointed to by path and uses it to produce rows. For each found node, a row is generated with column values as specified by the NESTED PATH''s COLUMNS clause. If path finds no nodes, only one row is generated with all columns having NULL values.\n\nFor example, consider a JSON document that contains an array of items, and each item, in turn, is expected to have an array of its available sizes:\n\n`json\nSET @json=''\n[\n {"name":"Jeans", "sizes": [32, 34, 36]},\n {"name":"T-Shirt", "sizes":["Medium", "Large"]},\n {"name":"Cellphone"}\n]'';\n`\n\nNESTED PATH allows one to produce a separate row for each size each item has:\n\n`sql\nselect from json_table(@json, ''$[]'' \n columns(\n name varchar(10) path ''$.name'', \n nested path ''$.sizes[]'' columns (\n size varchar(32) path ''$''\n )\n )\n) as jt;\n+-----------+--------+\n| name | size |\n+-----------+--------+\n| Jeans | 32 |\n| Jeans | 34 |\n| Jeans | 36 |\n| T-Shirt | Medium |\n| T-Shirt | Large |\n| Cellphone | NULL |\n+-----------+--------+\n`\n\nNESTED PATH clauses can be nested within one another. They can also be located next to each other. In that case, the nested path clauses will produce records one at a time. The ones that are not producing records will have all columns set to NULL.\n\nExample:\n\n`sql\nset @json=''\n[\n {"name":"Jeans", "sizes": [32, 34, 36], "colors":["black", "blue"]}\n]'';\n\nselect from json_table(@json, ''$[]'' \n columns(\n name varchar(10) path ''$.name'', \n nested path ''$.sizes[]'' columns (\n size varchar(32) path ''$''\n ),\n nested path ''$.colors[]'' columns (\n color varchar(32) path ''$''\n )\n )\n) as jt;\n\n+-------+------+-------+\n| name | size | color |\n+-------+------+-------+\n| Jeans | 32 | NULL |\n| Jeans | 34 | NULL |\n| Jeans | 36 | NULL |\n| Jeans | NULL | black |\n| Jeans | NULL | blue |\n+-------+------+-------+\n`\n\nON EMPTY and ON ERROR Clauses\n\nThe ON EMPTY clause specifies what will be done when the element specified by the search path is missing in the JSON document.\n\n`sql\non_empty:\n {NULL | DEFAULT string | ERROR} ON EMPTY\n`\n\nWhen ON EMPTY clause is not present, NULL ON EMPTY is implied.\n\n`sql\non_error:\n {NULL | DEFAULT string | ERROR} ON ERROR\n`\n\nThe ON ERROR clause specifies what should be done if a JSON structure error occurs when trying to extract the value pointed to by the path expression. A JSON structure error here occurs only when one attempts to convert a JSON non-scalar (array or object) into a scalar value. When the ON ERROR clause is not present, NULL ON ERROR is implied.\n\nNote: A datatype conversion error (e.g. attempt to store a non-integer value into an integer field, or a varchar column being truncated) is not considered a JSON error and so will not trigger the ON ERROR behavior. It will produce warnings, in the same way as CAST(value AS datatype) would.\n\nReplication\n\nIn the current code, evaluation of JSON_TABLE is deterministic, that is, for a given input string JSON_TABLE will always produce the same set of rows in the same order. However, one can think of JSON documents that one can consider identical which will produce different output. In order to be future-proof and withstand changes like\n\n sorting JSON object members by name (like MySQL does);\n changing the way duplicate object members are handled the function is marked as unsafe for statement-based replication.\n\nExtracting a Subdocument into a Column\n\n`sql\nSELECT FROM JSON_TABLE(''{"foo": [1,2,3,4]}'',''$'' columns( jscol json path ''$.foo'') ) AS T;\n+-----------+\n| jscol |\n+-----------+\n| [1,2,3,4] |\n+-----------+\n`\n\nJSON_TABLE does not allow to extract a JSON "subdocument" into a JSON column.\n\n`sql\nSELECT * FROM JSON_TABLE(''{"foo": [1,2,3,4]}'',''$'' columns( jscol json path ''$.foo'') ) AS T;\n+-------+\n| jscol |\n+-------+\n| NULL |\n+-------+\n``\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_table', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_table'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (391, 35, 'JSON\\_TYPE', 'Syntax\n------\n\nJSON_TYPE(json_val)\n\nDescription\n-----------\n\nReturns the type of a JSON value (as a string), or NULL if the argument is null.\n\nAn error will occur if the argument is an invalid JSON value.\n\nThe following is a complete list of the possible return types:\n\n| Return type | Value | Example |\n| ----------- | --------------------------------------------------------------------------------------------- | ------------------------- |\n| ARRAY | JSON array | \\[1, 2, {"key": "value"}] |\n| OBJECT | JSON object | {"key":"value"} |\n| BOOLEAN | JSON true/false literals | true, false |\n| DOUBLE | A number with at least one floating point decimal. | 1.2 |\n| INTEGER | A number without a floating point decimal. | 1 |\n| NULL | JSON null literal (this is returned as a string, not to be confused with the SQL NULL value!) | null |\n| STRING | JSON String | "a sample string" |\n\nExamples\n--------\n\nSELECT JSON_TYPE(''{"A": 1, "B": 2, "C": 3}'');\n+---------------------------------------+\n| JSON_TYPE(''{"A": 1, "B": 2, "C": 3}'') |\n+---------------------------------------+\n| OBJECT |\n+---------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_type', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_type'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (392, 35, 'JSON\\_UNQUOTE', 'Syntax\n------\n\nJSON_UNQUOTE(val)\n\nDescription\n-----------\n\nUnquotes a JSON value, returning a string, or NULL if the argument is null.\n\nAn error will occur if the given value begins and ends with double quotes and is an invalid JSON string literal.\n\nIf the given value is not a JSON string, value is passed through unmodified.\n\nCertain character sequences have special meanings within a string. Usually, a backslash is ignored, but the escape sequences in the table below are recognised by MariaDB, unless the SQL Mode is set to NO_BACKSLASH_ESCAPES .\n\n| Escape sequence | Character |\n| --------------- | ---------------------------------- |\n| " | Double quote (") |\n| \\b | Backslash |\n| \\f | Formfeed |\n| \\n | Newline (linefeed) |\n| \\r | Carriage return |\n| \\t | Tab |\n| \\\\ | Backslash () |\n| \\uXXXX | UTF-8 bytes for Unicode value XXXX |\n\nExamples\n--------\n\nSELECT JSON_UNQUOTE(''"Monty"'');\n+-------------------------+\n| JSON_UNQUOTE(''"Monty"'') |\n+-------------------------+\n| Monty |\n+-------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_unquote', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_unquote'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (393, 35, 'JSON\\_VALID', 'Syntax\n------\n\nJSON_VALID(value)\n\nDescription\n-----------\n\nIndicates whether the given value is a valid JSON document or not. Returns 1 if valid, 0 if not, and NULL if the argument is NULL.\n\nThe JSON_VALID function is automatically used as a CHECK constraint for the JSON data type alias in order to ensure that a valid json document is inserted.\n\nThe JSON_VALID function is not automatically used as a CHECK constraint for the JSON data type alias.\n\nExamples\n--------\n\nSELECT JSON_VALID(''{"id": 1, "name": "Monty"}'');\n+------------------------------------------+\n| JSON_VALID(''{"id": 1, "name": "Monty"}'') |\n+------------------------------------------+\n| 1 |\n+------------------------------------------+\n\nSELECT JSON_VALID(''{"id": 1, "name": "Monty", "oddfield"}'');\n+------------------------------------------------------+\n| JSON_VALID(''{"id": 1, "name": "Monty", "oddfield"}'') |\n+------------------------------------------------------+\n| 0 |\n+------------------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_valid', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_valid'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (394, 35, 'JSON\\_VALUE', 'Syntax\n------\n\nJSON_VALUE(json_doc, path)\n\nDescription\n-----------\n\nGiven a JSON document, returns the scalar specified by the path. Returns NULL if not given a valid JSON document, or if there is no match.\n\nExamples\n--------\n\nSELECT json_value(''{"key1":123}'', ''$.key1'');\n+--------------------------------------+\n| json_value(''{"key1":123}'', ''$.key1'') |\n+--------------------------------------+\n| 123 |\n+--------------------------------------+\n\nSELECT json_value(''{"key1": [1,2,3], "key1":123}'', ''$.key1'');\n+-------------------------------------------------------+\n| json_value(''{"key1": [1,2,3], "key1":123}'', ''$.key1'') |\n+-------------------------------------------------------+\n| 123 |\n+-------------------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_value', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_value'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (395, 35, 'JSONPath Expressions', 'Description\n-----------\n\nA number of JSON functions accept JSON Path expressions. MariaDB defines this path as follows:\n\nJSON Path Syntax\n\n``sql\npath : [''lax''] ''$'' [step]\n`\n\nThe path starts with an optional _path mode_. At the moment, MariaDB supports only the "lax" mode, which is also the mode that is used when it is not explicitly specified.\n\nThe $ symbol represents the context item. The search always starts from the context item; because of that, the path always starts with $.\n\nThen, it is followed by zero or more steps, which select element(s) in the JSON document. A step may be one of the following:\n\n Object member selector.\n Array element selector.\n Wildcard selector.\n\nObject Member Selector\n\nTo select member(s) in a JSON object, one can use one of the following:\n\n .memberName selects the value of the member with name memberName.\n ."memberName" - the same as above but allows one to select a member with a name that''s not a valid identifier (that is, has space, dot, and/or other characters).\n . - selects the values of all members of the object.\n\nIf the current item is an array (instead of an object), nothing will be selected.\n\nArray Element Selector\n\nTo select elements of an array, one can use one of the following:\n\n [N] selects element number N in the array. The elements are counted from zero.\n [] selects all elements in the array.\n\nIf the current item is an object (instead of an array), nothing will be selected.\n\nJSON path supports negative indexes in an array, ''last'' keyword and range notation (''to'' keyword) for accessing array elements. Negative indexes start from -1.\n\n [-N] selects n th element from end.\n [last-N] selects n th element from the last element.\n [M to N] selects range of elements starting from index M to N.\n\nExample:\n\n`sql\nSET @json=''{\n "A": [0,\n [1, 2, 3],\n [4, 5, 6],\n "seven",\n 0.8,\n true,\n false,\n "eleven",\n [12, [13, 14], {"key1":"value1"},[15]],\n true],\n "B": {"C": 1},\n "D": 2\n }'';\nSELECT JSON_EXTRACT(@json, ''$.A[-8][1]'');\n+--------------------------------------------------+\n| JSON_EXTRACT(@json, ''$.A[-8][1]'') |\n+--------------------------------------------------+\n| 5 |\n+--------------------------------------------------+\n\nSELECT JSON_EXTRACT(@json, ''$.A[last-7][1]'');\n+-----------------------------------------------+\n| SELECT JSON_EXTRACT(@json, ''$.A[last-7][1]''); |\n+-----------------------------------------------+\n| 5 |\n+-----------------------------------------------+\n\nSET @json= ''[\n [1, {"key1": "value1"}, 3],\n [false, 5, 6],\n [7, 8, [9, {"key2": 2}, 11]],\n [15, 1.34, [14], ["string1", [16, {"key1":[1,2,3,[4,5,6]]}, 18]]],\n [19, 20],\n 21, 22\n ]'';\n\nSELECT JSON_EXTRACT(@json, ''$[0 to 3][2]'');\n+-----------------------------------------------+\n| JSON_EXTRACT(@json, ''$[0 to 3][2]'') |\n+-----------------------------------------------+\n| [3, 6, [9, {"key2": 2}, 11], [14]] |\n+-----------------------------------------------+\n`\n\nJSON path does not support negative indexes in an array.\n\nThis produces output for first index of eighth from last element of a two dimensional array.\n\nNote: In range notation, when M > N ( when M,N are greater than or equal to 0) or (size of array - M or size of array - N when M, N are less than 0), then it is treated as an impossible range and NULL is returned.\n\n`sql\nSET @json= ''[1, 2, 3, 4, 5]'';\nSELECT JSON_EXTRACT(@json, ''$[4 to 2]'');\n+-----------------------------------+\n| JSON_EXTRACT(@json, ''$[4 to 2]'') |\n+-----------------------------------+\n| NULL |\n+-----------------------------------+\n`\n\nWildcard\n\nThe wildcard step, , recursively selects all child elements of the current element. Both array elements and object members are selected.\n\nThe wildcard step must not be the last step in the JSONPath expression. It must be followed by an array or object member selector step.\n\nFor example, this query selects all object members named price in the document:\n\n`sql\nSELECT json_extract(@json_doc, ''$.price'');\n`\n\nThis query, however, selects the second element in each of the arrays present in the document:\n\n`sql\nSELECT json_extract(@json_doc, ''$[2]'');\n`\n\nCompatibility\n\nMariaDB''s JSONPath syntax supports a subset of JSON Path''s definition in the SQL Standard. The most notable things not supported are the strict mode and filters.\n\nMariaDB''s JSONPath is close to MySQL''s JSONPath. The wildcard step ( ) is a non-standard extension that has the same meaning as in MySQL. The difference between MariaDB and MySQL''s JSONPath is: MySQL doesn''t allow one to specify the mode explicitly (but uses lax` mode implicitly).\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/jsonpath-expressions', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/jsonpath-expressions'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (396, 35, 'CUME\\_DIST', 'Syntax\n------\n\nCUME_DIST() OVER ( \n [ PARTITION BY partition_expression ] \n [ ORDER BY order_list ]\n)\n\nDescription\n-----------\n\nCUME_DIST() is a window function that returns the cumulative distribution of a given row. The following formula is used to calculate the value:\n\n``sql\n(number of rows <= current row) / (total rows)\n``\n\nExamples\n--------\n\ncreate table t1 (\n pk int primary key,\n a int,\n b int\n);\n\ninsert into t1 values\n( 1 , 0, 10),\n( 2 , 0, 10),\n( 3 , 1, 10),\n( 4 , 1, 10),\n( 8 , 2, 10),\n( 5 , 2, 20),\n( 6 , 2, 20),\n( 7 , 2, 20),\n( 9 , 4, 20),\n(10 , 4, 20);\n\nselect pk, a, b,\n rank() over (order by a) as rank,\n percent_rank() over (order by a) as pct_rank,\n cume_dist() over (order by a) as cume_dist\nfrom t1;\n+----+------+------+------+--------------+--------------+\n| pk | a | b | rank | pct_rank | cume_dist |\n+----+------+------+------+--------------+--------------+\n| 1 | 0 | 10 | 1 | 0.0000000000 | 0.2000000000 |\n| 2 | 0 | 10 | 1 | 0.0000000000 | 0.2000000000 |\n| 3 | 1 | 10 | 3 | 0.2222222222 | 0.4000000000 |\n| 4 | 1 | 10 | 3 | 0.2222222222 | 0.4000000000 |\n| 5 | 2 | 20 | 5 | 0.4444444444 | 0.8000000000 |\n| 6 | 2 | 20 | 5 | 0.4444444444 | 0.8000000000 |\n| 7 | 2 | 20 | 5 | 0.4444444444 | 0.8000000000 |\n| 8 | 2 | 10 | 5 | 0.4444444444 | 0.8000000000 |\n| 9 | 4 | 20 | 9 | 0.8888888889 | 1.0000000000 |\n| 10 | 4 | 20 | 9 | 0.8888888889 | 1.0000000000 |\n+----+------+------+------+--------------+--------------+\n\nselect pk, a, b,\n percent_rank() over (order by pk) as pct_rank,\n cume_dist() over (order by pk) as cume_dist\nfrom t1 order by pk;\n+----+------+------+--------------+--------------+\n| pk | a | b | pct_rank | cume_dist |\n+----+------+------+--------------+--------------+\n| 1 | 0 | 10 | 0.0000000000 | 0.1000000000 |\n| 2 | 0 | 10 | 0.1111111111 | 0.2000000000 |\n| 3 | 1 | 10 | 0.2222222222 | 0.3000000000 |\n| 4 | 1 | 10 | 0.3333333333 | 0.4000000000 |\n| 5 | 2 | 20 | 0.4444444444 | 0.5000000000 |\n| 6 | 2 | 20 | 0.5555555556 | 0.6000000000 |\n| 7 | 2 | 20 | 0.6666666667 | 0.7000000000 |\n| 8 | 2 | 10 | 0.7777777778 | 0.8000000000 |\n| 9 | 4 | 20 | 0.8888888889 | 0.9000000000 |\n| 10 | 4 | 20 | 1.0000000000 | 1.0000000000 |\n+----+------+------+--------------+--------------+\n\nselect pk, a, b,\n percent_rank() over (partition by a order by a) as pct_rank,\n cume_dist() over (partition by a order by a) as cume_dist\nfrom t1;\n+----+------+------+--------------+--------------+\n| pk | a | b | pct_rank | cume_dist |\n+----+------+------+--------------+--------------+\n| 1 | 0 | 10 | 0.0000000000 | 1.0000000000 |\n| 2 | 0 | 10 | 0.0000000000 | 1.0000000000 |\n| 3 | 1 | 10 | 0.0000000000 | 1.0000000000 |\n| 4 | 1 | 10 | 0.0000000000 | 1.0000000000 |\n| 5 | 2 | 20 | 0.0000000000 | 1.0000000000 |\n| 6 | 2 | 20 | 0.0000000000 | 1.0000000000 |\n| 7 | 2 | 20 | 0.0000000000 | 1.0000000000 |\n| 8 | 2 | 10 | 0.0000000000 | 1.0000000000 |\n| 9 | 4 | 20 | 0.0000000000 | 1.0000000000 |\n| 10 | 4 | 20 | 0.0000000000 | 1.0000000000 |\n+----+------+------+--------------+--------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/window-functions/cume_dist', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/window-functions/cume_dist'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (397, 35, 'DENSE\\_RANK', 'Syntax\n------\n\nDENSE_RANK() OVER (\n [ PARTITION BY partition_expression ]\n [ ORDER BY order_list ]\n)\n\nDescription\n-----------\n\nDENSE_RANK() is a window function that displays the number of a given row, starting at one and following the ORDER BY sequence of the window function, with identical values receiving the same result. Unlike the RANK() function, there are no skipped values if the preceding results are identical. It is also similar to the ROW_NUMBER() function except that in that function, identical values will receive a different row number for each result.\n\nExamples\n--------\n\nCREATE TABLE student(course VARCHAR(10), mark int, name varchar(10));\n\nINSERT INTO student VALUES \n (''Maths'', 60, ''Thulile''),\n (''Maths'', 60, ''Pritha''),\n (''Maths'', 70, ''Voitto''),\n (''Maths'', 55, ''Chun''),\n (''Biology'', 60, ''Bilal''),\n (''Biology'', 70, ''Roger'');\n\nSELECT \n RANK() OVER (PARTITION BY course ORDER BY mark DESC) AS rank, \n DENSE_RANK() OVER (PARTITION BY course ORDER BY mark DESC) AS dense_rank, \n ROW_NUMBER() OVER (PARTITION BY course ORDER BY mark DESC) AS row_num, \n course, mark, name \nFROM student ORDER BY course, mark DESC;\n+------+------------+---------+---------+------+---------+\n| rank | dense_rank | row_num | course | mark | name |\n+------+------------+---------+---------+------+---------+\n| 1 | 1 | 1 | Biology | 70 | Roger |\n| 2 | 2 | 2 | Biology | 60 | Bilal |\n| 1 | 1 | 1 | Maths | 70 | Voitto |\n| 2 | 2 | 2 | Maths | 60 | Thulile |\n| 2 | 2 | 3 | Maths | 60 | Pritha |\n| 4 | 3 | 4 | Maths | 55 | Chun |\n+------+------------+---------+---------+------+---------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/window-functions/dense_rank', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/window-functions/dense_rank'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (398, 35, 'FIRST\\_VALUE', 'Syntax\n------\n\nFIRST_VALUE(expr) OVER (\n [ PARTITION BY partition_expression ]\n [ ORDER BY order_list ]\n)\n\nDescription\n-----------\n\nFIRST_VALUE returns the first result from an ordered set, or NULL if no such result exists.\n\nExamples\n--------\n\nCREATE TABLE t1 (\n pk int primary key,\n a int,\n b int,\n c char(10),\n d decimal(10, 3),\n e real\n);\n\nINSERT INTO t1 VALUES\n( 1, 0, 1, ''one'', 0.1, 0.001),\n( 2, 0, 2, ''two'', 0.2, 0.002),\n( 3, 0, 3, ''three'', 0.3, 0.003),\n( 4, 1, 2, ''three'', 0.4, 0.004),\n( 5, 1, 1, ''two'', 0.5, 0.005),\n( 6, 1, 1, ''one'', 0.6, 0.006),\n( 7, 2, NULL, ''n_one'', 0.5, 0.007),\n( 8, 2, 1, ''n_two'', NULL, 0.008),\n( 9, 2, 2, NULL, 0.7, 0.009),\n(10, 2, 0, ''n_four'', 0.8, 0.010),\n(11, 2, 10, NULL, 0.9, NULL);\n\nSELECT pk, FIRST_VALUE(pk) OVER (ORDER BY pk) AS first_asc,\n LAST_VALUE(pk) OVER (ORDER BY pk) AS last_asc,\n FIRST_VALUE(pk) OVER (ORDER BY pk DESC) AS first_desc,\n LAST_VALUE(pk) OVER (ORDER BY pk DESC) AS last_desc\nFROM t1\nORDER BY pk DESC;\n\n+----+-----------+----------+------------+-----------+\n| pk | first_asc | last_asc | first_desc | last_desc |\n+----+-----------+----------+------------+-----------+\n| 11 | 1 | 11 | 11 | 11 |\n| 10 | 1 | 10 | 11 | 10 |\n| 9 | 1 | 9 | 11 | 9 |\n| 8 | 1 | 8 | 11 | 8 |\n| 7 | 1 | 7 | 11 | 7 |\n| 6 | 1 | 6 | 11 | 6 |\n| 5 | 1 | 5 | 11 | 5 |\n| 4 | 1 | 4 | 11 | 4 |\n| 3 | 1 | 3 | 11 | 3 |\n| 2 | 1 | 2 | 11 | 2 |\n| 1 | 1 | 1 | 11 | 1 |\n+----+-----------+----------+------------+-----------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/window-functions/first_value', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/window-functions/first_value'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (399, 35, 'LAG', 'Syntax\n------\n\nLAG (expr[, offset]) OVER ( \n [ PARTITION BY partition_expression ] \n < ORDER BY order_list >\n)\n\nDescription\n-----------\n\nThe LAG function accesses data from a previous row according to the ORDER BY clause without the need for a self-join. The specific row is determined by the _offset_ (default _1_), which specifies the number of rows behind the current row to use. An offset of _0_ is the current row.\n\nExamples\n--------\n\nCREATE TABLE t1 (pk int primary key, a int, b int, c char(10), d decimal(10, 3), e real);\n\nINSERT INTO t1 VALUES\n ( 1, 0, 1, ''one'', 0.1, 0.001),\n ( 2, 0, 2, ''two'', 0.2, 0.002),\n ( 3, 0, 3, ''three'', 0.3, 0.003),\n ( 4, 1, 2, ''three'', 0.4, 0.004),\n ( 5, 1, 1, ''two'', 0.5, 0.005),\n ( 6, 1, 1, ''one'', 0.6, 0.006),\n ( 7, 2, NULL, ''n_one'', 0.5, 0.007),\n ( 8, 2, 1, ''n_two'', NULL, 0.008),\n ( 9, 2, 2, NULL, 0.7, 0.009),\n (10, 2, 0, ''n_four'', 0.8, 0.010),\n (11, 2, 10, NULL, 0.9, NULL);\n\nSELECT pk, LAG(pk) OVER (ORDER BY pk) AS l,\n LAG(pk,1) OVER (ORDER BY pk) AS l1,\n LAG(pk,2) OVER (ORDER BY pk) AS l2,\n LAG(pk,0) OVER (ORDER BY pk) AS l0,\n LAG(pk,-1) OVER (ORDER BY pk) AS lm1,\n LAG(pk,-2) OVER (ORDER BY pk) AS lm2 \nFROM t1;\n+----+------+------+------+------+------+------+\n| pk | l | l1 | l2 | l0 | lm1 | lm2 |\n+----+------+------+------+------+------+------+\n| 1 | NULL | NULL | NULL | 1 | 2 | 3 |\n| 2 | 1 | 1 | NULL | 2 | 3 | 4 |\n| 3 | 2 | 2 | 1 | 3 | 4 | 5 |\n| 4 | 3 | 3 | 2 | 4 | 5 | 6 |\n| 5 | 4 | 4 | 3 | 5 | 6 | 7 |\n| 6 | 5 | 5 | 4 | 6 | 7 | 8 |\n| 7 | 6 | 6 | 5 | 7 | 8 | 9 |\n| 8 | 7 | 7 | 6 | 8 | 9 | 10 |\n| 9 | 8 | 8 | 7 | 9 | 10 | 11 |\n| 10 | 9 | 9 | 8 | 10 | 11 | NULL |\n| 11 | 10 | 10 | 9 | 11 | NULL | NULL |\n+----+------+------+------+------+------+------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/window-functions/lag', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/window-functions/lag'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (400, 35, 'LEAD', 'Syntax\n------\n\nLEAD (expr[, offset]) OVER ( \n [ PARTITION BY partition_expression ] \n [ ORDER BY order_list ]\n)\n\nDescription\n-----------\n\nThe LEAD function accesses data from a following row in the same result set without the need for a self-join. The specific row is determined by the _offset_ (default _1_), which specifies the number of rows ahead the current row to use. An offset of _0_ is the current row.\n\nExamples\n--------\n\nCREATE TABLE t1 (pk int primary key, a int, b int, c char(10), d decimal(10, 3), e real);\n\nINSERT INTO t1 VALUES\n ( 1, 0, 1, ''one'', 0.1, 0.001),\n ( 2, 0, 2, ''two'', 0.2, 0.002),\n ( 3, 0, 3, ''three'', 0.3, 0.003),\n ( 4, 1, 2, ''three'', 0.4, 0.004),\n ( 5, 1, 1, ''two'', 0.5, 0.005),\n ( 6, 1, 1, ''one'', 0.6, 0.006),\n ( 7, 2, NULL, ''n_one'', 0.5, 0.007),\n ( 8, 2, 1, ''n_two'', NULL, 0.008),\n ( 9, 2, 2, NULL, 0.7, 0.009),\n (10, 2, 0, ''n_four'', 0.8, 0.010),\n (11, 2, 10, NULL, 0.9, NULL);\n\nSELECT pk, LEAD(pk) OVER (ORDER BY pk) AS l,\n LEAD(pk,1) OVER (ORDER BY pk) AS l1,\n LEAD(pk,2) OVER (ORDER BY pk) AS l2,\n LEAD(pk,0) OVER (ORDER BY pk) AS l0,\n LEAD(pk,-1) OVER (ORDER BY pk) AS lm1,\n LEAD(pk,-2) OVER (ORDER BY pk) AS lm2 \nFROM t1;\n+----+------+------+------+------+------+------+\n| pk | l | l1 | l2 | l0 | lm1 | lm2 |\n+----+------+------+------+------+------+------+\n| 1 | 2 | 2 | 3 | 1 | NULL | NULL |\n| 2 | 3 | 3 | 4 | 2 | 1 | NULL |\n| 3 | 4 | 4 | 5 | 3 | 2 | 1 |\n| 4 | 5 | 5 | 6 | 4 | 3 | 2 |\n| 5 | 6 | 6 | 7 | 5 | 4 | 3 |\n| 6 | 7 | 7 | 8 | 6 | 5 | 4 |\n| 7 | 8 | 8 | 9 | 7 | 6 | 5 |\n| 8 | 9 | 9 | 10 | 8 | 7 | 6 |\n| 9 | 10 | 10 | 11 | 9 | 8 | 7 |\n| 10 | 11 | 11 | NULL | 10 | 9 | 8 |\n| 11 | NULL | NULL | NULL | 11 | 10 | 9 |\n+----+------+------+------+------+------+------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/window-functions/lead', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/window-functions/lead'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (401, 35, 'MEDIAN', 'Syntax\n------\n\nMEDIAN(median expression) OVER (\n [ PARTITION BY partition_expression ] \n)\n\nDescription\n-----------\n\nMEDIAN() is a window function that returns the median value of a range of values.\n\nIt is a specific case of PERCENTILE_CONT, with an argument of 0.5 and the ORDER BY column the one in MEDIAN''s argument.\n\n``sql\nMEDIAN() OVER ( [ PARTITION BY partition_expression] )\n`\n\nIs equivalent to:\n\n`sql\nPERCENTILE_CONT(0.5) WITHIN \n GROUP (ORDER BY ) OVER ( [ PARTITION BY partition_expression ])\n``\n\nExamples\n--------\n\nCREATE TABLE book_rating (name CHAR(30), star_rating TINYINT);\n\nINSERT INTO book_rating VALUES (''Lord of the Ladybirds'', 5);\nINSERT INTO book_rating VALUES (''Lord of the Ladybirds'', 3);\nINSERT INTO book_rating VALUES (''Lady of the Flies'', 1);\nINSERT INTO book_rating VALUES (''Lady of the Flies'', 2);\nINSERT INTO book_rating VALUES (''Lady of the Flies'', 5);\n\nSELECT name, median(star_rating) OVER (PARTITION BY name) FROM book_rating;\n+-----------------------+----------------------------------------------+\n| name | median(star_rating) OVER (PARTITION BY name) |\n+-----------------------+----------------------------------------------+\n| Lord of the Ladybirds | 4.0000000000 |\n| Lord of the Ladybirds | 4.0000000000 |\n| Lady of the Flies | 2.0000000000 |\n| Lady of the Flies | 2.0000000000 |\n| Lady of the Flies | 2.0000000000 |\n+-----------------------+----------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/window-functions/median', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/window-functions/median'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (402, 35, 'NTH\\_VALUE', 'Syntax\n------\n\nNTH_VALUE (expr[, num_row]) OVER ( \n [ PARTITION BY partition_expression ] \n [ ORDER BY order_list ]\n)\n\nDescription\n-----------\n\nThe NTH_VALUE function returns the value evaluated at row number num_row of the window frame, starting from 1, or NULL if the row does not exist.\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/window-functions/nth_value', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/window-functions/nth_value'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (403, 35, 'NTILE', 'Syntax\n------\n\nNTILE (expr) OVER ( \n [ PARTITION BY partition_expression ] \n [ ORDER BY order_list ]\n)\n\nDescription\n-----------\n\nNTILE() is a window function that returns an integer indicating which group a given row falls into. The number of groups is specified in the argument (_expr_), starting at one. Ordered rows in the partition are divided into the specified number of groups with as equal a size as possible.\n\nExamples\n--------\n\ncreate table t1 (\n pk int primary key,\n a int,\n b int\n );\n\ninsert into t1 values\n (11 , 0, 10),\n (12 , 0, 10),\n (13 , 1, 10),\n (14 , 1, 10),\n (18 , 2, 10),\n (15 , 2, 20),\n (16 , 2, 20),\n (17 , 2, 20),\n (19 , 4, 20),\n (20 , 4, 20);\n\nselect pk, a, b,\n ntile(1) over (order by pk)\n from t1;\n+----+------+------+-----------------------------+\n| pk | a | b | ntile(1) over (order by pk) |\n+----+------+------+-----------------------------+\n| 11 | 0 | 10 | 1 |\n| 12 | 0 | 10 | 1 |\n| 13 | 1 | 10 | 1 |\n| 14 | 1 | 10 | 1 |\n| 15 | 2 | 20 | 1 |\n| 16 | 2 | 20 | 1 |\n| 17 | 2 | 20 | 1 |\n| 18 | 2 | 10 | 1 |\n| 19 | 4 | 20 | 1 |\n| 20 | 4 | 20 | 1 |\n+----+------+------+-----------------------------+\n\nselect pk, a, b,\n ntile(4) over (order by pk)\n from t1;\n+----+------+------+-----------------------------+\n| pk | a | b | ntile(4) over (order by pk) |\n+----+------+------+-----------------------------+\n| 11 | 0 | 10 | 1 |\n| 12 | 0 | 10 | 1 |\n| 13 | 1 | 10 | 1 |\n| 14 | 1 | 10 | 2 |\n| 15 | 2 | 20 | 2 |\n| 16 | 2 | 20 | 2 |\n| 17 | 2 | 20 | 3 |\n| 18 | 2 | 10 | 3 |\n| 19 | 4 | 20 | 4 |\n| 20 | 4 | 20 | 4 |\n+----+------+------+-----------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/window-functions/ntile', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/window-functions/ntile'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (404, 35, 'PERCENT\\_RANK', 'Syntax\n------\n\nPERCENT_RANK() OVER (\n [ PARTITION BY partition_expression ] \n [ ORDER BY order_list ]\n)\n\nDescription\n-----------\n\nPERCENT_RANK() is a window function that returns the relative percent rank of a given row. The following formula is used to calculate the percent rank:\n\n``sql\n(rank - 1) / (number of rows in the window or partition - 1)\n``\n\nExamples\n--------\n\ncreate table t1 (\n pk int primary key,\n a int,\n b int\n);\n\ninsert into t1 values\n( 1 , 0, 10),\n( 2 , 0, 10),\n( 3 , 1, 10),\n( 4 , 1, 10),\n( 8 , 2, 10),\n( 5 , 2, 20),\n( 6 , 2, 20),\n( 7 , 2, 20),\n( 9 , 4, 20),\n(10 , 4, 20);\n\nselect pk, a, b,\n rank() over (order by a) as rank,\n percent_rank() over (order by a) as pct_rank,\n cume_dist() over (order by a) as cume_dist\nfrom t1;\n+----+------+------+------+--------------+--------------+\n| pk | a | b | rank | pct_rank | cume_dist |\n+----+------+------+------+--------------+--------------+\n| 1 | 0 | 10 | 1 | 0.0000000000 | 0.2000000000 |\n| 2 | 0 | 10 | 1 | 0.0000000000 | 0.2000000000 |\n| 3 | 1 | 10 | 3 | 0.2222222222 | 0.4000000000 |\n| 4 | 1 | 10 | 3 | 0.2222222222 | 0.4000000000 |\n| 5 | 2 | 20 | 5 | 0.4444444444 | 0.8000000000 |\n| 6 | 2 | 20 | 5 | 0.4444444444 | 0.8000000000 |\n| 7 | 2 | 20 | 5 | 0.4444444444 | 0.8000000000 |\n| 8 | 2 | 10 | 5 | 0.4444444444 | 0.8000000000 |\n| 9 | 4 | 20 | 9 | 0.8888888889 | 1.0000000000 |\n| 10 | 4 | 20 | 9 | 0.8888888889 | 1.0000000000 |\n+----+------+------+------+--------------+--------------+\n\nselect pk, a, b,\n percent_rank() over (order by pk) as pct_rank,\n cume_dist() over (order by pk) as cume_dist\nfrom t1 order by pk;\n+----+------+------+--------------+--------------+\n| pk | a | b | pct_rank | cume_dist |\n+----+------+------+--------------+--------------+\n| 1 | 0 | 10 | 0.0000000000 | 0.1000000000 |\n| 2 | 0 | 10 | 0.1111111111 | 0.2000000000 |\n| 3 | 1 | 10 | 0.2222222222 | 0.3000000000 |\n| 4 | 1 | 10 | 0.3333333333 | 0.4000000000 |\n| 5 | 2 | 20 | 0.4444444444 | 0.5000000000 |\n| 6 | 2 | 20 | 0.5555555556 | 0.6000000000 |\n| 7 | 2 | 20 | 0.6666666667 | 0.7000000000 |\n| 8 | 2 | 10 | 0.7777777778 | 0.8000000000 |\n| 9 | 4 | 20 | 0.8888888889 | 0.9000000000 |\n| 10 | 4 | 20 | 1.0000000000 | 1.0000000000 |\n+----+------+------+--------------+--------------+\n\nselect pk, a, b,\n percent_rank() over (partition by a order by a) as pct_rank,\n cume_dist() over (partition by a order by a) as cume_dist\nfrom t1;\n+----+------+------+--------------+--------------+\n| pk | a | b | pct_rank | cume_dist |\n+----+------+------+--------------+--------------+\n| 1 | 0 | 10 | 0.0000000000 | 1.0000000000 |\n| 2 | 0 | 10 | 0.0000000000 | 1.0000000000 |\n| 3 | 1 | 10 | 0.0000000000 | 1.0000000000 |\n| 4 | 1 | 10 | 0.0000000000 | 1.0000000000 |\n| 5 | 2 | 20 | 0.0000000000 | 1.0000000000 |\n| 6 | 2 | 20 | 0.0000000000 | 1.0000000000 |\n| 7 | 2 | 20 | 0.0000000000 | 1.0000000000 |\n| 8 | 2 | 10 | 0.0000000000 | 1.0000000000 |\n| 9 | 4 | 20 | 0.0000000000 | 1.0000000000 |\n| 10 | 4 | 20 | 0.0000000000 | 1.0000000000 |\n+----+------+------+--------------+--------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/window-functions/percent_rank', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/window-functions/percent_rank'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (405, 35, 'PERCENTILE\\_CONT', 'Description\n-----------\n\nPERCENTILE_CONT() (standing for continuous percentile) is a window function which returns a value which corresponds to the given fraction in the sort order. If required, it will interpolate between adjacent input items.\n\nEssentially, the following process is followed to find the value to return:\n\n Get the number of rows in the partition, denoted by N\n RN = p\\(N-1), where p denotes the argument to the PERCENTILE_CONT function\n Calculate FRN as FRN=floor(RN) and CRN as CRN=ceil(RN)\n Look up rows FRN and CRN\n If (CRN = FRN = RN) then the result is (value of expression from row at RN)\n Otherwise the result is\n (CRN - RN) \\ (value of expression for row at FRN) +\n (RN - FRN) \\* (value of expression for row at CRN)\n\nThe MEDIAN function is a specific case of PERCENTILE_CONT, equivalent to PERCENTILE_CONT(0.5).\n\nExamples\n--------\n\nCREATE TABLE book_rating (name CHAR(30), star_rating TINYINT);\n\nINSERT INTO book_rating VALUES (''Lord of the Ladybirds'', 5);\nINSERT INTO book_rating VALUES (''Lord of the Ladybirds'', 3);\nINSERT INTO book_rating VALUES (''Lady of the Flies'', 1);\nINSERT INTO book_rating VALUES (''Lady of the Flies'', 2);\nINSERT INTO book_rating VALUES (''Lady of the Flies'', 5);\n\nSELECT name, PERCENTILE_CONT(0.5) WITHIN GROUP (ORDER BY star_rating) \n OVER (PARTITION BY name) AS pc \n FROM book_rating;\n+-----------------------+--------------+\n| name | pc |\n+-----------------------+--------------+\n| Lord of the Ladybirds | 4.0000000000 |\n| Lord of the Ladybirds | 4.0000000000 |\n| Lady of the Flies | 2.0000000000 |\n| Lady of the Flies | 2.0000000000 |\n| Lady of the Flies | 2.0000000000 |\n+-----------------------+--------------+\n\nSELECT name, PERCENTILE_CONT(1) WITHIN GROUP (ORDER BY star_rating) \n OVER (PARTITION BY name) AS pc \n FROM book_rating;\n+-----------------------+--------------+\n| name | pc |\n+-----------------------+--------------+\n| Lord of the Ladybirds | 5.0000000000 |\n| Lord of the Ladybirds | 5.0000000000 |\n| Lady of the Flies | 5.0000000000 |\n| Lady of the Flies | 5.0000000000 |\n| Lady of the Flies | 5.0000000000 |\n+-----------------------+--------------+\n\nSELECT name, PERCENTILE_CONT(0) WITHIN GROUP (ORDER BY star_rating) \n OVER (PARTITION BY name) AS pc \n FROM book_rating;\n+-----------------------+--------------+\n| name | pc |\n+-----------------------+--------------+\n| Lord of the Ladybirds | 3.0000000000 |\n| Lord of the Ladybirds | 3.0000000000 |\n| Lady of the Flies | 1.0000000000 |\n| Lady of the Flies | 1.0000000000 |\n| Lady of the Flies | 1.0000000000 |\n+-----------------------+--------------+\n\nSELECT name, PERCENTILE_CONT(0.6) WITHIN GROUP (ORDER BY star_rating) \n OVER (PARTITION BY name) AS pc \n FROM book_rating;\n+-----------------------+--------------+\n| name | pc |\n+-----------------------+--------------+\n| Lord of the Ladybirds | 4.2000000000 |\n| Lord of the Ladybirds | 4.2000000000 |\n| Lady of the Flies | 2.6000000000 |\n| Lady of the Flies | 2.6000000000 |\n| Lady of the Flies | 2.6000000000 |\n+-----------------------+--------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/window-functions/percentile_cont', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/window-functions/percentile_cont'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (406, 35, 'PERCENTILE\\_DISC', 'Description\n-----------\n\nPERCENTILE_DISC() (standing for discrete percentile) is a window function which returns the first value in the set whose ordered position is the same or more than the specified fraction.\n\nEssentially, the following process is followed to find the value to return:\n\n Get the number of rows in the partition.\n Walk through the partition, in order, until finding the first row with CUME_DIST() >= function_argument.\n\nExamples\n--------\n\nCREATE TABLE book_rating (name CHAR(30), star_rating TINYINT);\n\nINSERT INTO book_rating VALUES (''Lord of the Ladybirds'', 5);\nINSERT INTO book_rating VALUES (''Lord of the Ladybirds'', 3);\nINSERT INTO book_rating VALUES (''Lady of the Flies'', 1);\nINSERT INTO book_rating VALUES (''Lady of the Flies'', 2);\nINSERT INTO book_rating VALUES (''Lady of the Flies'', 5);\n\nSELECT name, PERCENTILE_DISC(0.5) WITHIN GROUP (ORDER BY star_rating)\n OVER (PARTITION BY name) AS pc FROM book_rating;\n+-----------------------+------+\n| name | pc |\n+-----------------------+------+\n| Lord of the Ladybirds | 3 |\n| Lord of the Ladybirds | 3 |\n| Lady of the Flies | 2 |\n| Lady of the Flies | 2 |\n| Lady of the Flies | 2 |\n+-----------------------+------+\n5 rows in set (0.000 sec)\n\nSELECT name, PERCENTILE_DISC(0) WITHIN GROUP (ORDER BY star_rating) \n OVER (PARTITION BY name) AS pc FROM book_rating;\n+-----------------------+------+\n| name | pc |\n+-----------------------+------+\n| Lord of the Ladybirds | 3 |\n| Lord of the Ladybirds | 3 |\n| Lady of the Flies | 1 |\n| Lady of the Flies | 1 |\n| Lady of the Flies | 1 |\n+-----------------------+------+\n5 rows in set (0.000 sec)\n\nSELECT name, PERCENTILE_DISC(1) WITHIN GROUP (ORDER BY star_rating) \n OVER (PARTITION BY name) AS pc FROM book_rating;\n+-----------------------+------+\n| name | pc |\n+-----------------------+------+\n| Lord of the Ladybirds | 5 |\n| Lord of the Ladybirds | 5 |\n| Lady of the Flies | 5 |\n| Lady of the Flies | 5 |\n| Lady of the Flies | 5 |\n+-----------------------+------+\n5 rows in set (0.000 sec)\n\nSELECT name, PERCENTILE_DISC(0.6) WITHIN GROUP (ORDER BY star_rating) \n OVER (PARTITION BY name) AS pc FROM book_rating;\n+-----------------------+------+\n| name | pc |\n+-----------------------+------+\n| Lord of the Ladybirds | 5 |\n| Lord of the Ladybirds | 5 |\n| Lady of the Flies | 2 |\n| Lady of the Flies | 2 |\n| Lady of the Flies | 2 |\n+-----------------------+------\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/window-functions/percentile_disc', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/window-functions/percentile_disc'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (407, 35, 'RANK', 'Syntax\n------\n\nRANK() OVER (\n [ PARTITION BY partition_expression ]\n [ ORDER BY order_list ]\n)\n\nDescription\n-----------\n\nRANK() is a window function that displays the number of a given row, starting at one and following the ORDER BY sequence of the window function, with identical values receiving the same result. It is similar to the ROW_NUMBER() function except that in that function, identical values will receive a different row number for each result.\n\nExamples\n--------\n\nCREATE TABLE student(course VARCHAR(10), mark int, name varchar(10));\n\nINSERT INTO student VALUES \n (''Maths'', 60, ''Thulile''),\n (''Maths'', 60, ''Pritha''),\n (''Maths'', 70, ''Voitto''),\n (''Maths'', 55, ''Chun''),\n (''Biology'', 60, ''Bilal''),\n (''Biology'', 70, ''Roger'');\n\nSELECT \n RANK() OVER (PARTITION BY course ORDER BY mark DESC) AS rank, \n DENSE_RANK() OVER (PARTITION BY course ORDER BY mark DESC) AS dense_rank, \n ROW_NUMBER() OVER (PARTITION BY course ORDER BY mark DESC) AS row_num, \n course, mark, name \nFROM student ORDER BY course, mark DESC;\n+------+------------+---------+---------+------+---------+\n| rank | dense_rank | row_num | course | mark | name |\n+------+------------+---------+---------+------+---------+\n| 1 | 1 | 1 | Biology | 70 | Roger |\n| 2 | 2 | 2 | Biology | 60 | Bilal |\n| 1 | 1 | 1 | Maths | 70 | Voitto |\n| 2 | 2 | 2 | Maths | 60 | Thulile |\n| 2 | 2 | 3 | Maths | 60 | Pritha |\n| 4 | 3 | 4 | Maths | 55 | Chun |\n+------+------------+---------+---------+------+---------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/window-functions/rank', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/window-functions/rank'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (408, 35, 'ROW\\_NUMBER', 'Syntax\n------\n\nROW_NUMBER() OVER (\n [ PARTITION BY partition_expression ]\n [ ORDER BY order_list ]\n)\n\nDescription\n-----------\n\nROW_NUMBER() is a window function that displays the number of a given row, starting at one and following the ORDER BY sequence of the window function, with identical values receiving different row numbers. It is similar to the RANK() and DENSE_RANK() functions except that in that function, identical values will receive the same rank for each result.\n\nExamples\n--------\n\nCREATE TABLE student(course VARCHAR(10), mark int, name varchar(10));\n\nINSERT INTO student VALUES \n (''Maths'', 60, ''Thulile''),\n (''Maths'', 60, ''Pritha''),\n (''Maths'', 70, ''Voitto''),\n (''Maths'', 55, ''Chun''),\n (''Biology'', 60, ''Bilal''),\n (''Biology'', 70, ''Roger'');\n\nSELECT \n RANK() OVER (PARTITION BY course ORDER BY mark DESC) AS rank, \n DENSE_RANK() OVER (PARTITION BY course ORDER BY mark DESC) AS dense_rank, \n ROW_NUMBER() OVER (PARTITION BY course ORDER BY mark DESC) AS row_num, \n course, mark, name \nFROM student ORDER BY course, mark DESC;\n+------+------------+---------+---------+------+---------+\n| rank | dense_rank | row_num | course | mark | name |\n+------+------------+---------+---------+------+---------+\n| 1 | 1 | 1 | Biology | 70 | Roger |\n| 2 | 2 | 2 | Biology | 60 | Bilal |\n| 1 | 1 | 1 | Maths | 70 | Voitto |\n| 2 | 2 | 2 | Maths | 60 | Thulile |\n| 2 | 2 | 3 | Maths | 60 | Pritha |\n| 4 | 3 | 4 | Maths | 55 | Chun |\n+------+------------+---------+---------+------+---------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/window-functions/row_number', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/window-functions/row_number'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (409, 35, 'Window Frames', 'Description\n-----------\n\nBasic Syntax\n\n``sql\nframe_clause:\n {ROWS | RANGE} {frame_border | BETWEEN frame_border AND frame_border}\n\nframe_border:\n | UNBOUNDED PRECEDING\n | UNBOUNDED FOLLOWING\n | CURRENT ROW\n | expr PRECEDING\n | expr FOLLOWING\n`\n\nHow Window Frames Work\n\nA basic overview of window functions is described in Window Functions Overview. Window frames define which rows contribute to the current result.\n\nWindow frames are used by aggregate window functions. They are defined by the frame clause inside OVER (...).\n\nOVER () uses the whole result set.\n\nFor aggregate window functions, OVER (ORDER BY ...) uses a running frame by default. In MariaDB, that default is RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW.\n\nFrame Bound Types\n\nCommon frame bounds include:\n\n All rows before the current row (UNBOUNDED PRECEDING), for example RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW .\n All rows after the current row (UNBOUNDED FOLLOWING), for example RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING .\n A set number of rows before the current row (expr PRECEDING), for example RANGE BETWEEN 6 PRECEDING AND CURRENT ROW .\n A set number of rows after the current row (expr FOLLOWING), for example RANGE BETWEEN CURRENT ROW AND 2 FOLLOWING .\n* A specified number of rows both before and after the current row, for example RANGE BETWEEN 6 PRECEDING AND 3 FOLLOWING .\n\nROWS vs RANGE\n\nROWS counts physical rows. RANGE groups peer rows that share the same ORDER BY value.\n\nUse ROWS when you want strict row-by-row stepping. Use RANGE when tied sort values should be treated as one peer group.\n\nAggregate Functions Using Frames\n\nSee list here.\n\nExamples\n--------\n\nCREATE TABLE student_test` (\n name char(10),\n test char(10),\n score tinyint(4)\n);\n\nINSERT INTO student_test VALUES \n (''Chun'', ''SQL'', 75), (''Chun'', ''Tuning'', 73), \n (''Esben'', ''SQL'', 43), (''Esben'', ''Tuning'', 31), \n (''Kaolin'', ''SQL'', 56), (''Kaolin'', ''Tuning'', 88), \n (''Tatiana'', ''SQL'', 87);\n\nSELECT name, test, score, SUM(score) \n OVER () AS total_score \n FROM student_test;\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/window-functions/window-frames', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/window-functions/window-frames'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (410, 35, 'ColumnStore Window Functions', 'Description\n-----------\n\nIntroduction\n\nMariaDB ColumnStore provides support for window functions broadly following the SQL 2003 specification. A window function allows for calculations relating to a window of data surrounding the current row in a result set. This capability provides for simplified queries in support of common business questions such as cumulative totals, rolling averages, and top 10 lists.\n\nAggregate functions are utilized for window functions however differ in behavior from a group by query because the rows remain ungrouped. This provides support for cumulative sums and rolling averages, for example.\n\nTwo key concepts for window functions are Partition and Frame:\n\n A Partition is a group of rows, or window, that have the same value for a specific column, for example a Partition can be created over a time period such as a quarter or lookup values.\n The Frame for each row is a subset of the row''s Partition. The frame typically is dynamic allowing for a sliding frame of rows within the Partition. The Frame determines the range of rows for the windowing function. A Frame could be defined as the last X rows and next Y rows all the way up to the entire Partition.\n\nWindow functions are applied after joins, group by, and having clauses are calculated.\n\nSyntax\n\nA window function is applied in the select clause using the following syntax:\n\n``sql\nfunction_name ([expression [, expression ... ]]) OVER ( window_definition )\n`\n\nwhere _window_definition_ is defined as:\n\n`sql\n[ PARTITION BY expression [, ...] ]\n[ ORDER BY expression [ ASC | DESC ] [ NULLS { FIRST | LAST } ] [, ...] ]\n[ frame_clause ]\n`\n\nPARTITION BY:\n\n Divides the window result set into groups based on one or more expressions.\n An expression may be a constant, column, and non window function expressions.\n A query is not limited to a single partition by clause. Different partition clauses can be used across different window function applications.\n The partition by columns do not need to be in the select list but do need to be available from the query result set.\n If there is no PARTITION BY clause, all rows of the result set define the group.\n\nORDER BY:\n\n Defines the ordering of values within the partition.\n Can be ordered by multiple keys which may be a constant, column or non window function expression.\n The order by columns do not need to be in the select list but need to be available from the query result set.\n Use of a select column alias from the query is not supported.\n ASC (default) and DESC options allow for ordering ascending or descending.\n NULLS FIRST and NULL_LAST options specify whether null values come first or last in the ordering sequence. NULLS_FIRST is the default for ASC order, and NULLS_LAST is the default for DESC order.\n\nand the optional _frame_clause_ is defined as:\n\n`sql\n{ RANGE | ROWS } frame_start\n{ RANGE | ROWS } BETWEEN frame_start AND frame_end\n`\n\nand the optional _frame_start_ and _frame_end_ are defined as (value being a numeric expression):\n\n`sql\nUNBOUNDED PRECEDING\nvalue PRECEDING\nCURRENT ROW\nvalue FOLLOWING\nUNBOUNDED FOLLOWING\n`\n\nRANGE/ROWS:\n\n Defines the windowing clause for calculating the set of rows that the function applies to for calculating a given rows window function result.\n Requires an ORDER BY clause to define the row order for the window.\n ROWS specify the window in physical units, i.e. result set rows and must be a constant or expression evaluating to a positive numeric value.\n RANGE specifies the window as a logical offset. If the expression evaluates to a numeric value then the ORDER BY expression must be a numeric or DATE type. If the expression evaluates to an interval value then the ORDER BY expression must be a DATE data type.\n UNBOUNDED PRECEDING indicates the window starts at the first row of the partition.\n UNBOUNDED FOLLOWING indicates the window ends at the last row of the partition.\n CURRENT ROW specifies the window start or ends at the current row or value.\n* If omitted, the default is ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW`.\n\nSupported Functions\n\n| Function | Description |\n| ---------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| AVG() | The average of all input values. |\n| COUNT() | Number of input rows. |\n| CUME_DIST() | Calculates the cumulative distribution, or relative rank, of the current row to other rows in the same partition. Number of peer or preceding rows / number of rows in partition. |\n| DENSE_RANK() | Ranks items in a group leaving no gaps in ranking sequence when there are ties. |\n| FIRST_VALUE() | The value evaluated at the row that is the first row of the window frame (counting from 1); null if no such row. |\n| LAG() | The value evaluated at the row that is offset rows before the current row within the partition; if there is no such row, instead return default. Both offset and default are evaluated with respect to the current row. If omitted, offset defaults to 1 and default to null. LAG provides access to more than one row of a table at the same time without a self-join. Given a series of rows returned from a query and a position of the cursor, LAG provides access to a row at a given physical offset prior to that position. |\n| LAST_VALUE() | The value evaluated at the row that is the last row of the window frame (counting from 1); null if no such row. |\n| LEAD() | Provides access to a row at a given physical offset beyond that position. Returns value evaluated at the row that is offset rows after the current row within the partition; if there is no such row, instead return default. Both offset and default are evaluated with respect to the current row. If omitted, offset defaults to 1 and default to null. |\n| MAX() | Maximum value of expression across all input values. |\n| MEDIAN() | An inverse distribution function that assumes a continuous distribution model. It takes a numeric or datetime value and returns the middle value or an interpolated value that would be the middle value once the values are sorted. Nulls are ignored in the calculation. |\n| MIN() | Minimum value of expression across all input values. |\n| NTH_VALUE() | The value evaluated at the row that is the nth row of the window frame (counting from 1); null if no such row. |\n| NTILE() | Divides an ordered data set into a number of buckets indicated by expr and assigns the appropriate bucket number to each row. The buckets are numbered 1 through expr. The expr value must resolve to a positive constant for each partition. Integer ranging from 1 to the argument value, dividing the partition as equally as possible. |\n| PERCENT_RANK() | relative rank of the current row: (rank - 1) / (total rows - 1). |\n| PERCENTILE_CONT() | An inverse distribution function that assumes a continuous distribution model. It takes a percentile value and a sort specification, and returns an interpolated value that would fall into that percentile value with respect to the sort specification. Nulls are ignored in the calculation. |\n| PERCENTILE_DISC() | An inverse distribution function that assumes a discrete distribution model. It takes a percentile value and a sort specification and returns an element from the set. Nulls are ignored in the calculation. |\n| RANK() | rank of the current row with gaps; same as row_number of its first peer. |\n| ROW_NUMBER() | number of the current row within its partition, counting from 1 |\n| STDDEV() STDDEV_POP() | Computes the population standard deviation a\n\n[Truncated — full content at mariadb.com/docs]', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/window-functions/window-functions-columnstore-window-functions'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (411, 35, 'Window Functions Overview', 'Description\n-----------\n\nWindow Functions\n\nWindow functions calculate across related rows without collapsing them. Unlike GROUP BY, they return one result for each input row.\n\nWhen to Use Window Functions\n\nUse window functions when you need to:\n\n Rank rows inside a group.\n Calculate running totals or moving averages.\n Compare a row with earlier or later rows.\n Return the top _N_ rows per group.\n\nBasic Syntax\n\n``sql\nwindow_function(expr) OVER (\n [PARTITION BY expr [, ...]]\n [ORDER BY expr [ASC | DESC] [, ...]]\n [{ROWS | RANGE} frame_clause]\n)\n\nframe_clause:\n {frame_border | BETWEEN frame_border AND frame_border}\n\nframe_border:\n UNBOUNDED PRECEDING\n | UNBOUNDED FOLLOWING\n | CURRENT ROW\n | expr PRECEDING\n | expr FOLLOWING\n`\n\nYou can also define a named window and reuse it:\n\n`sql\nSELECT\n SUM(score) OVER w AS running_total,\n AVG(score) OVER w AS running_avg\nFROM student\nWINDOW w AS (\n ORDER BY score\n ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW\n);\n`\n\nWindow Functions vs GROUP BY\n\nUse GROUP BY when you want one output row per group.\n\nUse a window function when you want to keep the original rows and add per-group or per-sequence calculations beside them.\n\n`sql\nSELECT test, AVG(score)\nFROM student\nGROUP BY test;\n`\n\nThis returns one row per test.\n\n`sql\nSELECT\n name,\n test,\n score,\n AVG(score) OVER (PARTITION BY test) AS avg_by_test\nFROM student;\n`\n\nThis returns every row, plus the average for that row''s test.\n\nHow OVER Works\n\nPARTITION BY\n\nPARTITION BY starts a new calculation for each group.\n\nORDER BY\n\nORDER BY defines the row sequence inside each partition.\n\nFrame\n\nThe frame controls which rows contribute to the current result. Aggregate window functions use frames. Ranking functions such as ROW_NUMBER() and RANK() do not.\n\nOVER () uses the whole result set.\n\nFor aggregate window functions, OVER (ORDER BY ...) uses a running frame by default. In MariaDB, that default is RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW.\n\nROWS vs RANGE\n\nROWS counts physical rows. RANGE groups peer rows that share the same ORDER BY value.\n\nUse ROWS when you need strict row-by-row stepping. Use RANGE when ties should be treated as one peer group.\n\n`sql\nCREATE TABLE t (score INT);\nINSERT INTO t VALUES (10), (10), (20);\n\nSELECT\n score,\n SUM(score) OVER (\n ORDER BY score\n ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW\n ) AS rows_sum,\n SUM(score) OVER (\n ORDER BY score\n RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW\n ) AS range_sum\nFROM t;\n`\n\nThis produces different results for the duplicate 10 values:\n\n`\n+-------+----------+-----------+\n| score | rows_sum | range_sum |\n+-------+----------+-----------+\n| 10 | 10 | 20 |\n| 10 | 20 | 20 |\n| 20 | 40 | 40 |\n+-------+----------+-----------+\n`\n\nSupported Functions\n\nDedicated window functions include CUME_DIST, DENSE_RANK, FIRST_VALUE, LAG, LAST_VALUE, LEAD, MEDIAN, NTH_VALUE, NTILE, PERCENTILE_CONT, PERCENTILE_DISC, PERCENT_RANK, RANK, and ROW_NUMBER.\n\nAggregate functions that also work with OVER (...) include AVG, BIT_AND, BIT_OR, BIT_XOR, COUNT, MAX, MIN, STD, STDDEV, STDDEV_POP, STDDEV_SAMP, SUM, VAR_POP, VAR_SAMP, and VARIANCE.\n\nAggregate window functions do not support DISTINCT.\n\nAggregate Functions as Window Functions\n\nIt is possible to use aggregate functions as window functions. An aggregate function used as a window function must have the OVER clause. For example, here''s COUNT() used as a window function:\n\n`sql\nSELECT COUNT() OVER (ORDER BY column) FROM table;\n`\n\nCommon Pitfalls\n\n You cannot reference a window function in WHERE.\n Compute the window result in a subquery or CTE first.\n MariaDB does not support GROUPS frames.\n MariaDB does not support frame exclusion.\n MariaDB does not support explicit NULLS FIRST or NULLS LAST.\n RANGE frames do not support DATE or DATETIME arithmetic.\n\nWindow functions are evaluated after WHERE, GROUP BY, and HAVING. Filter the computed result in an outer query or CTE.\n\nOptimization\n\nWindow functions often need sorted input. Query shape can decide whether MariaDB can reuse an existing order or must sort again.\n\nGROUP BY Comes First\n\nIf a query uses both GROUP BY and window functions, MariaDB executes the grouping step first. The window step runs on the grouped result.\n\nThis affects index usage. An index that helps the base table scan does not automatically avoid later sorting for the window stage.\n\nWhen tuning this pattern, optimize the GROUP BY step first. Then check whether the window step still needs its own sort.\n\nSort Reuse Depends on Sort Keys\n\nIf the GROUP BY definition and the window''s PARTITION BY and ORDER BY definition use different sort keys, MariaDB usually needs another sort pass before evaluating the window functions.\n\nFor example, this shape can require an extra sort:\n\n`sql\nSELECT\n dept,\n month,\n SUM(sales) AS monthly_sales,\n ROW_NUMBER() OVER (\n PARTITION BY dept\n ORDER BY month\n ) AS row_num\nFROM revenue\nGROUP BY month, dept;\n`\n\nThe grouped result is ordered by month, dept. The window step needs dept, month. Those orders do not match.\n\nMultiple Window Functions Can Share One Sort\n\nMultiple window functions can share the same sort pass when they use the same PARTITION BY and ORDER BY clause.\n\n`sql\nSELECT\n dept,\n month,\n sales,\n ROW_NUMBER() OVER (\n PARTITION BY dept\n ORDER BY month\n ) AS row_num,\n SUM(sales) OVER (\n PARTITION BY dept\n ORDER BY month\n ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW\n ) AS running_sales\nFROM revenue;\n`\n\nBoth window functions use the same partitioning and ordering. MariaDB can reuse the same sorted stream for both.\n\nPractical Tuning Tips\n\n Expect GROUP BY to shape the input seen by window functions.\n Align GROUP BY keys with the window sort keys when possible.\n Reuse the same PARTITION BY and ORDER BY` across multiple window functions.\n* Check the execution plan to see whether an extra sort is still present.\n\nExamples\n--------\n\nCREATE TABLE student (\n name CHAR(10),\n test CHAR(10),\n score TINYINT\n);\n\nINSERT INTO student VALUES\n (''Chun'', ''SQL'', 75), (''Chun'', ''Tuning'', 73),\n (''Esben'', ''SQL'', 43), (''Esben'', ''Tuning'', 31),\n (''Kaolin'', ''SQL'', 56), (''Kaolin'', ''Tuning'', 88),\n (''Tatiana'', ''SQL'', 87), (''Tatiana'', ''Tuning'', 83);\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/window-functions/window-functions-overview', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/window-functions/window-functions-overview'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (412, 37, 'ASCII', 'Syntax\n------\n\nASCII(str)\n\nDescription\n-----------\n\nReturns the numeric ASCII value of the leftmost character of the string argument. Returns 0 if the given string is empty and NULL if it is NULL.\n\nASCII() works for 8-bit characters.\n\nExamples\n--------\n\nSELECT ASCII(9);\n+----------+\n| ASCII(9) |\n+----------+\n| 57 |\n+----------+\n\nSELECT ASCII(''9'');\n+------------+\n| ASCII(''9'') |\n+------------+\n| 57 |\n+------------+\n\nSELECT ASCII(''abc'');\n+--------------+\n| ASCII(''abc'') |\n+--------------+\n| 97 |\n+--------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/ascii', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/ascii'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (413, 37, 'BIN', 'Syntax\n------\n\nBIN(N)\n\nDescription\n-----------\n\nReturns a string representation of the binary value of the given longlong (that is, BIGINT) number. This is equivalent to CONV(N,10,2). The argument should be positive. If it is a FLOAT, it will be truncated. Returns NULL if the argument is NULL.\n\nExamples\n--------\n\nSELECT BIN(12);\n+---------+\n| BIN(12) |\n+---------+\n| 1100 |\n+---------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/bin', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/bin'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (414, 37, 'BINARY Operator', 'Syntax\n------\n\nBINARY\n\nDescription\n-----------\n\nThe BINARY operator casts the string following it to a binary string. This is an easy way to force a column comparison to be done byte by byte rather than character by character. This causes the comparison to be case sensitive even if the column isn''t defined as BINARY or BLOB.\n\nBINARY also causes trailing spaces to be significant.\n\nExamples\n--------\n\nSELECT ''a'' = ''A'';\n+-----------+\n| ''a'' = ''A'' |\n+-----------+\n| 1 |\n+-----------+\n\nSELECT BINARY ''a'' = ''A'';\n+------------------+\n| BINARY ''a'' = ''A'' |\n+------------------+\n| 0 |\n+------------------+\n\nSELECT ''a'' = ''a '';\n+------------+\n| ''a'' = ''a '' |\n+------------+\n| 1 |\n+------------+\n\nSELECT BINARY ''a'' = ''a '';\n+-------------------+\n| BINARY ''a'' = ''a '' |\n+-------------------+\n| 0 |\n+-------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/binary-operator', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/binary-operator'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (415, 37, 'BIT\\_LENGTH', 'Syntax\n------\n\nBIT_LENGTH(str)\n\nDescription\n-----------\n\nReturns the length of the given string argument in bits. If the argument is not a string, it will be converted to string. If the argument is NULL, it returns NULL.\n\nExamples\n--------\n\nSELECT BIT_LENGTH(''text'');\n+--------------------+\n| BIT_LENGTH(''text'') |\n+--------------------+\n| 32 |\n+--------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/bit_length', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/bit_length'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (416, 37, 'CAST', 'Syntax\n------\n\nCAST(expr AS type)\n\nDescription\n-----------\n\nThe CAST() function takes a value of one data type and produces a value of another data type, similar to the CONVERT() function.\n\nThe type can be one of the following values:\n\n BINARY\n CHAR\n DATE\n DATETIME\n DECIMAL\n DOUBLE\n FLOAT\n INTEGER (short for SIGNED INTEGER )\n [SIGNED \\[INTEGER\\]](../../data-types/numeric-data-types/integer.md)\n [UNSIGNED \\[INTEGER\\]](../../data-types/numeric-data-types/integer.md)\n TIME\n VARCHAR\n* XMLTYPE (Available starting with MariaDB 12.3)\n\nThe main difference between CAST and CONVERT() is that CONVERT(expr,type) is ODBC syntax, while CAST(expr as type) and CONVERT(... USING ...) are SQL92 syntax.\n\nTo cast a value to a string data type while specifying the character set, use this extended syntax:\n\n``sql\n CAST(expr AS CHAR CHARACTER SET name)\n`\n\nSee the examples for casting to character sets.\n\nUsing an introducer like _utf8mb4''text'' is often more efficient than CAST(''text'' AS CHAR CHARACTER SET utf8mb4), but CAST is necessary when converting data types (like numbers to strings) into a specific encoding. See this example, too.\n\nYou can use the CAST() function with the INTERVAL` keyword.\n\nThis introduced an incompatibility with previous versions of MariaDB, and all versions of MySQL (see the example below).\n\nExamples\n--------\n\nSELECT CAST("abc" AS BINARY);\nSELECT CAST("1" AS UNSIGNED INTEGER);\nSELECT CAST(123 AS CHAR CHARACTER SET utf8)\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/cast', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/cast'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (417, 37, 'CHAR Function', 'Syntax\n------\n\nCHAR(N,... [USING charset_name])\n\nDescription\n-----------\n\nCHAR() interprets each argument as an INT and returns a string consisting of the characters given by the code values of those integers. NULL values are skipped. By default, CHAR() returns a binary string. To produce a string in a given character set, use the optional USING clause:\n\n``sql\nSELECT CHARSET(CHAR(0x65)), CHARSET(CHAR(0x65 USING utf8));\n+---------------------+--------------------------------+\n| CHARSET(CHAR(0x65)) | CHARSET(CHAR(0x65 USING utf8)) |\n+---------------------+--------------------------------+\n| binary | utf8 |\n+---------------------+--------------------------------+\n`\n\nIf USING is given and the result string is illegal for the given character set, a warning is issued. Also, if strict SQL mode is enabled, the result from CHAR() becomes NULL`.\n\nExamples\n--------\n\nSELECT CHAR(77,97,114,''105'',97,''68'',66);\n+----------------------------------+\n| CHAR(77,97,114,''105'',97,''68'',66) |\n+----------------------------------+\n| MariaDB |\n+----------------------------------+\n\nSELECT CHAR(77,77.3,''77.3'');\n+----------------------+\n| CHAR(77,77.3,''77.3'') |\n+----------------------+\n| MMM |\n+----------------------+\n1 row in set, 1 warning (0.00 sec)\n\nWarning (Code 1292): Truncated incorrect INTEGER value: ''77.3''\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/char-function', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/char-function'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (418, 37, 'CHAR\\_LENGTH', 'Syntax\n------\n\nCHAR_LENGTH(str)\nCHARACTER_LENGTH(str)\n\nDescription\n-----------\n\nReturns the length of the given string argument, measured in characters. A multi-byte character counts as a single character. This means that for a string containing five two-byte characters, LENGTH() (or OCTET_LENGTH() in Oracle mode) returns 10, whereas CHAR_LENGTH() returns 5. If the argument is NULL, it returns NULL.\n\nIf the argument is not a string value, it is converted into a string.\n\nIt is synonymous with the CHARACTER_LENGTH() function.\n\nExamples\n--------\n\nSELECT CHAR_LENGTH(''MariaDB'');\n+------------------------+\n| CHAR_LENGTH(''MariaDB'') |\n+------------------------+\n| 7 |\n+------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/char_length', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/char_length'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (419, 37, 'CHARACTER\\_LENGTH', 'Syntax\n------\n\nCHARACTER_LENGTH(str)\n\nDescription\n-----------\n\nCHARACTER_LENGTH() is a synonym for CHAR_LENGTH().\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/character_length', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/character_length'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (420, 37, 'CHR', 'Syntax\n------\n\nCHR(N)\n\nDescription\n-----------\n\nCHR() interprets each argument N as an integer and returns a VARCHAR(1) string consisting of the character given by the code values of the integer. The character set and collation of the string are set according to the values of the character_set_database and collation_database system variables.\n\nCHR() is similar to the CHAR() function, but only accepts a single argument.\n\nCHR() is available in all sql_modes.\n\nExamples\n--------\n\nSELECT CHR(67);\n+---------+\n| CHR(67) |\n+---------+\n| C |\n+---------+\n\nSELECT CHR(''67'');\n+-----------+\n| CHR(''67'') |\n+-----------+\n| C |\n+-----------+\n\nSELECT CHR(''C'');\n+----------+\n| CHR(''C'') |\n+----------+\n| |\n+----------+\n1 row in set, 1 warning (0.000 sec)\n\nSHOW WARNINGS;\n+---------+------+----------------------------------------+\n| Level | Code | Message |\n+---------+------+----------------------------------------+\n| Warning | 1292 | Truncated incorrect INTEGER value: ''C'' |\n+---------+------+----------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/chr', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/chr'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (421, 37, 'CONCAT', 'Syntax\n------\n\nCONCAT(str1,str2,...)\n\nDescription\n-----------\n\nReturns the string that results from concatenating the arguments. May have one or more arguments. If all arguments are non-binary strings, the result is a non-binary string. If the arguments include any binary strings, the result is a binary string. A numeric argument is converted to its equivalent binary string form; if you want to avoid that, you can use an explicit type cast, as in this example:\n\n``sql\nSELECT CONCAT(CAST(int_col AS CHAR), char_col);\n`\n\nCONCAT() returns NULL if any argument is NULL.\n\nA NULL parameter hides all information contained in other parameters from the result. Sometimes this is not desirable; to avoid this, you can:\n\n Use the CONCAT_WS() function with an empty separator, because that function is NULL-safe.\n Use IFNULL() to turn NULLs into empty strings.\n\nOracle Mode\n\nIn Oracle mode, CONCAT` ignores null.\n\nExamples\n--------\n\nSELECT CONCAT(''Ma'', ''ria'', ''DB'');\n+---------------------------+\n| CONCAT(''Ma'', ''ria'', ''DB'') |\n+---------------------------+\n| MariaDB |\n+---------------------------+\n\nSELECT CONCAT(''Ma'', ''ria'', NULL, ''DB'');\n+---------------------------------+\n| CONCAT(''Ma'', ''ria'', NULL, ''DB'') |\n+---------------------------------+\n| NULL |\n+---------------------------------+\n\nSELECT CONCAT(42.0);\n+--------------+\n| CONCAT(42.0) |\n+--------------+\n| 42.0 |\n+--------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/concat', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/concat'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (422, 37, 'CONCAT\\_WS', 'Syntax\n------\n\nCONCAT_WS(separator,str1,str2,...)\n\nDescription\n-----------\n\nCONCAT_WS() stands for Concatenate With Separator and is a special form of CONCAT(). The first argument is the separator for the rest of the arguments. The separator is added between the strings to be concatenated. The separator can be a string, as can the rest of the arguments.\n\nIf the separator is NULL, the result is NULL; all other NULL values are skipped. This makes CONCAT_WS() suitable when you want to concatenate some values and avoid losing all information if one of them is NULL.\n\nExamples\n--------\n\nSELECT CONCAT_WS('','',''First name'',''Second name'',''Last Name'');\n+-------------------------------------------------------+\n| CONCAT_WS('','',''First name'',''Second name'',''Last Name'') |\n+-------------------------------------------------------+\n| First name,Second name,Last Name |\n+-------------------------------------------------------+\n\nSELECT CONCAT_WS(''-'',''Floor'',NULL,''Room'');\n+------------------------------------+\n| CONCAT_WS(''-'',''Floor'',NULL,''Room'') |\n+------------------------------------+\n| Floor-Room |\n+------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/concat_ws', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/concat_ws'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (423, 37, 'CONVERT', 'Syntax\n------\n\nCONVERT(expr,type), CONVERT(expr USING transcoding_name)\n\nDescription\n-----------\n\nThe CONVERT() and CAST() functions take a value of one type and produce a value of another type.\n\nThe type can be one of the following values:\n\n BINARY\n CHAR\n DATE\n DATETIME\n \\[DECIMAL [(M\\[,D\\])](../../data-types/numeric-data-types/decimal.md)]\n DOUBLE\n FLOAT\n INTEGER\n Short for SIGNED INTEGER\n SIGNED \\[INTEGER]\n UNSIGNED \\[INTEGER]\n TIME\n* VARCHAR (in Oracle mode)\n\nNote that in MariaDB, INT and INTEGER are the same thing.\n\nBINARY produces a string with the BINARY data type. If the optional length is given, BINARY(N) causes the cast to use no more than N bytes of the argument. Values shorter than the given number in bytes are padded with 0x00 bytes to make them equal the length value.\n\nCHAR(N) causes the cast to use no more than the number of characters given in the argument.\n\nThe main difference between the CAST() and CONVERT() is that CONVERT(expr,type) is ODBC syntax while CAST(expr as type) and CONVERT(... USING ...) are SQL92 syntax.\n\nCONVERT() with USING is used to convert data between different character sets. In MariaDB, transcoding names are the same as the corresponding character set names. For example, this statement converts the string ''abc'' in the default character set to the corresponding string in the utf8 character set:\n\n``sql\nSELECT CONVERT(''abc'' USING utf8);\n``\n\nExamples\n--------\n\nSELECT enum_col FROM tbl_name \nORDER BY CAST(enum_col AS CHAR);\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/convert', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/convert'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (424, 37, 'ELT', 'Syntax\n------\n\nELT(N, str1[, str2, str3,...])\n\nDescription\n-----------\n\nTakes a numeric argument and a series of string arguments. Returns the string that corresponds to the given numeric position. For instance, it returns str1 if N is 1, str2 if N is 2, and so on. If the numeric argument is a FLOAT, MariaDB rounds it to the nearest INTEGER. If the numeric argument is less than 1, greater than the total number of arguments, or not a number, ELT() returns NULL. It must have at least two arguments.\n\nIt is complementary to the FIELD() function.\n\nExamples\n--------\n\nSELECT ELT(1, ''ej'', ''Heja'', ''hej'', ''foo'');\n+------------------------------------+\n| ELT(1, ''ej'', ''Heja'', ''hej'', ''foo'') |\n+------------------------------------+\n| ej |\n+------------------------------------+\n\nSELECT ELT(4, ''ej'', ''Heja'', ''hej'', ''foo'');\n+------------------------------------+\n| ELT(4, ''ej'', ''Heja'', ''hej'', ''foo'') |\n+------------------------------------+\n| foo |\n+------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/elt', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/elt'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (425, 37, 'EXPORT\\_SET', 'Syntax\n------\n\nEXPORT_SET(bits, on, off[, separator[, number_of_bits]])\n\nDescription\n-----------\n\nTakes a minimum of three arguments. Returns a string where each bit in the given bits argument is returned, with the string values given for on and off.\n\nBits are examined from right to left, (from low-order to high-order bits). Strings are added to the result from left to right, separated by a separator string (defaults as '',''). You can optionally limit the number of bits the EXPORT_SET() function examines using the number_of_bits option.\n\nIf any of the arguments are set as NULL, the function returns NULL.\n\nExamples\n--------\n\nSELECT EXPORT_SET(5,''Y'',''N'','','',4);\n+-----------------------------+\n| EXPORT_SET(5,''Y'',''N'','','',4) |\n+-----------------------------+\n| Y,N,Y,N |\n+-----------------------------+\n\nSELECT EXPORT_SET(6,''1'',''0'','','',10);\n+------------------------------+\n| EXPORT_SET(6,''1'',''0'','','',10) |\n+------------------------------+\n| 0,1,1,0,0,0,0,0,0,0 |\n+------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/export_set', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/export_set'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (426, 37, 'EXTRACTVALUE', 'Syntax\n------\n\nEXTRACTVALUE(xml_frag, xpath_expr)\n\nDescription\n-----------\n\nThe EXTRACTVALUE() function takes two string arguments: a fragment of XML markup and an XPath expression, (also known as a locator). It returns the text (That is, CDDATA), of the first text node which is a child of the element or elements matching the XPath expression.\n\nIn cases where a valid XPath expression does not match any text nodes in a valid XML fragment, (including the implicit /text() expression), the EXTRACTVALUE() function returns an empty string.\n\nInvalid Arguments\n\nWhen either the XML fragment or the XPath expression is NULL, the EXTRACTVALUE() function returns NULL. When the XML fragment is invalid, it raises a warning Code 1525:\n\n``sql\nWarning (Code 1525): Incorrect XML value: ''parse error at line 1 pos 11: unexpected END-OF-INPUT''\n`\n\nWhen the XPath value is invalid, it generates an Error 1105:\n\n`sql\nERROR 1105 (HY000): XPATH syntax error: '')''\n`\n\nExplicit text() Expressions\n\nThis function is the equivalent of performing a match using the XPath expression after appending /text(). In other words:\n\n`sql\nSELECT\n EXTRACTVALUE(''example'', ''/cases/case'') \n AS ''Base Example'',\n EXTRACTVALUE(''example'', ''/cases/case/text()'') \n AS ''text() Example'';\n+--------------+----------------+\n| Base Example | text() Example |\n+--------------+----------------+\n| example | example |\n+--------------+----------------+\n`\n\nCount Matches\n\nWhen EXTRACTVALUE() returns multiple matches, it returns the content of the first child text node of each matching element, in the matched order, as a single, space-delimited string.\n\nBy design, the EXTRACTVALUE() function makes no distinction between a match on an empty element and no match at all. If you need to determine whether no matching element was found in the XML fragment or if an element was found that contained no child text nodes, use the XPath count() function.\n\nFor instance, when looking for a value that exists, but contains no child text nodes, you would get a count of the number of matching instances:\n\n`sql\nSELECT\n EXTRACTVALUE('''', ''/cases/case'') \n AS ''Empty Example'',\n EXTRACTVALUE('''', ''count(/cases/case)'') \n AS ''count() Example'';\n+---------------+-----------------+\n| Empty Example | count() Example |\n+---------------+-----------------+\n| | 1 |\n+---------------+-----------------+\n`\n\nAlternatively, when looking for a value that doesn''t exist, count() returns 0.\n\n`sql\nSELECT\n EXTRACTVALUE('''', ''/cases/person'') \n AS ''No Match Example'',\n EXTRACTVALUE('''', ''count(/cases/person)'') \n AS ''count() Example'';\n+------------------+-----------------+\n| No Match Example | count() Example |\n+------------------+-----------------+\n| | 0|\n+------------------+-----------------+\n`\n\nMatches\n\nImportant: The EXTRACTVALUE() function only returns CDDATA. It does not return tags that the element might contain or the text that these child elements contain.\n\n`sql\nSELECT \n EXTRACTVALUE(''Personx@example.com'', ''/cases'')\n AS Case;\n+--------+\n| Case |\n+--------+\n| Person |\n+--------+\n`\n\nNote, in the above example, while the XPath expression matches to the parent instance, it does not return the contained ` tag or its content.\n\nExamples\n--------\n\nSELECT\n ExtractValue(''cccddd'', ''/a'') AS val1,\n ExtractValue(''cccddd'', ''/a/b'') AS val2,\n ExtractValue(''cccddd'', ''//b'') AS val3,\n ExtractValue(''cccddd'', ''/b'') AS val4,\n ExtractValue(''cccdddeee'', ''//b'') AS val5;\n+------+------+------+------+---------+\n| val1 | val2 | val3 | val4 | val5 |\n+------+------+------+------+---------+\n| ccc | ddd | ddd | | ddd eee |\n+------+------+------+------+---------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/extractvalue', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/extractvalue'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (427, 37, 'FIELD', 'Syntax\n------\n\nFIELD(pattern, str1[,str2,...])\n\nDescription\n-----------\n\nReturns the index position of the string or number matching the given pattern. Returns 0 in the event that none of the arguments match the pattern. Raises an Error 1582 if not given at least two arguments.\n\nWhen all arguments given to the FIELD() function are strings, they are treated as case-insensitive. When all the arguments are numbers, they are treated as numbers. Otherwise, they are treated as doubles.\n\nIf the given pattern occurs more than once, the FIELD() function only returns the index of the first instance. If the given pattern is NULL, the function returns 0, as a NULL pattern always fails to match.\n\nThis function is complementary to the ELT() function.\n\nExamples\n--------\n\nSELECT FIELD(''ej'', ''Hej'', ''ej'', ''Heja'', ''hej'', ''foo'') \n AS ''Field Results'';\n+---------------+\n| Field Results | \n+---------------+\n| 2 |\n+---------------+\n\nSELECT FIELD(''fo'', ''Hej'', ''ej'', ''Heja'', ''hej'', ''foo'')\n AS ''Field Results'';\n+---------------+\n| Field Results | \n+---------------+\n| 0 |\n+---------------+\n\nSELECT FIELD(1, 2, 3, 4, 5, 1) AS ''Field Results'';\n+---------------+\n| Field Results |\n+---------------+\n| 5 |\n+---------------+\n\nSELECT FIELD(NULL, 2, 3) AS ''Field Results'';\n+---------------+\n| Field Results |\n+---------------+\n| 0 |\n+---------------+\n\nSELECT FIELD(''fail'') AS ''Field Results'';\nError 1582 (42000): Incorrect parameter count in call\nto native function ''field''\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/field', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/field'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (428, 37, 'FIND\\_IN\\_SET', 'Syntax\n------\n\nFIND_IN_SET(pattern, strlist)\n\nDescription\n-----------\n\nReturns the index position where the given pattern occurs in a string list. The first argument is the pattern you want to search for. The second argument is a string containing comma-separated variables. If the second argument is of the SET data-type, the function is optimized to use bit arithmetic.\n\nIf the pattern does not occur in the string list or if the string list is an empty string, the function returns 0. If either argument is NULL, the function returns NULL. The function does not return the correct result if the pattern contains a comma (",") character.\n\nExamples\n--------\n\nSELECT FIND_IN_SET(''b'',''a,b,c,d'') AS "Found Results";\n+---------------+\n| Found Results |\n+---------------+\n| 2 |\n+---------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/find_in_set', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/find_in_set'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (429, 37, 'FORMAT', 'Description\n-----------\n\nFormats the given number for display as a string, adding separators to appropriate position and rounding the results to the given decimal position. For instance, it would format 15233.345 to 15,233.35.\n\nIf the given decimal position is 0, it rounds to return no decimal point or fractional part. You can optionally specify a locale value to format numbers to the pattern appropriate for the given region.\n\nExamples\n--------\n\nSELECT FORMAT(1234567890.09876543210, 4) AS ''Format'';\n+--------------------+\n| Format |\n+--------------------+\n| 1,234,567,890.0988 |\n+--------------------+\n\nSELECT FORMAT(1234567.89, 4) AS ''Format'';\n+----------------+\n| Format |\n+----------------+\n| 1,234,567.8900 |\n+----------------+\n\nSELECT FORMAT(1234567.89, 0) AS ''Format'';\n+-----------+\n| Format |\n+-----------+\n| 1,234,568 |\n+-----------+\n\n-- Format number to German number formatting\nSELECT FORMAT(123456789,2,''de_DE'') AS ''Format'';\n+----------------+\n| Format |\n+----------------+\n| 123.456.789,00 |\n+----------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/format', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/format'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (430, 37, 'FROM\\_BASE64', 'Syntax\n------\n\nFROM_BASE64(str)\n\nDescription\n-----------\n\nDecodes the given base-64 encode string, returning the result as a binary string. Returns NULL if the given string is NULL or if it''s invalid.\n\nIt is the reverse of the TO_BASE64 function.\n\nThere are numerous methods to base-64 encode a string. MariaDB uses the following:\n\n It encodes alphabet value 64 as ''+''.\n It encodes alphabet value 63 as ''/''.\n It codes output in groups of four printable characters. Each three byte of data encoded uses four characters. If the final group is incomplete, it pads the difference with the ''='' character.\n It divides long output, adding a new line very 76 characters.\n* In decoding, it recognizes and ignores newlines, carriage returns, tabs and space whitespace characters.\n\n``sql\nSELECT TO_BASE64(''Maria'') AS ''Input'';\n+-----------+\n| Input |\n+-----------+\n| TWFyaWE= |\n+-----------+\n\nSELECT FROM_BASE64(''TWFyaWE='') AS ''Output'';\n+--------+\n| Output |\n+--------+\n| Maria |\n+--------+\n``\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/from_base64', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/from_base64'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (431, 37, 'HEX', 'Description\n-----------\n\nIf N_or_S is a number, returns a string representation of the hexadecimal value of N, where N is a longlong (BIGINT) number. This is equivalent to CONV(N,10,16).\n\nIf N_or_S is a string, returns a hexadecimal string representation ofN_or_S where each byte of each character in N_or_S is converted to two hexadecimal digits. If N_or_S is NULL, returns NULL. The inverse of this operation is performed by the UNHEX()\\\nfunction.\n\nHEX() with an INET6 argument returns a hexadecimal representation of the underlying 16-byte binary string.\n\nExamples\n--------\n\nSELECT HEX(255);\n+----------+\n| HEX(255) |\n+----------+\n| FF |\n+----------+\n\nSELECT 0x4D617269614442;\n+------------------+\n| 0x4D617269614442 |\n+------------------+\n| MariaDB |\n+------------------+\n\nSELECT HEX(''MariaDB'');\n+----------------+\n| HEX(''MariaDB'') |\n+----------------+\n| 4D617269614442 |\n+----------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/hex', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/hex'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (432, 37, 'INSERT Function', 'Syntax\n------\n\nINSERT(str,pos,len,newstr)\n\nDescription\n-----------\n\nReturns the string str, with the substring beginning at position pos and len characters long replaced by the string newstr. Returns the original string if pos is not within the length of the string.\\\nReplaces the rest of the string from position pos if len is not within the length of the rest of the string. Returns NULL if any argument is NULL.\n\nExamples\n--------\n\nSELECT INSERT(''Quadratic'', 3, 4, ''What'');\n+-----------------------------------+\n| INSERT(''Quadratic'', 3, 4, ''What'') |\n+-----------------------------------+\n| QuWhattic |\n+-----------------------------------+\n\nSELECT INSERT(''Quadratic'', -1, 4, ''What'');\n+------------------------------------+\n| INSERT(''Quadratic'', -1, 4, ''What'') |\n+------------------------------------+\n| Quadratic |\n+------------------------------------+\n\nSELECT INSERT(''Quadratic'', 3, 100, ''What'');\n+-------------------------------------+\n| INSERT(''Quadratic'', 3, 100, ''What'') |\n+-------------------------------------+\n| QuWhat |\n+-------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/insert-function', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/insert-function'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (433, 37, 'INSTR', 'Syntax\n------\n\nINSTR(str,substr)\n\nDescription\n-----------\n\nReturns the position of the first occurrence of substring _substr_ in string _str_. This is the same as the two-argument form of LOCATE(), except that the order of the arguments is reversed.\n\nINSTR() performs a case-insensitive search.\n\nIf any argument is NULL, returns NULL.\n\nExamples\n--------\n\nSELECT INSTR(''foobarbar'', ''bar'');\n+---------------------------+\n| INSTR(''foobarbar'', ''bar'') |\n+---------------------------+\n| 4 |\n+---------------------------+\n\nSELECT INSTR(''My'', ''Maria'');\n+----------------------+\n| INSTR(''My'', ''Maria'') |\n+----------------------+\n| 0 |\n+----------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/instr', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/instr'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (434, 37, 'LCASE', 'Syntax\n------\n\nLCASE(str)\n\nDescription\n-----------\n\nLCASE() is a synonym for LOWER().\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/lcase', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/lcase'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (435, 37, 'LEFT', 'Syntax\n------\n\nLEFT(str,len)\n\nDescription\n-----------\n\nReturns the leftmost len characters from the string str, or NULL if any argument is NULL.\n\nExamples\n--------\n\nSELECT LEFT(''MariaDB'', 5);\n+--------------------+\n| LEFT(''MariaDB'', 5) |\n+--------------------+\n| Maria |\n+--------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/left', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/left'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (436, 37, 'LENGTH', 'Syntax\n------\n\nLENGTH(str)\n\nDescription\n-----------\n\nReturns the length of the string str.\n\nIn the default mode, when Oracle mode is not set, the length is measured in bytes. In this case, a multi-byte character counts as multiple bytes. LENGTH() returns the length in bytes, whereas CHAR_LENGTH() returns the number of characters. This means that, for a string containing five two-byte characters, LENGTH() returns 10, whereas CHAR_LENGTH() returns 5.\nWhen running Oracle mode, the length is measured in characters, and LENGTH is a synonym for CHAR_LENGTH().\n\nIf str is not a string value, it is converted into a string. If str is NULL, the function returns NULL.\n\nExamples\n--------\n\nSELECT LENGTH(''MariaDB'');\n+-------------------+\n| LENGTH(''MariaDB'') |\n+-------------------+\n| 7 |\n+-------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/length', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/length'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (437, 37, 'LENGTHB', 'Syntax\n------\n\nLENGTHB(str)\n\nDescription\n-----------\n\nLENGTHB() returns the length of the given string, in bytes. When Oracle mode is not set, this is a synonym for LENGTH.\n\nA multi-byte character counts as multiple bytes. This means that for a string containing five two-byte characters, LENGTHB() returns 10, whereas CHAR_LENGTH() returns 5.\n\nIf str is not a string value, it is converted into a string. If str is NULL, the function returns NULL.\n\nExamples\n--------\n\nSELECT CHAR_LENGTH(''π''), LENGTH(''π''), LENGTHB(''π''), OCTET_LENGTH(''π'');\n+-------------------+--------------+---------------+--------------------+\n| CHAR_LENGTH(''π'') | LENGTH(''π'') | LENGTHB(''π'') | OCTET_LENGTH(''π'') |\n+-------------------+--------------+---------------+--------------------+\n| 1 | 2 | 2 | 2 |\n+-------------------+--------------+---------------+--------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/lengthb', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/lengthb'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (438, 37, 'LIKE', 'Description\n-----------\n\nTests whether _expr_ matches the pattern _pat_. Returns either 1 (TRUE) or 0 (FALSE).\\\nBoth _expr_ and _pat_ may be any valid expression and are evaluated to strings.\\\nPatterns may use the following wildcard characters:\n\n % matches any number of characters, including zero.\n _ matches any single character.\n\nUse NOT LIKE to test if a string does not match a pattern. This is equivalent to using\\\nthe NOT operator on the entire LIKE expression.\n\nIf either the expression or the pattern is NULL, the result is NULL.\n\nLIKE performs case-insensitive substring matches if the collation for the expression and pattern is case-insensitive. For case-sensitive matches, declare either argument to use a binary collation using collate, or coerce either of them to a BINARY string using CAST. Use SHOW COLLATION to get a list of\\\navailable collations. Collations ending in _bin are case-sensitive.\n\nNumeric arguments are coerced to binary strings.\n\nThe _ wildcard matches a single character, not byte. It will only match a multi-byte character\\\nif it is valid in the expression''s character set. For example, _ will match _utf8"€", but it\\\nwill not match _latin1"€" because the Euro sign is not a valid latin1 character. If necessary,\\\nuse CONVERT to use the expression in a different character set.\n\nIf you need to match the characters _ or %, you must escape them. By default, you can prefix the wildcard characters the backslash character \\ to escape them. The backslash is used both to encode special characters like newlines when a string is parsed as well as to escape wildcards in a pattern after parsing. Thus, to match an actual backslash, you sometimes need to double-escape it as "\\\\\\\\".\n\nTo avoid difficulties with the backslash character, you can change the wildcard escape character using ESCAPE in a LIKE expression. The argument to ESCAPE must be a single-character string.\n\nExamples\n--------\n\nCREATE TABLE t1 (d VARCHAR(16));\nINSERT INTO t1 VALUES \n ("Monday"), ("Tuesday"), ("Wednesday"), \n ("Thursday"), ("Friday"), ("Saturday"), ("Sunday");\nSELECT * FROM t1 WHERE d LIKE "T%";\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/like', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/like'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (439, 37, 'LOAD\\_FILE', 'Syntax\n------\n\nLOAD_FILE(file_name)\n\nDescription\n-----------\n\nReads the file and returns the file contents as a string. To use this function, the file must be located on the server host, you must specify the full path name to the file, and you must have the FILE privilege. The file must be readable by all and it must be less than the size, in bytes, of the max_allowed_packet system variable. If the secure_file_priv system variable is set to a non-empty directory name, the file to be loaded must be located in that directory.\n\nIf the file does not exist or cannot be read because one of the preceding conditions is not satisfied, the function returns NULL.\n\nThe character_set_filesystem system variable has controlled interpretation of file names that are given as literal strings.\n\nStatements using the LOAD_FILE() function are not safe for statement based replication. This is because the slave will execute the LOAD_FILE() command itself. If the file doesn''t exist on the slave, the function will return NULL.\n\nExamples\n--------\n\nUPDATE t SET blob_col=LOAD_FILE(''/tmp/picture'') WHERE id=1;\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/load_file', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/load_file'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (440, 37, 'LOCATE', 'Syntax\n------\n\nLOCATE(substr,str), LOCATE(substr,str,pos)\n\nDescription\n-----------\n\nThe first syntax returns the position of the first occurrence of substring substr in string str. The second syntax returns the position of the first occurrence of substring substr in string str, starting at position pos. Returns 0 if substr is not in str.\n\nLOCATE() performs a case-insensitive search.\n\nIf any argument is NULL, returns NULL.\n\nINSTR() is the same as the two-argument form of LOCATE(), except that the order of the arguments is reversed.\n\nExamples\n--------\n\nSELECT LOCATE(''bar'', ''foobarbar'');\n+----------------------------+\n| LOCATE(''bar'', ''foobarbar'') |\n+----------------------------+\n| 4 |\n+----------------------------+\n\nSELECT LOCATE(''My'', ''Maria'');\n+-----------------------+\n| LOCATE(''My'', ''Maria'') |\n+-----------------------+\n| 0 |\n+-----------------------+\n\nSELECT LOCATE(''bar'', ''foobarbar'', 5);\n+-------------------------------+\n| LOCATE(''bar'', ''foobarbar'', 5) |\n+-------------------------------+\n| 7 |\n+-------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/locate', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/locate'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (441, 37, 'LOWER', 'Syntax\n------\n\nLOWER(str)\nLCASE(str)\n\nDescription\n-----------\n\nReturns the string str with all characters changed to lowercase according to the current character set mapping. The default is latin1 (cp1252 West European).\n\nLCASE is a synonym for LOWER .\n\nExamples\n--------\n\nSELECT LOWER(''QUADRATICALLY'');\n+------------------------+\n| LOWER(''QUADRATICALLY'') |\n+------------------------+\n| quadratically |\n+------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/lower', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/lower'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (442, 37, 'LPAD', 'Syntax\n------\n\nLPAD(str, len [,padstr])\n\nDescription\n-----------\n\nReturns the string str, left-padded with the string padstr to a length of len characters. If str is longer than len, the return value is shortened to len characters. If padstr is omitted, the LPAD function pads spaces.\n\nReturns NULL if given a NULL argument. If the result is empty (zero length), returns either an empty string or with SQL_MODE=Oracle, NULL.\n\nThe Oracle mode version of the function can be accessed outside of Oracle mode by using LPAD_ORACLE as the function name.\n\nExamples\n--------\n\nSELECT LPAD(''hello'',10,''.'');\n+----------------------+\n| LPAD(''hello'',10,''.'') |\n+----------------------+\n| .....hello |\n+----------------------+\n\nSELECT LPAD(''hello'',2,''.'');\n+---------------------+\n| LPAD(''hello'',2,''.'') |\n+---------------------+\n| he |\n+---------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/lpad', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/lpad'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (443, 37, 'LTRIM', 'Syntax\n------\n\nLTRIM(str)\n\nDescription\n-----------\n\nReturns the string str with leading space characters removed.\n\nReturns NULL if given a NULL argument. If the result is empty, returns either an empty string, or with SQL_MODE=Oracle, NULL.\n\nThe Oracle mode version of the function can be accessed outside of Oracle mode by using LTRIM_ORACLE as the function name.\n\nExamples\n--------\n\nSELECT QUOTE(LTRIM('' MariaDB ''));\n+-------------------------------+\n| QUOTE(LTRIM('' MariaDB '')) |\n+-------------------------------+\n| ''MariaDB '' |\n+-------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/ltrim', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/ltrim'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (444, 37, 'MAKE\\_SET', 'Syntax\n------\n\nMAKE_SET(bits,str1,str2,...)\n\nDescription\n-----------\n\nReturns a set value (a string containing substrings separated by "," characters) consisting of the strings that have the corresponding bit in bits set. _str1_ corresponds to bit 0, _str2_ to bit 1, and so on. NULL\\\nvalues in _str1_, _str2_, ... are not appended to the result.\n\nExamples\n--------\n\nSELECT MAKE_SET(1,''a'',''b'',''c'');\n+-------------------------+\n| MAKE_SET(1,''a'',''b'',''c'') |\n+-------------------------+\n| a |\n+-------------------------+\n\nSELECT MAKE_SET(1 | 4,''hello'',''nice'',''world'');\n+----------------------------------------+\n| MAKE_SET(1 | 4,''hello'',''nice'',''world'') |\n+----------------------------------------+\n| hello,world |\n+----------------------------------------+\n\nSELECT MAKE_SET(1 | 4,''hello'',''nice'',NULL,''world'');\n+---------------------------------------------+\n| MAKE_SET(1 | 4,''hello'',''nice'',NULL,''world'') |\n+---------------------------------------------+\n| hello |\n+---------------------------------------------+\n\nSELECT QUOTE(MAKE_SET(0,''a'',''b'',''c''));\n+--------------------------------+\n| QUOTE(MAKE_SET(0,''a'',''b'',''c'')) |\n+--------------------------------+\n| '''' |\n+--------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/make_set', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/make_set'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (445, 37, 'MATCH AGAINST', 'Syntax\n------\n\nMATCH (col1,col2,...) AGAINST (expr [search_modifier])\n\nDescription\n-----------\n\nA special construct used to perform a fulltext search on a fulltext index.\n\nSee Fulltext Index Overview for a full description, and Full-text Indexes for more articles on the topic.\n\nExamples\n--------\n\nCREATE TABLE ft_myisam(copy TEXT,FULLTEXT(copy)) ENGINE=MyISAM;\n\nINSERT INTO ft_myisam(copy) VALUES (''Once upon a time''), (''There was a wicked witch''), \n (''Who ate everybody up'');\n\nSELECT * FROM ft_myisam WHERE MATCH(copy) AGAINST(''wicked'');\n+--------------------------+\n| copy |\n+--------------------------+\n| There was a wicked witch |\n+--------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/match-against', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/match-against'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (446, 37, 'MID', 'Syntax\n------\n\nMID(str,pos,len)\n\nDescription\n-----------\n\nMID(str,pos,len) is a synonym for SUBSTRING(str,pos,len)!\n\nExamples\n--------\n\nSELECT MID(''abcd'',4,1);\n+-----------------+\n| MID(''abcd'',4,1) |\n+-----------------+\n| d |\n+-----------------+\n\nSELECT MID(''abcd'',2,2);\n+-----------------+\n| MID(''abcd'',2,2) |\n+-----------------+\n| bc |\n+-----------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/mid', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/mid'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (447, 37, 'NATURAL\\_SORT\\_KEY', 'Syntax\n------\n\nNATURAL_SORT_KEY(str)\n\nDescription\n-----------\n\nThe NATURAL_SORT_KEY function is used for sorting that is closer to natural sorting. Strings are sorted in alphabetical order, while numbers are treated in a way such that, for example, 10 is greater than 2, whereas in other forms of sorting, 2 would be greater than 10, just like z is greater than ya.\n\nThere are multiple natural sort implementations, differing in the way they handle leading zeroes, fractions, i18n, negatives, decimals and so on.\n\nMariaDB''s implementation ignores leading zeroes when performing the sort.\n\nYou can use also use NATURAL_SORT_KEY with generated columns. The value is not stored permanently in the table. When using a generated column, the virtual column must be longer than the base column to cater for embedded numbers in the string and MDEV-24582.\n\nExamples\n--------\n\nCREATE TABLE t1 (c TEXT);\n\nINSERT INTO t1 VALUES (''b1''),(''a2''),(''a11''),(''a1'');\n\nSELECT c FROM t1;\n+------+\n| c |\n+------+\n| b1 |\n| a2 |\n| a11 |\n| a1 |\n+------+\n\nSELECT c FROM t1 ORDER BY c;\n+------+\n| c |\n+------+\n| a1 |\n| a11 |\n| a2 |\n| b1 |\n+------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/natural_sort_key', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/natural_sort_key'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (448, 37, 'NOT LIKE', 'Syntax\n------\n\nexpr NOT LIKE pat [ESCAPE ''escape_char'']\n\nDescription\n-----------\n\nThis is the same as [NOT (expr LIKE pat \\[ESCAPE ''escape_char''\\])](../../sql-structure/operators/logical-operators/not.md).\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/not-like', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/not-like'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (449, 37, 'NOT REGEXP', 'Syntax\n------\n\nexpr NOT REGEXP pat, expr NOT RLIKE pat\n\nDescription\n-----------\n\nThis is the same as NOT (expr REGEXP pat).\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/not-regexp', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/not-regexp'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (450, 37, 'OCTET\\_LENGTH', 'Description\n-----------\n\nOCTET_LENGTH() returns the length of the given string, in octets (bytes). This is a synonym for LENGTHB(), and, when Oracle mode is not set, a synonym for LENGTH().\n\nA multi-byte character counts as multiple bytes. This means that for a string containing five two-byte characters, OCTET_LENGTH() returns 10, whereas CHAR_LENGTH() returns 5.\n\nIf str is not a string value, it is converted into a string. If str is NULL, the function returns NULL.\n\nExamples\n--------\n\nSELECT CHAR_LENGTH(''π''), LENGTH(''π''), LENGTHB(''π''), OCTET_LENGTH(''π'');\n+-------------------+--------------+---------------+--------------------+\n| CHAR_LENGTH(''π'') | LENGTH(''π'') | LENGTHB(''π'') | OCTET_LENGTH(''π'') |\n+-------------------+--------------+---------------+--------------------+\n| 1 | 2 | 2 | 2 |\n+-------------------+--------------+---------------+--------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/octet_length', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/octet_length'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (451, 37, 'ORD', 'Syntax\n------\n\nORD(str)\n\nDescription\n-----------\n\nIf the leftmost character of the string str is a multi-byte character, returns the code for that character, calculated from the numeric values of its constituent bytes using this formula:\n\n``sql\n(1st byte code)\n+ (2nd byte code x 256)\n+ (3rd byte code x 256 x 256) ...\n`\n\nIf the leftmost character is not a multi-byte character, ORD()` returns the same value as the ASCII() function.\n\nExamples\n--------\n\nSELECT ORD(''2'');\n+----------+\n| ORD(''2'') |\n+----------+\n| 50 |\n+----------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/ord', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/ord'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (452, 37, 'POSITION', 'Syntax\n------\n\nPOSITION(substr IN str)\n\nDescription\n-----------\n\nPOSITION(substr IN str) is a synonym for LOCATE(substr,str).\n\nThe function is part of ODBC 3.0.\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/position', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/position'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (453, 37, 'QUOTE', 'Syntax\n------\n\nQUOTE(str)\n\nDescription\n-----------\n\nQuotes a string to produce a result that can be used as a properly escaped data value in an SQL statement. The string is returned enclosed by single quotes and with each instance of single quote ("''"), backslash ("\\"),ASCII NUL, and Control-Z preceded by a backslash. If the argument is NULL, the return value is the word "NULL" without enclosing single quotes.\n\nExamples\n--------\n\nSELECT QUOTE("Don''t!");\n+-----------------+\n| QUOTE("Don''t!") |\n+-----------------+\n| ''Don\\''t!'' |\n+-----------------+\n\nSELECT QUOTE(NULL); \n+-------------+\n| QUOTE(NULL) |\n+-------------+\n| NULL |\n+-------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/quote', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/quote'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (454, 37, 'PCRE - Perl Compatible Regular Expressions', 'Description\n-----------\n\nPCRE Versions\n\n| PCRE Version | Introduced | Maturity |\n| ------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- |\n| PCRE2 10.34 | MariaDB 10.5.1 | Stable |\n| PCRE 8.43 | MariaDB 10.1.39 | Stable |\n| PCRE 8.42 | MariaDB 10.2.15, MariaDB 10.1.33, MariaDB 10.0.35 | Stable |\n| PCRE 8.41 | MariaDB 10.2.8, MariaDB 10.1.26, MariaDB 10.0.32 | Stable |\n| PCRE 8.40 | MariaDB 10.2.5, MariaDB 10.1.22, MariaDB 10.0.30 | Stable |\n| PCRE 8.39 | MariaDB 10.1.15, MariaDB 10.0.26 | Stable |\n| PCRE 8.38 | MariaDB 10.1.10, MariaDB 10.0.23 | Stable |\n| PCRE 8.37 | MariaDB 10.1.5, MariaDB 10.0.18 | Stable |\n| PCRE 8.36 | MariaDB 10.1.2, MariaDB 10.0.15 | Stable |\n| PCRE 8.35 | MariaDB 10.1.0, MariaDB 10.0.12 | Stable |\n| PCRE 8.34 | MariaDB 10.0.8 | Stable |\n\nPCRE Enhancements\n\nMariaDB uses the PCRE library, which significantly improves the power of the REGEXP/RLIKE operator.\n\nThe switch to PCRE added a number of features, including recursive patterns, named capture, look-ahead and look-behind assertions, non-capturing groups, non-greedy quantifiers, Unicode character properties, extended syntax for characters and character classes, multi-line matching, and many other.\n\nThese functions work with regular expressions: REGEXP_REPLACE(), REGEXP_INSTR(), and REGEXP_SUBSTR().\n\nAlso, REGEXP/RLIKE, and the new functions, work correctly with all multi-byte character sets supported by MariaDB, including East-Asian character sets (big5, gb2313, gbk, eucjp, eucjpms, cp932, ujis, euckr), and Unicode character sets (utf8, utf8mb4, ucs2, utf16, utf16le, utf32).\n\nNew Regular Expression Functions\n\n REGEXP_REPLACE(subject, pattern, replace) - Replaces all occurrences of a pattern.\n REGEXP_INSTR(subject, pattern) - Position of the first appearance of a regex.\n REGEXP_SUBSTR(subject,pattern) - Returns the matching part of a string.\n\nSee the individual articles for more details and examples.\n\nPCRE Syntax\n\nIn most cases PCRE is backward compatible with the old POSIX 1003.2 compliant regexp library (see Regular Expressions Overview), so you won''t need to change your applications that use SQL queries with the REGEXP/RLIKE predicate.\n\nThis section briefly describes the most important extended PCRE features. For more details, please refer to the documentation on the PCRE site, or to the documentation which is bundled in the /pcre/doc/html/ directory of a MariaDB sources distribution. The pages pcresyntax.html and pcrepattern.html should be a good start. Regular-Expressions.Info is another good resource to learn about PCRE and regular expressions generally.\n\nSpecial Characters\n\nPCRE supports the following escape sequences to match special characters:\n\n| Sequence | Description |\n| --------- | ------------------------------------------- |\n| \\a | 0x07 (BEL) |\n| \\cx | "control-x", where x is any ASCII character |\n| \\e | 0x1B (escape) |\n| \\f | 0x0C (form feed) |\n| | 0x0A (newline) |\n| | 0x0D (carriage return) |\n| | 0x09 (TAB) |\n| \\ddd | character with octal code ddd |\n| \\xhh | character with hex code hh |\n| \\x{hhh..} | character with hex code hhh.. |\n\nNote, the backslash characters (here, and in all examples in the sections below) must be escaped with another backslash, unless you''re using the SQL_MODE NO_BACKSLASH_ESCAPES.\n\nThis example tests if a character has hex code 0x61:\n\n``sql\nSELECT ''a'' RLIKE ''\\\\x{61}'';\n-> 1\n`\n\nCharacter Classes\n\nPCRE supports the standard POSIX character classes such as alnum, alpha, blank, cntrl, digit, graph, lower, print, punct, space, upper, xdigit, with the following additional classes:\n\n| Class | Description |\n| ----- | ---------------------------------------------------------- |\n| ascii | any ASCII character (0x00..0x7F) |\n| word | any "word" character (a letter, a digit, or an underscore) |\n\nThis example checks if the string consists of ASCII characters only:\n\n`\nSELECT ''abc'' RLIKE ''^[[:ascii:]]+$'';\n-> 1\n`\n\nGeneric Character Types\n\nGeneric character types complement the POSIX character classes and serve to simplify writing patterns:\n\n| Class | Description |\n| ----- | ---------------------------------------------------------- |\n| \\d | a decimal digit (same as \\[:digit:]) |\n| \\D | a character that is not a decimal digit |\n| \\h | a horizontal white space character |\n| \\H | a character that is not a horizontal white space character |\n| | a character that is not a new line |\n| | a newline sequence |\n| \\s | a white space character |\n| \\S | a character that is not a white space character |\n| \\v | a vertical white space character |\n| \\V | a character that is not a vertical white space character |\n| \\w | a "word" character (same as \\[:word:]) |\n| \\W | a "non-word" character |\n\nThis example checks if the string consists of "word" characters only:\n\n`sql\nSELECT ''abc'' RLIKE ''^\\\\w+$'';\n-> 1\n`\n\nUnicode Character Properties\n\n\\p{xx} is a character with the xx property, and \\P{xx} is a character without the xx property.\n\nThe property names represented by xx above are limited to the Unicode script names, the general category properties, and "Any", which matches any character (including newline). Those that are not part of an identified script are lumped together as "Common".\n\nGeneral Category Properties For \\p and \\P\n\n| Property | Description |\n| -------- | --------------------- |\n| C | Other |\n| Cc | Control |\n| Cf | Format |\n| Cn | Unassigned |\n| Co | Private use |\n| Cs | Surrogate |\n| L | Letter |\n| Ll | Lower case letter |\n| Lm | Modifier letter |\n| Lo | Other letter |\n| Lt | Title case letter |\n| Lu | Upper case letter |\n| L& | Ll, Lu, or Lt |\n| M | Mark |\n| Mc | Spacing mark |\n| Me | Enclosing mark |\n| Mn | Non-spacing mark |\n| N | Number |\n| Nd | Decimal number |\n| Nl | Letter number |\n| No | Other number |\n| P | Punctuation |\n| Pc | Connector punctuation |\n| Pd | Dash punctuation |\n| Pe | Close punctuation |\n| Pf | Final punctuation |\n| Pi | Initial punctuation |\n| Po | Other punctuation |\n| Ps | Open punctuation |\n| S | Symbol |\n| Sc | Currency symbol |\n| Sk | Modifier symbol |\n| Sm | Mathematical symbol |\n| So | Other symbol |\n| Z | Separator |\n| Zl | Line separator |\n| Zp | Paragraph separator |\n| Zs | Space separator |\n\nThis example checks if the string consists only of characters with property N (number):\n\n`sql\nSELECT ''1¼①'' RLIKE ''^\\\\p{N}+$'';\n-> 1\n`\n\nSpecial Category Properties For \\p and \\P\n\n| Property | Description |\n| -------- | ----------------------------------------------------------------- |\n| Xan | Alphanumeric: union of properties L and N |\n| Xps | POSIX space: property Z or tab, NL, VT, FF, CR |\n| Xsp | Perl space: property Z or tab, NL, FF, CR |\n| Xuc | A character than can be represented by a Universal Character Name |\n| Xwd | Perl word: property Xan or underscore |\n\nThe property Xuc matches any character that can be represented by a Universal Character Name (in C++ and other programming languages). These include $, @, \\\\\\, and all characters with Unicode code points greater than U+00A0, excluding the surrogates U+D800..U+DFFF.\n\nScript Names For \\p and \\P\n\nArabic, Armenian, Avestan, Balinese, Bamum, Batak, Bengali, Bopomofo, Brahmi, Braille, Buginese, Buhid, Canadian_Aboriginal, Carian, Chakma, Cham, Cherokee, Common, Coptic, Cuneiform, Cypriot, Cyrillic, Deseret, Devanagari, Egyptian_Hieroglyphs, Ethiopic, Georgian, Glagolitic, Gothic, Greek, Gujarati, Gurmukhi, Han, Hangul, Hanunoo, Hebrew, Hiragana, Imperial_Aramaic, Inherited, Inscriptional_Pahlavi, Inscriptional_Parthian, Javanese, Kaithi, Kannada, Katakana, Kayah_Li, Kharoshthi, Khmer, Lao, Latin, Lepcha, Limbu, Linear_B, Lisu, Lycian, Lydian, Malayalam, Mandaic, Meetei_Mayek, Meroitic_Cursive, Meroitic_Hieroglyphs, Miao, Mongolian, Myanmar, New_Tai_Lue, Nko, Ogham, Old_Italic, Old_Persian, Old_South_Arabian, Old_Turkic, Ol_Chiki, Oriya, Osmanya, Phags_Pa, Phoenician, Rejang, Runic, Samaritan, Saurashtra, Sharada, Shavian, Sinhala, Sora_Sompeng, Sundanese, Syloti_Nagri, Syriac, Tagalog, Tagbanwa, Tai_Le, Tai_Tham, Tai_Viet, Takri, Tamil, Telugu, Thaana, Thai, Tibetan, Tifinagh, Ugaritic, Vai, Yi.\n\nThis example checks if the string consists only of Greek characters:\n\n``sql\nSELECT ''ΣΦΩ'' RLIKE ''^\\\\p{Greek}+$'';\n-> 1\n`\n\nExtended Unicode Grapheme Sequence\n\nThe \\X escape sequence matches a character sequence that makes an "extended grapheme cluster", i.e. a composite character that consists of multiple Unicode code points.\n\nOne of the examples of a composite character can be a letter followed by non-spacing accent marks. This example demonstrates that U+0045 LATIN CAPITAL LETTER E followed by U+0302 COMBINING CIRCUMFLEX ACCENT followed by U+0323 COMBINING DOT BELOW together form an extended grapheme cluster:\n\n`sql\nSELECT _ucs2 0x004503020323 RLIKE ''^\\\\X$'';\n-> 1\n`\n\nSee the PCRE documentation for the other types of extended grapheme clusters.\n\nSimple Assertions\n\nAn assertion specifies a certain condition that must match at a particular point, but without consuming characters from the subject string. In addition to the standard POSIX simple assertions ^ (that matches at the beginning of a line) and $ (that matches at the end of a line), PCRE supports a number of other assertions:\n\n| Assertion | Description |\n| --------- | ------------------------------------------------------------------------------------------ |\n| \\b | matches at a word boundary |\n| \\B | matches when not at a word boundary |\n| \\A | matches at the start of the subject |\n| \\Z | matches at the end of the subject, also matches before a newline at the end of the subject |\n| \\z | matches only at the end of the subject |\n| \\G | matches at the first matching position in the subject |\n\nThis example cuts a word that consists only of 3 characters from a string:\n\n`sql\nSELECT REGEXP_SUBSTR(''---abcd---xyz---'', ''\\\\b\\\\w{3}\\\\b'');\n-> xyz\n`\n\nNotice that the two \\b assertions checked the word boundaries but did not get into the matching pattern.\n\nThe \\b assertions work well in the beginning and the end of the subject string:\n\n`sql\nSELECT REGEXP_SUBSTR(''xyz'', ''\\\\b\\\\w{3}\\\\b'');\n-> xyz\n`\n\nBy default, the ^ and $ assertions have the same meaning with \\A, \\Z, and \\z. However, the meanings of ^ and $ can change in multiline mode (see below). By contrast, the meanings of \\A, \\Z, and \\z are always the same; they are independent of the multiline mode.\n\nOption Setting\n\nA number of options that control the default match behavior can be changed within the pattern by a sequence of option letters enclosed between (? and ).\n\n| Option | Description |\n| ------- | ------------------------------------------------------------------------ |\n| (?i) | case insensitive match |\n| (?m) | multiline mode |\n| (?s) | dotall mode (dot matches newline characters) |\n| (?x) | extended (ignore white space) |\n| (?U) | ungreedy (lazy) ma\n\n[Truncated — full content at mariadb.com/docs]', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/regular-expressions-functions/pcre'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (455, 37, 'REGEXP', 'Syntax\n------\n\nexpr REGEXP pat, expr RLIKE pat\n\nDescription\n-----------\n\nPerforms a pattern match of a string expression expr against a patternpat. The pattern can be an extended regular expression. See Regular Expressions Overview for details on the syntax for\\\nregular expressions (see also PCRE Regular Expressions).\n\nReturns 1 if expr matches pat or 0 if it doesn''t match. If either expr or pat are NULL, the result is NULL.\n\nThe negative form NOT REGEXP also exists, as an alias for NOT (string REGEXP pattern). RLIKE and NOT RLIKE are synonyms for REGEXP and NOT REGEXP, originally provided for mSQL compatibility.\n\nThe pattern need not be a literal string. For example, it can be specified as a string expression or table column.\n\nNote: Because MariaDB uses the C escape syntax in strings (for example, "\\n" to represent the newline character), you must double any "" that you use in your REGEXP strings.\n\nREGEXP is not case sensitive, except when used with binary strings.\n\nThe default_regex_flags variable addresses the remaining compatibilities between PCRE and the old regex library.\n\nExamples\n--------\n\nSELECT ''Monty!'' REGEXP ''m%y%%'';\n+-------------------------+\n| ''Monty!'' REGEXP ''m%y%%'' |\n+-------------------------+\n| 0 |\n+-------------------------+\n\nSELECT ''Monty!'' REGEXP ''.'';\n+----------------------+\n| ''Monty!'' REGEXP ''.'' |\n+----------------------+\n| 1 |\n+----------------------+\n\nSELECT ''new\\nline'' REGEXP ''new\\\\.\\\\line'';\n+---------------------------------------+\n| ''new\\nline'' REGEXP ''new\\\\.\\\\line'' |\n+---------------------------------------+\n| 1 |\n+---------------------------------------+\n\nSELECT ''a'' REGEXP ''A'', ''a'' REGEXP BINARY ''A'';\n+----------------+-----------------------+\n| ''a'' REGEXP ''A'' | ''a'' REGEXP BINARY ''A'' |\n+----------------+-----------------------+\n| 1 | 0 |\n+----------------+-----------------------+\n\nSELECT ''a'' REGEXP ''^[a-d]'';\n+---------------------+\n| ''a'' REGEXP ''^[a-d]'' |\n+---------------------+\n| 1 |\n+---------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/regular-expressions-functions/regexp', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/regular-expressions-functions/regexp'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (456, 37, 'REGEXP\\_INSTR', 'Description\n-----------\n\nSyntax\n\n``sql\nREGEXP_INSTR(subject, pattern)\n`\n\nReturns the position of the first occurrence of the regular expression pattern in the string subject, or 0 if pattern was not found.\n\nThe positions start with 1 and are measured in characters (i.e. not in bytes), which is important for multi-byte character sets. You can cast a multi-byte character set to BINARY to get offsets in bytes.\n\nThe function follows the case sensitivity rules of the effective collation. Matching is performed case insensitively for case insensitive collations, and case sensitively for case sensitive collations and for binary data.\n\nThe collation case sensitivity can be overwritten using the (?i) and (?-i) PCRE flags.\n\nMariaDB uses the PCRE regular expression library for enhanced regular expression performance, and REGEXP_INSTR` was introduced as part of this enhancement.\n\nExamples\n--------\n\nSELECT REGEXP_INSTR(''abc'',''b'');\n-> 2\n\nSELECT REGEXP_INSTR(''abc'',''x'');\n-> 0\n\nSELECT REGEXP_INSTR(''BJÖRN'',''N'');\n-> 5\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/regular-expressions-functions/regexp_instr', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/regular-expressions-functions/regexp_instr'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (457, 37, 'REGEXP\\_REPLACE', 'Syntax\n------\n\nREGEXP_REPLACE(subject, pattern, replace)\n\nDescription\n-----------\n\nREGEXP_REPLACE returns the string subject with all occurrences of the regular expression pattern replaced by the string replace. If no occurrences are found, then subject is returned as is.\n\nThe replace string can have backreferences to the subexpressions in the form \\N, where N is a number from 1 to 9.\n\nThe function follows the case sensitivity rules of the effective collation. Matching is performed case insensitively for case insensitive collations, and case sensitively for case sensitive collations and for binary data.\n\nThe collation case sensitivity can be overwritten using the (?i) and (?-i) PCRE flags.\n\nMariaDB uses the PCRE regular expression library for enhanced regular expression performance, and REGEXP_REPLACE was introduced as part of this enhancement.\n\nThe default_regex_flags variable addresses the remaining compatibilities between PCRE and the old regex library.\n\nExamples\n--------\n\nSELECT REGEXP_REPLACE(''ab12cd'',''[0-9]'','''') AS remove_digits;\n-> abcd\n\nSELECT REGEXP_REPLACE(''titlebody'', ''<.+?>'','' '')\nAS strip_html;\n-> title body\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/regular-expressions-functions/regexp_replace', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/regular-expressions-functions/regexp_replace'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (458, 37, 'REGEXP\\_SUBSTR', 'Syntax\n------\n\nREGEXP_SUBSTR(subject,pattern)\n\nDescription\n-----------\n\nReturns the part of the string subject that matches the regular expression pattern, or an empty string if pattern was not found.\n\nThe function follows the case sensitivity rules of the effective collation. Matching is performed case insensitively for case insensitive collations, and case sensitively for case sensitive collations and for binary data.\n\nThe collation case sensitivity can be overwritten using the (?i) and (?-i) PCRE flags.\n\nMariaDB uses the PCRE regular expression library for enhanced regular expression performance, and REGEXP_SUBSTR was introduced as part of this enhancement.\n\nThe default_regex_flags variable addresses the remaining compatibilities between PCRE and the old regex library.\n\nExamples\n--------\n\nSELECT REGEXP_SUBSTR(''ab12cd'',''[0-9]+'');\n-> 12\n\nSELECT REGEXP_SUBSTR(\n ''See https://mariadb.org/en/foundation/ for details'',\n ''https?://[^/]*'');\n-> https://mariadb.org\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/regular-expressions-functions/regexp_substr', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/regular-expressions-functions/regexp_substr'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (459, 37, 'Regular Expressions Overview', 'Description\n-----------\n\nRegular Expressions allow MariaDB to perform complex pattern matching on a string. In many cases, the simple pattern matching provided by LIKE is sufficient. LIKE performs two kinds of matches:\n\n _ - the underscore, matching a single character\n % - the percentage sign, matching any number of characters.\n\nIn other cases you may need more control over the returned matches, and will need to use regular expressions.\n\nRegular expression matches are performed with the REGEXP function. RLIKE is a synonym for REGEXP.\n\nComparisons are performed on the byte value, so characters that are treated as equivalent by a collation, but do not have the same byte-value, such as accented characters, could evaluate as unequal.\n\nWithout any special characters, a regular expression match is true if the characters match. The match is case-insensitive, except in the case of BINARY strings.\n\n``sql\nSELECT ''Maria'' REGEXP ''Maria'';\n+------------------------+\n| ''Maria'' REGEXP ''Maria'' |\n+------------------------+\n| 1 |\n+------------------------+\n\nSELECT ''Maria'' REGEXP ''maria'';\n+------------------------+\n| ''Maria'' REGEXP ''maria'' |\n+------------------------+\n| 1 |\n+------------------------+\n\nSELECT BINARY ''Maria'' REGEXP ''maria'';\n+-------------------------------+\n| BINARY ''Maria'' REGEXP ''maria'' |\n+-------------------------------+\n| 0 |\n+-------------------------------+\n`\n\nNote that the word being matched must match the whole pattern:\n\n`sql\nSELECT ''Maria'' REGEXP ''Mari'';\n+-----------------------+\n| ''Maria'' REGEXP ''Mari'' |\n+-----------------------+\n| 1 |\n+-----------------------+\n\nSELECT ''Mari'' REGEXP ''Maria'';\n+-----------------------+\n| ''Mari'' REGEXP ''Maria'' |\n+-----------------------+\n| 0 |\n+-----------------------+\n`\n\nThe first returns true because the pattern "Mari" exists in the expression "Maria". When the order is reversed, the result is false, as the pattern "Maria" does not exist in the expression "Mari"\n\nA match can be performed against more than one word with the | character. For example:\n\n`sql\nSELECT ''Maria'' REGEXP ''Monty|Maria'';\n+------------------------------+\n| ''Maria'' REGEXP ''Monty|Maria'' |\n+------------------------------+\n| 1 |\n+------------------------------+\n`\n\nSpecial Characters\n\nThe above examples introduce the syntax, but are not very useful on their own. It''s the special characters that give regular expressions their power.\n\n^\n\n^ matches the beginning of a string (inside square brackets it can also mean NOT - see below):\n\n`sql\nSELECT ''Maria'' REGEXP ''^Ma'';\n+----------------------+\n| ''Maria'' REGEXP ''^Ma'' |\n+----------------------+\n| 1 |\n+----------------------+\n`\n\n$\n\n$ matches the end of a string:\n\n`sql\nSELECT ''Maria'' REGEXP ''ia$'';\n+----------------------+\n| ''Maria'' REGEXP ''ia$'' |\n+----------------------+\n| 1 |\n+----------------------+\n`\n\n.\n\n. matches any single character:\n\n`sql\nSELECT ''Maria'' REGEXP ''Ma.ia'';\n+------------------------+\n| ''Maria'' REGEXP ''Ma.ia'' |\n+------------------------+\n| 1 |\n+------------------------+\n\nSELECT ''Maria'' REGEXP ''Ma..ia'';\n+-------------------------+\n| ''Maria'' REGEXP ''Ma..ia'' |\n+-------------------------+\n| 0 |\n+-------------------------+\n`\n\n\\\n\nx matches zero or more of a character x. In the examples below, it''s the r character.\n\n`sql\nSELECT ''Maria'' REGEXP ''Maria'';\n+-------------------------+\n| ''Maria'' REGEXP ''Maria'' |\n+-------------------------+\n| 1 |\n+-------------------------+\n\nSELECT ''Maia'' REGEXP ''Maria'';\n+------------------------+\n| ''Maia'' REGEXP ''Maria'' |\n+------------------------+\n| 1 |\n+------------------------+\n\nSELECT ''Marrria'' REGEXP ''Maria'';\n+---------------------------+\n| ''Marrria'' REGEXP ''Maria'' |\n+---------------------------+\n| 1 |\n+---------------------------+\n`\n\n+\n\nx+ matches one or more of a character x. In the examples below, it''s the r character.\n\n`sql\nSELECT ''Maria'' REGEXP ''Mar+ia'';\n+-------------------------+\n| ''Maria'' REGEXP ''Mar+ia'' |\n+-------------------------+\n| 1 |\n+-------------------------+\n\nSELECT ''Maia'' REGEXP ''Mar+ia'';\n+------------------------+\n| ''Maia'' REGEXP ''Mar+ia'' |\n+------------------------+\n| 0 |\n+------------------------+\n\nSELECT ''Marrria'' REGEXP ''Mar+ia'';\n+---------------------------+\n| ''Marrria'' REGEXP ''Mar+ia'' |\n+---------------------------+\n| 1 |\n+---------------------------+\n`\n\n?\n\nx? matches zero or one of a character x. In the examples below, it''s the r character.\n\n`sql\nSELECT ''Maria'' REGEXP ''Mar?ia'';\n+-------------------------+\n| ''Maria'' REGEXP ''Mar?ia'' |\n+-------------------------+\n| 1 |\n+-------------------------+\n\nSELECT ''Maia'' REGEXP ''Mar?ia'';\n+------------------------+\n| ''Maia'' REGEXP ''Mar?ia'' |\n+------------------------+\n| 1 |\n+------------------------+\n\nSELECT ''Marrria'' REGEXP ''Mar?ia'';\n+---------------------------+\n| ''Marrria'' REGEXP ''Mar?ia'' |\n+---------------------------+\n| 0 |\n+---------------------------+\n`\n\n()\n\n(xyz) - combine a sequence, for example (xyz)+ or (xyz)\n\n`sql\nSELECT ''Maria'' REGEXP ''(ari)+'';\n+-------------------------+\n| ''Maria'' REGEXP ''(ari)+'' |\n+-------------------------+\n| 1 |\n+-------------------------+\n`\n\n{}\n\nx{n} and x{m,n}\\\nThis notation is used to match many instances of the x. In the case of x{n} the match must be exactly that many times. In the case of x{m,n}, the match can occur from m to n times. For example, to match zero or one instance of the string ari (which is identical to (ari)?), the following can be used:\n\n`sql\nSELECT ''Maria'' REGEXP ''(ari){0,1}'';\n+-----------------------------+\n| ''Maria'' REGEXP ''(ari){0,1}'' |\n+-----------------------------+\n| 1 |\n+-----------------------------+\n`\n\n\\[]\n\n[xy] groups characters for matching purposes. For example, to match either the p or the r character:\n\n`sql\nSELECT ''Maria'' REGEXP ''Ma[pr]ia'';\n+---------------------------+\n| ''Maria'' REGEXP ''Ma[pr]ia'' |\n+---------------------------+\n| 1 |\n+---------------------------+\n`\n\nThe square brackets also permit a range match, for example, to match any character from a-z, [a-z] is used. Numeric ranges are also permitted.\n\n`sql\nSELECT ''Maria'' REGEXP ''Ma[a-z]ia'';\n+----------------------------+\n| ''Maria'' REGEXP ''Ma[a-z]ia'' |\n+----------------------------+\n| 1 |\n+----------------------------+\n`\n\nThe following does not match, as r falls outside of the range a-p.\n\n`sql\nSELECT ''Maria'' REGEXP ''Ma[a-p]ia'';\n+----------------------------+\n| ''Maria'' REGEXP ''Ma[a-p]ia'' |\n+----------------------------+\n| 0 |\n+----------------------------+\n`\n\n^\n\nThe ^ character means does NOT match, for example:\n\n`sql\nSELECT ''Maria'' REGEXP ''Ma[^p]ia'';\n+---------------------------+\n| ''Maria'' REGEXP ''Ma[^p]ia'' |\n+---------------------------+\n| 1 |\n+---------------------------+\n\nSELECT ''Maria'' REGEXP ''Ma[^r]ia'';\n+---------------------------+\n| ''Maria'' REGEXP ''Ma[^r]ia'' |\n+---------------------------+\n| 0 |\n+---------------------------+\n`\n\nThe [ and ] characters on their own can be literally matched inside a [] block, without escaping, as long as they immediately match the opening bracket:\n\n`sql\nSELECT ''[Maria'' REGEXP ''[[]'';\n+-----------------------+\n| ''[Maria'' REGEXP ''[[]'' |\n+-----------------------+\n| 1 |\n+-----------------------+\n\nSELECT ''[Maria'' REGEXP ''[]]'';\n+-----------------------+\n| ''[Maria'' REGEXP ''[]]'' |\n+-----------------------+\n| 0 |\n+-----------------------+\n\nSELECT '']Maria'' REGEXP ''[]]'';\n+-----------------------+\n| '']Maria'' REGEXP ''[]]'' |\n+-----------------------+\n| 1 |\n+-----------------------+\n\nSELECT '']Maria'' REGEXP ''[]a]'';\n+------------------------+\n| '']Maria'' REGEXP ''[]a]'' |\n+------------------------+\n| 1 |\n+------------------------+\n`\n\nIncorrect order, so no match:\n\n`sql\nSELECT '']Maria'' REGEXP ''[a]]'';\n+------------------------+\n| '']Maria'' REGEXP ''[a]]'' |\n+------------------------+\n| 0 |\n+------------------------+\n`\n\nThe - character can also be matched in the same way:\n\n`sql\nSELECT ''-Maria'' REGEXP ''[1-10]'';\n+--------------------------+\n| ''-Maria'' REGEXP ''[1-10]'' |\n+--------------------------+\n| 0 |\n+--------------------------+\n\nSELECT ''-Maria'' REGEXP ''[-1-10]'';\n+---------------------------+\n| ''-Maria'' REGEXP ''[-1-10]'' |\n+---------------------------+\n| 1 |\n+---------------------------+\n`\n\nWord boundaries\n\nThe :<: and :>: patterns match the beginning and the end of a word respectively. For example:\n\n`sql\nSELECT ''How do I upgrade MariaDB?'' REGEXP ''[[:<:]]MariaDB[[:>:]]'';\n+------------------------------------------------------------+\n| ''How do I upgrade MariaDB?'' REGEXP ''[[:<:]]MariaDB[[:>:]]'' |\n+------------------------------------------------------------+\n| 1 |\n+------------------------------------------------------------+\n\nSELECT ''How do I upgrade MariaDB?'' REGEXP ''[[:<:]]Maria[[:>:]]'';\n+----------------------------------------------------------+\n| ''How do I upgrade MariaDB?'' REGEXP ''[[:<:]]Maria[[:>:]]'' |\n+----------------------------------------------------------+\n| 0 |\n+----------------------------------------------------------+\n`\n\nCharacter Classes\n\nThere are a number of shortcuts to match particular preset character classes. These are matched with the [:character_class:] pattern (inside a [] set). The following character classes exist:\n\n| Character Class | Description |\n| --------------- | ---------------------------------------- |\n| alnum | Alphanumeric |\n| alpha | Alphabetic |\n| blank | Whitespace |\n| cntrl | Control characters |\n| digit | Digits |\n| graph | Graphic characters |\n| lower | Lowercase alphabetic |\n| print | Graphic or space characters |\n| punct | Punctuation |\n| space | Space, tab, newline, and carriage return |\n| upper | Uppercase alphabetic |\n| xdigit | Hexadecimal digit |\n\nFor example:\n\n`sql\nSELECT ''Maria'' REGEXP ''Mar[[:alnum:]]'';\n+--------------------------------+\n| ''Maria'' REGEXP ''Mar[:alnum:]'' |\n+--------------------------------+\n| 1 |\n+--------------------------------+\n`\n\nRemember that matches are by default case-insensitive, unless a binary string is used, so the following example, specifically looking for an uppercase, counter-intuitively matches a lowercase character:\n\n`sql\nSELECT ''Mari'' REGEXP ''Mar[[:upper:]]+'';\n+---------------------------------+\n| ''Mari'' REGEXP ''Mar[[:upper:]]+'' |\n+---------------------------------+\n| 1 |\n+---------------------------------+\n\nSELECT BINARY ''Mari'' REGEXP ''Mar[[:upper:]]+'';\n+----------------------------------------+\n| BINARY ''Mari'' REGEXP ''Mar[[:upper:]]+'' |\n+----------------------------------------+\n| 0 |\n+----------------------------------------+\n`\n\nCharacter Names\n\nThere are also number of shortcuts to match particular preset character names. These are matched with the [.character.] pattern (inside a [] set). The following character classes exist:\n\n| Name | Character |\n| -------------------- | --------- |\n| NUL | 0 |\n| SOH | 001 |\n| STX | 002 |\n| ETX | 003 |\n| EOT | 004 |\n| ENQ | 005 |\n| ACK | 006 |\n| BEL | 007 |\n| alert | 007 |\n| BS | 010 |\n| backspace | ''\\b'' |\n| HT | 011 |\n| tab | ''\\t'' |\n| LF | 012 |\n| newline | ''\\n'' |\n| VT | 013 |\n| vertical-tab | ''\\v'' |\n| FF | 014 |\n| form-feed | ''\\f'' |\n| CR | 015 |\n| carriage-return | ''\\r'' |\n| SO | 016 |\n| SI | 017 |\n| DLE | 020 |\n| DC1 | 021 |\n| DC2 | 022 |\n| DC3 | 023 |\n| DC4 | 024 |\n| NAK | 025 |\n| SYN | 026 |\n| ETB | 027 |\n| CAN | 030 |\n| EM | 031 |\n| SUB | 032 |\n| ESC | 033 |\n| IS4 | 034 |\n| FS | 034 |\n| IS3 | 035 |\n| GS | 035 |\n| IS2 | 036 |\n| RS | 036 |\n| IS1 | 037 |\n| US | 037 |\n| space | '' '' |\n| exclamation-mark | ''!'' |\n| quotation-mark | ''"'' |\n| number-sign | ''#'' |\n| dollar-sign | ''$'' |\n| percent-sign | ''%'' |\n| ampersand | ''&'' |\n| apostrophe | '''''' |\n| left-parenthesis | ''('' |\n| right-parenthesis | '')'' |\n| asterisk | ''\\'' |\n| plus-sign | ''+'' |\n| comma | '','' |\n| hyphen | ''-'' |\n| hyphen-minus | ''-'' |\n| period | ''.'' |\n| full-stop | ''.'' |\n| slash | ''/'' |\n| solidus | ''/'' |\n| zero | ''0'' |\n| one | ''1'' |\n| two | ''2'' |\n| three | ''3'' |\n| four | ''4'' |\n| five | ''5'' |\n| six | ''6'' |\n| seven | ''7'' |\n| eight | ''8'' |\n| nine | ''9'' |\n| colon | '':'' |\n| semicolon | '';'' |\n| less-than-sign | ''<'' |\n| equals-sign | ''='' |\n| greater-than-sign | ''>'' |\n| question-mark | ''?'' |\n| commercial-at | ''@'' |\n| left-square-bracket | ''\\['' |\n| backslash | '''' |\n| reverse-solidus | '''' |\n| right-square-bracket | '']''\n\n[Truncated — full content at mariadb.com/docs]', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/regular-expressions-functions/regular-expressions-overview'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (460, 37, 'RLIKE', 'Syntax\n------\n\nexpr REGEXP pat, expr RLIKE pat\n\nDescription\n-----------\n\nRLIKE is a synonym for REGEXP.\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/regular-expressions-functions/rlike', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/regular-expressions-functions/rlike'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (461, 37, 'REPEAT Function', 'Syntax\n------\n\nREPEAT(str,count)\n\nDescription\n-----------\n\nReturns a string consisting of the string str repeated count times. Ifcount is less than 1, returns an empty string. Returns NULL if str orcount are NULL.\n\nExamples\n--------\n\nSELECT QUOTE(REPEAT(''MariaDB '',4));\n+------------------------------------+\n| QUOTE(REPEAT(''MariaDB '',4)) |\n+------------------------------------+\n| ''MariaDB MariaDB MariaDB MariaDB '' |\n+------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/repeat-function', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/repeat-function'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (462, 37, 'REPLACE Function', 'Syntax\n------\n\nREPLACE(str,from_str,to_str)\n\nDescription\n-----------\n\nReturns the string str with all occurrences of the string from_str replaced by the string to_str. REPLACE() performs a case-sensitive match when searching for from_str. If any argument is NULL, the function returns NULL.\n\nExamples\n--------\n\nSELECT REPLACE(''www.mariadb.org'', ''w'', ''Ww'');\n+---------------------------------------+\n| REPLACE(''www.mariadb.org'', ''w'', ''Ww'') |\n+---------------------------------------+\n| WwWwWw.mariadb.org |\n+---------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/replace-function', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/replace-function'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (463, 37, 'REVERSE', 'Syntax\n------\n\nREVERSE(str)\n\nDescription\n-----------\n\nReturns the string str with the order of the characters reversed. If the input string is NULL, the function returns NULL.\n\nExamples\n--------\n\nSELECT REVERSE(''desserts'');\n+---------------------+\n| REVERSE(''desserts'') |\n+---------------------+\n| stressed |\n+---------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/reverse', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/reverse'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (464, 37, 'RIGHT', 'Syntax\n------\n\nRIGHT(str,len)\n\nDescription\n-----------\n\nReturns the rightmost _len_ characters from the string _str_, or NULL if any argument is NULL.\n\nExamples\n--------\n\nSELECT RIGHT(''MariaDB'', 2);\n+---------------------+\n| RIGHT(''MariaDB'', 2) |\n+---------------------+\n| DB |\n+---------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/right', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/right'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (465, 37, 'RPAD', 'Syntax\n------\n\nRPAD(str, len [, padstr])\n\nDescription\n-----------\n\nReturns the string str, right-padded with the string padstr to a length of len characters. If str is longer than len, the return value is shortened to len characters. If padstr is omitted, the RPAD function pads spaces.\n\nReturns NULL if given a NULL argument. If the result is empty (a length of zero), returns either an empty string, or, with SQL_MODE=Oracle, NULL.\n\nThe Oracle mode version of the function can be accessed outside of Oracle mode by using RPAD_ORACLE as the function name.\n\nExamples\n--------\n\nSELECT RPAD(''hello'',10,''.'');\n+----------------------+\n| RPAD(''hello'',10,''.'') |\n+----------------------+\n| hello..... |\n+----------------------+\n\nSELECT RPAD(''hello'',2,''.'');\n+---------------------+\n| RPAD(''hello'',2,''.'') |\n+---------------------+\n| he |\n+---------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/rpad', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/rpad'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (466, 37, 'RTRIM', 'Syntax\n------\n\nRTRIM(str)\n\nDescription\n-----------\n\nReturns the string str with trailing space characters removed.\n\nReturns NULL if given a NULL argument. If the result is empty, returns either an empty string, or, with SQL_MODE=Oracle, NULL.\n\nThe Oracle mode version of the function can be accessed outside of Oracle mode by using RTRIM_ORACLE as the function name.\n\nExamples\n--------\n\nSELECT QUOTE(RTRIM(''MariaDB ''));\n+-----------------------------+\n| QUOTE(RTRIM(''MariaDB '')) |\n+-----------------------------+\n| ''MariaDB'' |\n+-----------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/rtrim', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/rtrim'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (467, 37, 'SFORMAT', 'Description\n-----------\n\nThe SFORMAT function takes an input string and a formatting specification and returns the string formatted using the rules the user passed in the specification.\n\nIt uses the fmtlib library for Python-like (as well as Rust, C++20, etc) string formatting.\n\nOnly fmtlib 7.0.0+ is supported.\n\nThere is no native support for temporal and decimal values:\n\n TIME_RESULT is handled as STRING_RESULT.\n DECIMAL_RESULT is handled as REAL_RESULT.\n\nExamples\n--------\n\nSELECT SFORMAT("The answer is {}.", 42);\n+----------------------------------+\n| SFORMAT("The answer is {}.", 42) |\n+----------------------------------+\n| The answer is 42. |\n+----------------------------------+\n\nCREATE TABLE test_sformat(mdb_release char(6), mdev int, feature char(20));\n\nINSERT INTO test_sformat VALUES(''10.7.0'', 25015, ''Python style sformat''), \n (''10.7.0'', 4958, ''UUID'');\n\nSELECT * FROM test_sformat;\n+-------------+-------+----------------------+\n| mdb_release | mdev | feature |\n+-------------+-------+----------------------+\n| 10.7.0 | 25015 | Python style sformat |\n| 10.7.0 | 4958 | UUID |\n+-------------+-------+----------------------+\n\nSELECT SFORMAT(''MariaDB Server {} has a preview for MDEV-{} which is about {}'', \n mdb_release, mdev, feature) AS ''Preview Release Examples''\n FROM test_sformat;\n+----------------------------------------------------------------------------------------+\n| Preview Release Examples |\n+----------------------------------------------------------------------------------------+\n| MariaDB Server 10.7.0 has a preview for MDEV-25015 which is about Python style sformat |\n| MariaDB Server 10.7.0 has a preview for MDEV-4958 which is about UUID |\n+----------------------------------------------------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/sformat', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/sformat'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (468, 37, 'SOUNDEX', 'Syntax\n------\n\nSOUNDEX(str)\n\nDescription\n-----------\n\nReturns a soundex string from _str_. Two strings that sound almost the same should have identical soundex strings. A standard soundex string is four characters long, but the SOUNDEX() function returns an arbitrarily long string. You can use SUBSTRING() on the result to get a standard soundex string. All non-alphabetic characters in _str_ are ignored. All international alphabetic characters outside the A-Z range are treated as vowels.\n\nImportant: When using SOUNDEX(), you should be aware of the following details:\n\n This function, as currently implemented, is intended to work well with strings that are in the English language only. Strings in other languages may not produce reasonable results.\n This function implements the original Soundex algorithm, not the more popular enhanced version (also described by D. Knuth). The difference is that original version discards vowels first and duplicates second, whereas the enhanced version discards duplicates first and vowels second.\n\nExamples\n--------\n\nSOUNDEX(''Hello'');\n+------------------+\n| SOUNDEX(''Hello'') |\n+------------------+\n| H400 |\n+------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/soundex', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/soundex'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (469, 37, 'SOUNDS LIKE', 'Syntax\n------\n\nexpr1 SOUNDS LIKE expr2\n\nDescription\n-----------\n\nThis is the same as SOUNDEX(expr1) = SOUNDEX(expr2).\n\nExamples\n--------\n\nSELECT givenname, surname FROM users WHERE givenname SOUNDS LIKE "robert";\n+-----------+---------+\n| givenname | surname |\n+-----------+---------+\n| Roberto | Castro |\n+-----------+---------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/sounds-like', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/sounds-like'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (470, 37, 'SPACE', 'Syntax\n------\n\nSPACE(N)\n\nDescription\n-----------\n\nReturns a string consisting of _N_ space characters. If N is NULL, returns NULL.\n\nExamples\n--------\n\nSELECT QUOTE(SPACE(6));\n+-----------------+\n| QUOTE(SPACE(6)) |\n+-----------------+\n| '' '' |\n+-----------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/space', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/space'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (471, 37, 'STRCMP', 'Syntax\n------\n\nSTRCMP(expr1,expr2)\n\nDescription\n-----------\n\nSTRCMP() returns 0 if the strings are the same, -1 if the first argument is smaller than the second according to the current sort order, and 1 if the strings are otherwise not the same. Returns NULL is either argument is NULL.\n\nExamples\n--------\n\nSELECT STRCMP(''text'', ''text2'');\n+-------------------------+\n| STRCMP(''text'', ''text2'') |\n+-------------------------+\n| -1 |\n+-------------------------+\n\nSELECT STRCMP(''text2'', ''text'');\n+-------------------------+\n| STRCMP(''text2'', ''text'') |\n+-------------------------+\n| 1 |\n+-------------------------+\n\nSELECT STRCMP(''text'', ''text'');\n+------------------------+\n| STRCMP(''text'', ''text'') |\n+------------------------+\n| 0 |\n+------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/strcmp', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/strcmp'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (472, 37, 'SUBSTR', 'Description\n-----------\n\nSUBSTR() is a synonym for SUBSTRING().\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/substr', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/substr'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (473, 37, 'SUBSTRING', 'Description\n-----------\n\nThe forms without a _len_ argument return a substring from string _str_ starting at position _pos_.\n\nThe forms with a _len_ argument return a substring _len_ characters long from string _str_, starting at position _pos_.\n\nThe forms that use _FROM_ are standard SQL syntax.\n\nIt is also possible to use a negative value for _pos_. In this case, the beginning of the substring is _pos_ characters from the end of the string, rather than the beginning. A negative value may be used for _pos_ in any of the forms of this function.\n\nBy default, the position of the first character in the string from which the substring is to be extracted is 1. If the value of _pos_ is 0, the result is empty string. For Oracle compatibility, when sql_mode is set to ''oracle'', position 0 is treated as position 1.\n\nIf any argument is NULL, returns NULL.\n\nThe optimizer can make use of an index for conditions like SUBSTR(indexed_column, 1, n) = const_string.\n\nThe optimizer cannot make use of an index if an indexed column is an argument of SUBSTR().\n\nExamples\n--------\n\nSELECT SUBSTRING(''Knowledgebase'',5);\n+------------------------------+\n| SUBSTRING(''Knowledgebase'',5) |\n+------------------------------+\n| ledgebase |\n+------------------------------+\n\nSELECT SUBSTRING(''MariaDB'' FROM 6);\n+-----------------------------+\n| SUBSTRING(''MariaDB'' FROM 6) |\n+-----------------------------+\n| DB |\n+-----------------------------+\n\nSELECT SUBSTRING(''Knowledgebase'',3,7);\n+--------------------------------+\n| SUBSTRING(''Knowledgebase'',3,7) |\n+--------------------------------+\n| owledge |\n+--------------------------------+\n\nSELECT SUBSTRING(''Knowledgebase'', -4);\n+--------------------------------+\n| SUBSTRING(''Knowledgebase'', -4) |\n+--------------------------------+\n| base |\n+--------------------------------+\n\nSELECT SUBSTRING(''Knowledgebase'', 0);\n+--------------------------------+\n| SUBSTRING(''Knowledgebase'', 0) |\n+--------------------------------+\n| |\n+--------------------------------+\n\nSELECT SUBSTRING(''Knowledgebase'', -8, 4);\n+-----------------------------------+\n| SUBSTRING(''Knowledgebase'', -8, 4) |\n+-----------------------------------+\n| edge |\n+-----------------------------------+\n\nSELECT SUBSTRING(''Knowledgebase'' FROM -8 FOR 4);\n+------------------------------------------+\n| SUBSTRING(''Knowledgebase'' FROM -8 FOR 4) |\n+------------------------------------------+\n| edge |\n+------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/substring', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/substring'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (474, 37, 'SUBSTRING\\_INDEX', 'Syntax\n------\n\nSUBSTRING_INDEX(str,delim,count)\n\nDescription\n-----------\n\nReturns the substring from string _str_ before count occurrences of the delimiter _delim_. If _count_ is positive, everything to the left of the final delimiter (counting from the left) is returned. If _count_ is negative, everything to the right of the final delimiter (counting from the right) is returned. SUBSTRING_INDEX() performs a case-sensitive match when searching for _delim_.\n\nIf any argument is NULL, returns NULL.\n\nFor example:\n\n``sql\nSUBSTRING_INDEX(''www.mariadb.org'', ''.'', 2)\n``\n\nIt means "Return all of the characters up to the 2nd occurrence of ."\n\nExamples\n--------\n\nSELECT SUBSTRING_INDEX(''www.mariadb.org'', ''.'', 2);\n+--------------------------------------------+\n| SUBSTRING_INDEX(''www.mariadb.org'', ''.'', 2) |\n+--------------------------------------------+\n| www.mariadb |\n+--------------------------------------------+\n\nSELECT SUBSTRING_INDEX(''www.mariadb.org'', ''.'', -2);\n+---------------------------------------------+\n| SUBSTRING_INDEX(''www.mariadb.org'', ''.'', -2) |\n+---------------------------------------------+\n| mariadb.org |\n+---------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/substring_index', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/substring_index'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (475, 37, 'TO\\_BASE64', 'Syntax\n------\n\nTO_BASE64(str)\n\nDescription\n-----------\n\nConverts the string argument str to its base-64 encoded form, returning the result as a character string in the connection character set and collation.\n\nThe argument str will be converted to string first if it is not a string. A NULL argument will return a NULL result.\n\nThe reverse function, FROM_BASE64(), decodes an encoded base-64 string.\n\nThere are a numerous different methods to base-64 encode a string. The following are used by MariaDB and MySQL:\n\n Alphabet value 64 is encoded as ''+''.\n Alphabet value 63 is encoded as ''/''.\n Encoding output is made up of groups of four printable characters, with each three bytes of data encoded using four characters. If the final group is not complete, it is padded with ''='' characters to make up a length of four.\n To divide long output, a newline is added after every 76 characters.\n* Decoding will recognize and ignore newlines, carriage returns, tabs, and spaces.\n\nExamples\n--------\n\nSELECT TO_BASE64(''Maria'');\n+--------------------+\n| TO_BASE64(''Maria'') |\n+--------------------+\n| TWFyaWE= |\n+--------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/to_base64', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/to_base64'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (476, 37, 'TO\\_CHAR', 'Syntax\n------\n\nTO_CHAR(expr[, fmt])\n\nDescription\n-----------\n\nThe TO_CHAR function converts an _expr_ of type date, datetime, time or timestamp to a string. The optional _fmt_ argument supports YYY/YYY/YY/RRRR/RR/MM/MON/MONTH/MI/DD/DY/HH/HH12/HH24/SS and special characters. The default value is YYYY-MM-DD HH24:MI:SS. TO_CHAR also accepts FM in the format string, which disables padding of all components following it.\n\nFM can be specified multiple times, with each time disabling the previous state:\n\n An odd number of FMs disables padding.\n An even number of FMs enables padding.\n\nThese additional formats (for _fmt_) are available:\n\n FF[1-6] – Fractional seconds\n DDD – Day (1-366)\n IW – Week 1-53 according to ISO 8601\n I – 1-digit year according to ISO 8601\n IY – 2-digit year according to ISO 8601\n IYY – 3-digit year according to ISO 8601\n IYYY – 4-digit year according to ISO 8601\n SYYY – 4-digit year according to ISO 8601 (Oracle can use signed years)\n\nThe TO_CHAR function converts an _expr_ of type date, datetime, time or timestamp to a string. The optional _fmt_ argument supports YYY/YYY/YY/RRRR/RR/MM/MON/MONTH/MI/DD/DY/HH/HH12/HH24/SS and special characters. The default value is YYYY-MM-DD HH24:MI:SS. TO_CHAR also accepts FM in the format string, which disables padding of all components following it.\n\nFM can be specified multiple times, with each time disabling the previous state:\n\n An odd number of FMs disables padding.\n An even number of FMs enables padding.\n\nThe TO_CHAR function converts an _expr_ of type date, datetime, time or timestamp to a string. The optional _fmt_ argument supports YYY/YYY/YY/RRRR/RR/MM/MON/MONTH/MI/DD/DY/HH/HH12/HH24/SS and special characters. The default value is YYYY-MM-DD HH24:MI:SS.\n\nIn Oracle, TO_CHAR can also be used to convert numbers to strings, but this is not supported in MariaDB and gives an error.\n\nExamples\n--------\n\nSELECT TO_CHAR(''1980-01-11 04:50:39'', ''YYYY-MM-DD'');\n+----------------------------------------------+\n| TO_CHAR(''1980-01-11 04:50:39'', ''YYYY-MM-DD'') |\n+----------------------------------------------+\n| 1980-01-11 |\n+----------------------------------------------+\n\nSELECT TO_CHAR(''1980-01-11 04:50:39'', ''HH24-MI-SS'');\n+----------------------------------------------+\n| TO_CHAR(''1980-01-11 04:50:39'', ''HH24-MI-SS'') |\n+----------------------------------------------+\n| 04-50-39 |\n+----------------------------------------------+\n\nSELECT TO_CHAR(''00-01-01 00:00:00'', ''YY-MM-DD HH24:MI:SS'');\n+-----------------------------------------------------+\n| TO_CHAR(''00-01-01 00:00:00'', ''YY-MM-DD HH24:MI:SS'') |\n+-----------------------------------------------------+\n| 00-01-01 00:00:00 |\n+-----------------------------------------------------+\n\nSELECT TO_CHAR(''99-12-31 23:59:59'', ''YY-MM-DD HH24:MI:SS'');\n+-----------------------------------------------------+\n| TO_CHAR(''99-12-31 23:59:59'', ''YY-MM-DD HH24:MI:SS'') |\n+-----------------------------------------------------+\n| 99-12-31 23:59:59 |\n+-----------------------------------------------------+\n\nSELECT TO_CHAR(''9999-12-31 23:59:59'', ''YY-MM-DD HH24:MI:SS'');\n+-------------------------------------------------------+\n| TO_CHAR(''9999-12-31 23:59:59'', ''YY-MM-DD HH24:MI:SS'') |\n+-------------------------------------------------------+\n| 99-12-31 23:59:59 |\n+-------------------------------------------------------+\n\nSELECT TO_CHAR(''21-01-03 08:30:00'', ''Y-MONTH-DY HH:MI:SS'');\n+-----------------------------------------------------+\n| TO_CHAR(''21-01-03 08:30:00'', ''Y-MONTH-DY HH:MI:SS'') |\n+-----------------------------------------------------+\n| 1-January -Sun 08:30:00 |\n+-----------------------------------------------------+\n\nFrom MariaDB 12.0, FM removes following padding:\n\nSELECT CONCAT(''/'', TO_CHAR(''2020-01-06 10:11:12'', ''DAY''), ''/'');\n+---------------------------------------------------------+\n| CONCAT(''/'', TO_CHAR(''2020-01-06 10:11:12'', ''DAY''), ''/'') |\n+---------------------------------------------------------+\n| /Monday / |\n+---------------------------------------------------------+\n\nSELECT CONCAT(''/'', TO_CHAR(''2020-01-06 10:11:12'', ''FMDAY''), ''/'');\n+-----------------------------------------------------------+\n| CONCAT(''/'', TO_CHAR(''2020-01-06 10:11:12'', ''FMDAY''), ''/'') |\n+-----------------------------------------------------------+\n| /Monday/ |\n+-----------------------------------------------------------+\n\nEven numbers of FM enable padding, while odd numbers disable it:\n\nSELECT CONCAT(''/'', TO_CHAR(''2020-01-06 10:11:12'', ''FMFMDAY''), ''/'');\n+-------------------------------------------------------------+\n| CONCAT(''/'', TO_CHAR(''2020-01-06 10:11:12'', ''FMFMDAY''), ''/'') |\n+-------------------------------------------------------------+\n| /Monday / |\n+-------------------------------------------------------------+\n\nSELECT CONCAT(''/'', TO_CHAR(''2020-01-06 10:11:12'', ''FMFMFMDAY''), ''/'');\n+---------------------------------------------------------------+\n| CONCAT(''/'', TO_CHAR(''2020-01-06 10:11:12'', ''FMFMFMDAY''), ''/'') |\n+---------------------------------------------------------------+\n| /Monday/ |\n+---------------------------------------------------------------+\n\nFM only suppresses following padding:\n\nSELECT CONCAT(''/'', TO_CHAR(''2020-01-06 10:11:12'', ''DAYFM''), ''/'');\n+-----------------------------------------------------------+\n| CONCAT(''/'', TO_CHAR(''2020-01-06 10:11:12'', ''DAYFM''), ''/'') |\n+-----------------------------------------------------------+\n| /Monday / |\n+-----------------------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/to_char', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/to_char'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (477, 37, 'TRIM', 'Syntax\n------\n\nTRIM_ORACLE([{BOTH | LEADING | TRAILING} [remstr] FROM] str), TRIM([remstr FROM] str)\n\nDescription\n-----------\n\nReturns the string str with all remstr prefixes or suffixes removed. If none of the specifiers BOTH, LEADING, or TRAILING is given, BOTH is assumed. remstr is optional and, if not specified, spaces are removed.\n\nReturns NULL if given a NULL argument. If the result is empty, returns either an empty string, or, with SQL_MODE=Oracle, NULL. SQL_MODE=Oracle is not set by default.\n\nThe Oracle mode version of the function can be accessed in any mode by using TRIM_ORACLE as the function name.\n\nExamples\n--------\n\nSELECT TRIM('' bar '')\\G\n************************ 1. row *********************\nTRIM('' bar ''): bar\n\nSELECT TRIM(LEADING ''x'' FROM ''xxxbarxxx'')\\G\n********************* 1. row *********************\nTRIM(LEADING ''x'' FROM ''xxxbarxxx''): barxxx\n\nSELECT TRIM(BOTH ''x'' FROM ''xxxbarxxx'')\\G\n********************* 1. row *********************\nTRIM(BOTH ''x'' FROM ''xxxbarxxx''): bar\n\nSELECT TRIM(TRAILING ''xyz'' FROM ''barxxyz'')\\G\n********************* 1. row ************************\nTRIM(TRAILING ''xyz'' FROM ''barxxyz''): barx\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/trim', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/trim'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (478, 37, 'TRIM\\_ORACLE', 'Description\n-----------\n\nTRIM_ORACLE is a synonym for the Oracle mode version of the TRIM function, and is available in all modes.\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/trim_oracle', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/trim_oracle'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (479, 37, 'Type Conversion', 'Description\n-----------\n\nImplicit type conversion takes place when MariaDB is using operands or different types, in order to make the operands compatible.\n\nIt is best practice not to rely upon implicit conversion; rather use CAST to explicitly convert types.\n\nRules for Conversion on Comparison\n\n If either argument is NULL, the result of the comparison is NULL unless the NULL-safe <=> equality comparison operator is used.\n If both arguments are integers, they are compared as integers.\n If both arguments are strings, they are compared as strings.\n If one argument is decimal and the other argument is decimal or integer, they are compared as decimals.\n If one argument is decimal and the other argument is a floating point, they are compared as floating point values.\n If one argument is string and the other argument is integer, they are compared as decimals.\n If a hexadecimal argument is not compared to a number, it is treated as a binary string.\n If a constant is compared to a TIMESTAMP or DATETIME, the constant is converted to a timestamp, unless used as an argument to the IN function.\n In other cases, arguments are compared as floating point, or real, numbers.\n\nNote that if a string column is being compared with a numeric value, MariaDB will not use the index on the column, as there are numerous alternatives that may evaluate as equal (see examples below).\n\nComparison Examples\n\nConverting a string to a number:\n\n``sql\nSELECT 15+''15'';\n+---------+\n| 15+''15'' |\n+---------+\n| 30 |\n+---------+\n`\n\nConverting a number to a string:\n\n`sql\nSELECT CONCAT(15,''15'');\n+-----------------+\n| CONCAT(15,''15'') |\n+-----------------+\n| 1515 |\n+-----------------+\n`\n\nFloating point number errors:\n\n`sql\nSELECT ''9746718491924563214'' = 9746718491924563213;\n+---------------------------------------------+\n| ''9746718491924563214'' = 9746718491924563213 |\n+---------------------------------------------+\n| 1 |\n+---------------------------------------------+\n`\n\nNumeric equivalence with strings:\n\n`sql\nSELECT ''5'' = 5;\n+---------+\n| ''5'' = 5 |\n+---------+\n| 1 |\n+---------+\n\nSELECT '' 5'' = 5;\n+------------+\n| '' 5'' = 5 |\n+------------+\n| 1 |\n+------------+\n\nSELECT '' 5 '' = 5;\n+--------------+\n| '' 5 '' = 5 |\n+--------------+\n| 1 |\n+--------------+\n1 row in set, 1 warning (0.000 sec)\n\nSHOW WARNINGS;\n+-------+------+--------------------------------------------+\n| Level | Code | Message |\n+-------+------+--------------------------------------------+\n| Note | 1292 | Truncated incorrect DOUBLE value: '' 5 '' |\n+-------+------+--------------------------------------------+\n`\n\nAs a result of the above, MariaDB cannot use the index when comparing a string with a numeric value in the example below:\n\n`sql\nCREATE TABLE t (a VARCHAR(10), b VARCHAR(10), INDEX idx_a (a));\n\nINSERT INTO t VALUES \n (''1'', ''1''), (''2'', ''2''), (''3'', ''3''), \n (''4'', ''4''), (''5'', ''5''), (''1'', ''5'');\n\nEXPLAIN SELECT FROM t WHERE a = ''3'' \\G\n************************ 1. row ***********************\n id: 1\n select_type: SIMPLE\n table: t\n type: ref\npossible_keys: idx_a\n key: idx_a\n key_len: 13\n ref: const\n rows: 1\n Extra: Using index condition\n\nEXPLAIN SELECT FROM t WHERE a = 3 \\G\n************************ 1. row ***********************\n id: 1\n select_type: SIMPLE\n table: t\n type: ALL\npossible_keys: idx_a\n key: NULL\n key_len: NULL\n ref: NULL\n rows: 6\n Extra: Using where\n`\n\nRules for Conversion on Dyadic Arithmetic Operations\n\nImplicit type conversion also takes place on dyadic arithmetic operations (+,-,\\,/). MariaDB chooses the minimum data type that is guaranteed to fit the result and converts both arguments to the result data type.\n\nFor addition (+), subtraction (-) and multiplication (\\), the result data type is chosen as follows:\n\n If either of the arguments is an approximate number (float, double), the result is double.\n If either of the arguments is a string (char, varchar, text), the result is double.\n If either of the arguments is a decimal number, the result is decimal.\n If either of the arguments is of a temporal type with a non-zero fractional second precision (time(N), datetime(N), timestamp(N)), the result is decimal.\n If either of the arguments is of a temporal type with a zero fractional second precision (time(0), date, datetime(0), timestamp(0)), the result may vary between int, int unsigned, bigint or bigint unsigned, depending on the exact data type combination.\n If both arguments are integer numbers (tinyint, smallint, mediumint, bigint), the result may vary between int, int unsigned, bigint or bigint unsigned, depending of the exact data types and their signs.\n\nFor division (/), the result data type is chosen as follows:\n\n If either of the arguments is an approximate number (float, double), the result is double.\n If either of the arguments is a string (char, varchar, text), the result is double.\n Otherwise, the result is decimal.\n\nArithmetic Examples\n\nNote, the above rules mean that when an argument of a temporal data type appears in addition or subtraction, it''s treated as a number by default.\n\n`sql\nSELECT TIME''10:20:30'' + 1;\n+--------------------+\n| TIME''10:20:30'' + 1 |\n+--------------------+\n| 102031 |\n+--------------------+\n`\n\nIn order to do temporal addition or subtraction instead, use the DATE_ADD() or DATE_SUB() functions, or an INTERVAL expression as the second argument:\n\n`sql\nSELECT TIME''10:20:30'' + INTERVAL 1 SECOND;\n+------------------------------------+\n| TIME''10:20:30'' + INTERVAL 1 SECOND |\n+------------------------------------+\n| 10:20:31 |\n+------------------------------------+\n`\n\n`sql\nSELECT "2.2" + 3;\n+-----------+\n| "2.2" + 3 |\n+-----------+\n| 5.2 |\n+-----------+\n\nSELECT 2.2 + 3;\n+---------+\n| 2.2 + 3 |\n+---------+\n| 5.2 |\n+---------+\n\nSELECT 2.2 / 3;\n+---------+\n| 2.2 / 3 |\n+---------+\n| 0.73333 |\n+---------+\n\nSELECT "2.2" / 3;\n+--------------------+\n| "2.2" / 3 |\n+--------------------+\n| 0.7333333333333334 |\n+--------------------+\n``\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/type-conversion', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/type-conversion'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (480, 37, 'UCASE', 'Syntax\n------\n\nUCASE(str)\n\nDescription\n-----------\n\nUCASE() is a synonym for UPPER().\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/ucase', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/ucase'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (481, 37, 'UNHEX', 'Syntax\n------\n\nUNHEX(str)\n\nDescription\n-----------\n\nPerforms the inverse operation of HEX(str). That is, it interprets each pair of hexadecimal digits in the argument as a number and converts it to the character represented by the number. The resulting\\\ncharacters are returned as a binary string.\n\nIf str is NULL, UNHEX() returns NULL.\n\nExamples\n--------\n\nSELECT HEX(''MariaDB'');\n+----------------+\n| HEX(''MariaDB'') |\n+----------------+\n| 4D617269614442 |\n+----------------+\n\nSELECT UNHEX(''4D617269614442'');\n+-------------------------+\n| UNHEX(''4D617269614442'') |\n+-------------------------+\n| MariaDB |\n+-------------------------+\n\nSELECT 0x4D617269614442;\n+------------------+\n| 0x4D617269614442 |\n+------------------+\n| MariaDB |\n+------------------+\n\nSELECT UNHEX(HEX(''string''));\n+----------------------+\n| UNHEX(HEX(''string'')) |\n+----------------------+\n| string |\n+----------------------+\n\nSELECT HEX(UNHEX(''1267''));\n+--------------------+\n| HEX(UNHEX(''1267'')) |\n+--------------------+\n| 1267 |\n+--------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/unhex', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/unhex'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (482, 37, 'UPDATEXML', 'Syntax\n------\n\nUpdateXML(xml_target, xpath_expr, new_xml)\n\nDescription\n-----------\n\nThis function replaces a single portion of a given fragment of XML markupxml_target with a new XML fragment new_xml, and then returns the changed XML. The portion of xml_target that is replaced matches an XPath expression xpath_expr supplied by the user. If no expression matching xpath_expr is found, or if multiple matches are found, the function returns the original xml_target XML fragment. All three arguments should be strings.\n\nExamples\n--------\n\nSELECT\n UpdateXML(''ccc'', ''/a'', ''fff'') AS val1,\n UpdateXML(''ccc'', ''/b'', ''fff'') AS val2,\n UpdateXML(''ccc'', ''//b'', ''fff'') AS val3,\n UpdateXML(''ccc'', ''/a/d'', ''fff'') AS val4,\n UpdateXML(''ccc'', ''/a/d'', ''fff'') AS val5\n \\G\n************************ 1. row ************************\nval1: fff\nval2: ccc\nval3: fff\nval4: cccfff\nval5: ccc\n1 row in set (0.00 sec)\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/updatexml', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/updatexml'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (483, 37, 'UPPER', 'Syntax\n------\n\nUPPER(str)\nUCASE(str)\n\nDescription\n-----------\n\nReturns the string str with all characters changed to uppercase according to the current character set mapping. The default is latin1 (cp1252 West European).\nThe result may depend on the collation and character set used.\nUCASE is a synonym.\n\n``sql\nSELECT UPPER(surname), givenname FROM users ORDER BY surname;\n+----------------+------------+\n| UPPER(surname) | givenname |\n+----------------+------------+\n| ABEL | Jacinto |\n| CASTRO | Robert |\n| COSTA | Phestos |\n| MOSCHELLA | Hippolytos |\n+----------------+------------+\n`\n\nUPPER()` is ineffective when applied to binary strings (BINARY, VARBINARY, BLOB). The description of LOWER() shows how to perform lettercase conversion of binary strings.\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/upper', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/upper'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (484, 37, 'WEIGHT\\_STRING', 'Syntax\n------\n\nWEIGHT_STRING(str [AS {CHAR|BINARY}(N)] [LEVEL levels] [flags])\n levels: N [ASC|DESC|REVERSE] [, N [ASC|DESC|REVERSE]] ...\n\nDescription\n-----------\n\nReturns a binary string representing the string''s sorting and comparison value. A string with a lower result means that for sorting purposes the string appears before a string with a higher result.\n\nWEIGHT_STRING() is particularly useful when adding new collations, for testing purposes.\n\nIf str is a non-binary string (CHAR, VARCHAR or TEXT), WEIGHT_STRING returns the string''s collation weight. If str is a binary string (BINARY, VARBINARY or BLOB), the return value is simply the input value, since the weight for each byte in a binary string is the byte value.\n\nWEIGHT_STRING() returns NULL if given a NULL input.\n\nThe optional AS clause permits casting the input string to a binary or non-binary string, as well as to a particular length.\n\nAS BINARY(N) measures the length in bytes rather than characters, and right pads with 0x00 bytes to the desired length.\n\nAS CHAR(N) measures the length in characters, and right pads with spaces to the desired length.\n\nN has a minimum value of 1, and if it is less than the length of the input string, the string is truncated without warning.\n\nThe optional LEVEL clause specifies that the return value should contain weights for specific collation levels. The levels specifier can either be a single integer, a comma-separated list of integers, or a range of integers separated by a dash (whitespace is ignored). Integers can range from 1 to a maximum of 6, dependent on the collation, and need to be listed in ascending order.\n\nIf the LEVEL clause is no provided, a default of 1 to the maximum for the collation is assumed.\n\nIf the q is specified without using a range, an optional modifier is permitted.\n\nASC, the default, returns the weights without any modification.\n\nDESC returns bitwise-inverted weights.\n\nREVERSE returns the weights in reverse order.\n\nExamples\n--------\n\nSELECT HEX(WEIGHT_STRING(''x''));\n+-------------------------+\n| HEX(WEIGHT_STRING(''x'')) |\n+-------------------------+\n| 0058 |\n+-------------------------+\n\nSELECT HEX(WEIGHT_STRING(''x'' AS BINARY(4)));\n+--------------------------------------+\n| HEX(WEIGHT_STRING(''x'' AS BINARY(4))) |\n+--------------------------------------+\n| 78000000 |\n+--------------------------------------+\n\nSELECT HEX(WEIGHT_STRING(''x'' AS CHAR(4)));\n+------------------------------------+\n| HEX(WEIGHT_STRING(''x'' AS CHAR(4))) |\n+------------------------------------+\n| 0058002000200020 |\n+------------------------------------+\n\nSELECT HEX(WEIGHT_STRING(0xaa22ee LEVEL 1));\n+--------------------------------------+\n| HEX(WEIGHT_STRING(0xaa22ee LEVEL 1)) |\n+--------------------------------------+\n| AA22EE |\n+--------------------------------------+\n\nSELECT HEX(WEIGHT_STRING(0xaa22ee LEVEL 1 DESC));\n+-------------------------------------------+\n| HEX(WEIGHT_STRING(0xaa22ee LEVEL 1 DESC)) |\n+-------------------------------------------+\n| 55DD11 |\n+-------------------------------------------+\n\nSELECT HEX(WEIGHT_STRING(0xaa22ee LEVEL 1 REVERSE));\n+----------------------------------------------+\n| HEX(WEIGHT_STRING(0xaa22ee LEVEL 1 REVERSE)) |\n+----------------------------------------------+\n| EE22AA |\n+----------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/weight_string', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/weight_string'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (485, 35, 'VEC\\_DISTANCE\\_COSINE', 'Syntax\n------\n\nVEC_DISTANCE_COSINE(v, s)\n\nDescription\n-----------\n\nVEC_Distance_Cosine is an SQL function that calculates the Cosine distance between two (not necessarily normalized) vectors.\n\nVectors must be of the same length. A distance between two vectors of different lengths is not defined, and VEC_Distance_Cosine will return NULL in such cases.\n\nIf the vector index was not built for the cosine function (see CREATE TABLE with Vectors), the index is not used — a full table scan is performed instead. The VEC_DISTANCE function is a generic function that behaves either as VEC_DISTANCE_EUCLIDEAN or VEC_DISTANCE_COSINE, depending on the underlying index type.\n\nExamples\n--------\n\nSELECT VEC_DISTANCE_COSINE(vec_fromtext(''[1,2,3]''), vec_fromtext(''[3,5,7]''));\n+-----------------------------------------------------------------------+\n| VEC_DISTANCE_COSINE(vec_fromtext(''[1,2,3]''), vec_fromtext(''[3,5,7]'')) |\n+-----------------------------------------------------------------------+\n| 0.00258509695694209 |\n+-----------------------------------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/vector-functions/vec_distance_cosine', '', 'https://mariadb.com/docs/server/reference/sql-functions/vector-functions/vec_distance_cosine'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (486, 35, 'VEC\\_DISTANCE\\_EUCLIDEAN', 'Syntax\n------\n\nVEC_DISTANCE_EUCLIDEAN(v, s)\n\nDescription\n-----------\n\nVEC_Distance_Euclidean is an SQL function that calculates a Euclidean (L2) distance between two points.\n\nVectors must be of the same length, a distance between two vectors of different lengths is not defined and VEC_Distance_Euclidean returns NULL in such cases.\n\nIf the vector index was not built for the euclidean function (see CREATE TABLE with Vectors), the index is not used, and a full table scan performed instead. The VEC_DISTANCE function is a generic function that behaves either as VEC_DISTANCE_EUCLIDEAN or VEC_DISTANCE_COSINE, depending on the underlying index type.\n\nExamples\n--------\n\nINSERT INTO v VALUES \n (1, x''e360d63ebe554f3fcdbc523f4522193f5236083d''),\n (2, x''f511303f72224a3fdd05fe3eb22a133ffae86a3f''),\n (3,x''f09baa3ea172763f123def3e0c7fe53e288bf33e''),\n (4,x''b97a523f2a193e3eb4f62e3f2d23583e9dd60d3f''),\n (5,x''f7c5df3e984b2b3e65e59d3d7376db3eac63773e''),\n (6,x''de01453ffa486d3f10aa4d3fdd66813c71cb163f''),\n (7,x''76edfc3e4b57243f10f8423fb158713f020bda3e''),\n (8,x''56926c3fdf098d3e2c8c5e3d1ad4953daa9d0b3e''),\n (9,x''7b713f3e5258323f80d1113d673b2b3f66e3583f''),\n (10,x''6ca1d43e9df91b3fe580da3e1c247d3f147cf33e'');\n\nSELECT id FROM v \n ORDER BY VEC_Distance_Euclidean(v, x''6ca1d43e9df91b3fe580da3e1c247d3f147cf33e'');\n+----+\n| id |\n+----+\n| 10 |\n| 7 |\n| 3 |\n| 9 |\n| 2 |\n| 1 |\n| 5 |\n| 4 |\n| 6 |\n| 8 |\n+----+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/vector-functions/vec_distance_euclidean', '', 'https://mariadb.com/docs/server/reference/sql-functions/vector-functions/vec_distance_euclidean'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (487, 35, 'VEC\\_FromText', 'Syntax\n------\n\nVEC_FromText(s)\n\nDescription\n-----------\n\nVEC_FromText converts a text representation of the vector (json array of numbers) to a vector (little-endian IEEE float sequence of bytes, 4 bytes per float).\n\nExamples\n--------\n\nSELECT HEX(vec_fromtext(''[1,2,3]'')); \n+------------------------------+\n| HEX(vec_fromtext(''[1,2,3]'')) |\n+------------------------------+\n| 0000803F0000004000004040 |\n+------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/vector-functions/vec_fromtext', '', 'https://mariadb.com/docs/server/reference/sql-functions/vector-functions/vec_fromtext'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (488, 35, 'VEC\\_ToText', 'Syntax\n------\n\nVEC_ToText(v)\n\nDescription\n-----------\n\nVEC_ToText converts a binary vector into a json array of numbers (floats). Returns NULL and throws a warning Error 4201 if given an invalid vector.\n\nExamples\n--------\n\nSELECT VEC_ToText(x''e360d63ebe554f3fcdbc523f4522193f5236083d'');\n+---------------------------------------------------------+\n| VEC_ToText(x''e360d63ebe554f3fcdbc523f4522193f5236083d'') |\n+---------------------------------------------------------+\n| [0.418708,0.809902,0.823193,0.598179,0.033255] |\n+---------------------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/vector-functions/vec_totext', '', 'https://mariadb.com/docs/server/reference/sql-functions/vector-functions/vec_totext'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (489, 35, 'VEC\\_DISTANCE', 'Syntax\n------\n\nVEC_DISTANCE(v, s)\n\nDescription\n-----------\n\nVEC_DISTANCE is a generic function that behaves either as VEC_DISTANCE_EUCLIDEAN, calculating the Euclidean (L2) distance between two points. Or VEC_DISTANCE_COSINE, calculating the Cosine distance between two vectors, depending on the underlying index type.\n\nIf the underlying index cannot be determined, an error 4206 is returned:\n\n``sql\nERROR 4206 (HY000): Cannot determine distance type for VEC_DISTANCE, index is not found\n``\n\nExamples\n--------\n\nINSERT INTO v VALUES \n (1, x''e360d63ebe554f3fcdbc523f4522193f5236083d''),\n (2, x''f511303f72224a3fdd05fe3eb22a133ffae86a3f''),\n (3,x''f09baa3ea172763f123def3e0c7fe53e288bf33e''),\n (4,x''b97a523f2a193e3eb4f62e3f2d23583e9dd60d3f''),\n (5,x''f7c5df3e984b2b3e65e59d3d7376db3eac63773e''),\n (6,x''de01453ffa486d3f10aa4d3fdd66813c71cb163f''),\n (7,x''76edfc3e4b57243f10f8423fb158713f020bda3e''),\n (8,x''56926c3fdf098d3e2c8c5e3d1ad4953daa9d0b3e''),\n (9,x''7b713f3e5258323f80d1113d673b2b3f66e3583f''),\n (10,x''6ca1d43e9df91b3fe580da3e1c247d3f147cf33e'');\n\nSELECT id FROM v \n ORDER BY VEC_DISTANCE(v, x''6ca1d43e9df91b3fe580da3e1c247d3f147cf33e'');\n+----+\n| id |\n+----+\n| 10 |\n| 7 |\n| 3 |\n| 9 |\n| 2 |\n| 1 |\n| 5 |\n| 4 |\n| 6 |\n| 8 |\n+----+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/vector-functions/vector-functions-vec_distance', '', 'https://mariadb.com/docs/server/reference/sql-functions/vector-functions/vector-functions-vec_distance'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (490, 35, 'SQL Statements', 'Description\n-----------\n\ndata-definition\n\ndata-manipulation\n\naccount-management-sql-statements\n\nadministrative-sql-statements\n\nsql-functions\n\nprepared-statements\n\nprogrammatic-compound-statements\n\nstored-routines\n\ntable-statements\n\ntransactions\n\ncomment-syntax.md\n\nhelp-command.md\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/README', '', 'https://mariadb.com/docs/server/reference/sql-statements/README'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (491, 10, 'ALTER USER', 'Syntax\n------\n\nALTER USER [IF EXISTS] \n user_specification [,user_specification] ...\n [REQUIRE {NONE | tls_option [[AND] tls_option] ...}]\n [WITH resource_option [resource_option] ...]\n [lock_option] [password_option] \n\nuser_specification:\n username [authentication_option]\n\nauthentication_option:\n IDENTIFIED BY ''password'' \n | IDENTIFIED BY PASSWORD ''password_hash''\n | IDENTIFIED {VIA|WITH} authentication_rule [OR authentication_rule] ... \n \nauthentication_rule:\n authentication_plugin\n | authentication_plugin {USING|AS} ''authentication_string''\n | authentication_plugin {USING|AS} PASSWORD(''password'')\n\ntls_option\n SSL \n | X509\n | CIPHER ''cipher''\n | ISSUER ''issuer''\n | SUBJECT ''subject''\n\nresource_option\n MAX_QUERIES_PER_HOUR COUNT\n | MAX_UPDATES_PER_HOUR COUNT\n | MAX_CONNECTIONS_PER_HOUR COUNT\n | MAX_USER_CONNECTIONS COUNT\n | MAX_STATEMENT_TIME TIME\n\npassword_option:\n PASSWORD EXPIRE\n | PASSWORD EXPIRE DEFAULT\n | PASSWORD EXPIRE NEVER\n | PASSWORD EXPIRE INTERVAL N DAY\n\nlock_option:\n ACCOUNT LOCK\n | ACCOUNT UNLOCK\n}\n\nDescription\n-----------\n\nThe ALTER USER statement modifies existing MariaDB accounts. To use it, you must have the global CREATE USER privilege or the UPDATE privilege for the mysql database. The global READ_ONLY ADMIN privilege is also required if the read_only system variable is enabled.\n\nIf any of the specified user accounts do not yet exist, an error results. If an error occurs, ALTER USER will still modify the accounts that do not result in an error. Only one error is produced for all users which have not been modified.\n\nFor renaming an existing account (user name and/or host), see RENAME USER.\n\nIF EXISTS\n\nWhen the IF EXISTS clause is used, MariaDB will return a warning instead of an error for each specified user that does not exist.\n\nAccount Names\n\nFor ALTER USER statements, account names are specified as the username argument in the same way as they are for CREATE USER statements. See account names from the CREATE USER page for details on how account names are specified.\n\nCURRENT_USER or CURRENT_USER() can also be used to alter the account logged into the current session. For example, to change the current user''s password to mariadb:\n\n``sql\nALTER USER CURRENT_USER() IDENTIFIED BY ''mariadb'';\n`\n\nAuthentication Options\n\nFrom MariaDB 10.4, it is possible to use more than one authentication plugin for each user account. For example, this can be useful to slowly migrate users to the more secure ed25519 authentication plugin over time, while allowing the old mysql_native_password authentication plugin as an alternative for the transitional period. See Authentication from MariaDB 10.4 for more.\n\nWhen running ALTER USER, not specifying an authentication option in the IDENTIFIED VIA clause will remove that authentication method. (However this was not the case before MariaDB 10.4.13, see MDEV-21928)\n\nFor example, a user is created with the ability to authenticate via both a password and unix_socket:\n\n`sql\nCREATE USER ''bob''@''localhost'' \n IDENTIFIED VIA mysql_native_password USING PASSWORD(''pwd'') \n OR unix_socket;\n\nSHOW CREATE USER ''bob''@''localhost''\\G\n`\n\n`\n************************ 1. row ***********************\nCREATE USER for bob@localhost: CREATE USER bob@localhost \n IDENTIFIED VIA mysql_native_password \n USING ''975B2CD4FF9AE554FE8AD33168FBFC326D2021DD'' \n OR unix_socket\n`\n\nIf the user''s password is updated, but unix_socket authentication is not specified in the IDENTIFIED VIA clause, unix_socket authentication will no longer be permitted.\n\n`sql\nALTER USER ''bob''@''localhost'' IDENTIFIED VIA mysql_native_password \n USING PASSWORD(''pwd2'');\n\nSHOW CREATE USER ''bob''@''localhost''\\G\n`\n\n`\n************************ 1. row ***********************\nCREATE USER for bob@localhost: CREATE USER bob@localhost \n IDENTIFIED BY PASSWORD ''38366FDA01695B6A5A9DD4E428D9FB8F7EB75512''\n`\n\nIDENTIFIED BY ''password''\n\nThe optional IDENTIFIED BY clause can be used to provide an account with a password. The password should be specified in plain text. It will be hashed by the PASSWORD function prior to being stored in the mysql.user view.\n\nFor example, if our password is mariadb, then we can set the account''s password with:\n\n`sql\nALTER USER foo2@test IDENTIFIED BY ''mariadb'';\n`\n\nIf you do not specify a password with the IDENTIFIED BY clause, the user\\\nwill be able to connect without a password. A blank password is not a wildcard\\\nto match any password. The user must connect without providing a password if no\\\npassword is set.\n\nThe only authentication plugins that this clause supports are mysql_native_password and mysql_old_password.\n\nIDENTIFIED BY PASSWORD ''password_hash''\n\nThe optional IDENTIFIED BY PASSWORD clause can be used to provide an account with a password that has already been hashed. The password should be specified as a hash that was provided by the PASSWORD#function. It will be stored in the mysql.user view as-is.\n\nFor example, if our password is mariadb, then we can find the hash with:\n\n`sql\nSELECT PASSWORD(''mariadb'');\n`\n\n`\n+-------------------------------------------+\n| PASSWORD(''mariadb'') |\n+-------------------------------------------+\n| 54958E764CE10E50764C2EECBB71D01F08549980 |\n+-------------------------------------------+\n`\n\nAnd then we can set an account''s password with the hash:\n\n`sql\nALTER USER foo2@test \n IDENTIFIED BY PASSWORD ''54958E764CE10E50764C2EECBB71D01F08549980'';\n`\n\nIf you do not specify a password with the IDENTIFIED BY clause, the user\\\nwill be able to connect without a password. A blank password is not a wildcard\\\nto match any password. The user must connect without providing a password if no password is set.\n\nThe only authentication plugins that this clause supports are mysql_native_password and mysql_old_password.\n\nIDENTIFIED {VIA|WITH} authentication_plugin\n\nThe optional IDENTIFIED VIA authentication_plugin allows you to specify that the account should be authenticated by a specific authentication plugin. The plugin name must be an active authentication plugin as per SHOW PLUGINS. If it doesn''t show up in that output, then you will need to install it with INSTALL PLUGIN or INSTALL SONAME.\n\nFor example, this could be used with the PAM authentication plugin:\n\n`sql\nALTER USER foo2@test IDENTIFIED VIA pam;\n`\n\nSome authentication plugins allow additional arguments to be specified after a USING or AS keyword. For example, the PAM authentication plugin accepts a service name:\n\n`sql\nALTER USER foo2@test IDENTIFIED VIA pam USING ''mariadb'';\n`\n\nThe exact meaning of the additional argument would depend on the specific authentication plugin.\n\nThe USING or AS keyword can also be used to provide a plain-text password to a plugin if it''s provided as an argument to the PASSWORD() function. This is only valid for authentication plugins that have implemented a hook for the PASSWORD() function. For example, the ed25519 authentication plugin supports this:\n\n`sql\nALTER USER safe@''%'' IDENTIFIED VIA ed25519 USING PASSWORD(''secret'');\n`\n\nThe USING or AS keyword cannot be used to provide a plain-text password to a plugin if it''s provided as an argument to the PASSWORD() function.\n\nTLS Options\n\nBy default, MariaDB transmits data between the server and clients without encrypting it. This is generally acceptable when the server and client run on the same host or in networks where security is guaranteed through other means. However, in cases where the server and client exist on separate networks or they are in a high-risk network, the lack of encryption does introduce security concerns as a malicious actor could potentially eavesdrop on the traffic as it is sent over the network between them.\n\nTo mitigate this concern, MariaDB allows you to encrypt data in transit between the server and clients using the Transport Layer Security (TLS) protocol. TLS was formerly known as Secure Socket Layer (SSL), but strictly speaking the SSL protocol is a predecessor to TLS and, that version of the protocol is now considered insecure. The documentation still uses the term SSL often and for compatibility reasons TLS-related server system and status variables still use the prefix ssl_, but internally, MariaDB only supports its secure successors.\n\nSee Secure Connections Overview for more information about how to determine whether your MariaDB server has TLS support.\n\nYou can set certain TLS-related restrictions for specific user accounts. For instance, you might use this with user accounts that require access to sensitive data while sending it across networks that you do not control. These restrictions can be enabled for a user account with the CREATE USER, ALTER USER, or GRANT statements. The following options are available:\n\n| Option | Description |\n| ------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| REQUIRE NONE | TLS is not required for this account, but can still be used. |\n| REQUIRE SSL | The account must use TLS, but no valid X509 certificate is required. This option cannot be combined with other TLS options. |\n| REQUIRE X509 | The account must use TLS and must have a valid X509 certificate. This option implies REQUIRE SSL. This option cannot be combined with other TLS options. |\n| REQUIRE ISSUER ''issuer'' | The account must use TLS and must have a valid X509 certificate. Also, the Certificate Authority must be the one specified via the string issuer. This option implies REQUIRE X509. This option can be combined with the SUBJECT, and CIPHER options in any order. |\n| REQUIRE SUBJECT ''subject'' | The account must use TLS and must have a valid X509 certificate. Also, the certificate''s Subject must be the one specified via the string subject. This option implies REQUIRE X509. This option can be combined with the ISSUER, and CIPHER options in any order. |\n| REQUIRE CIPHER ''cipher'' | The account must use TLS, but no valid X509 certificate is required. Also, the encryption used for the connection must use a specific cipher method specified in the string cipher. This option implies REQUIRE SSL. This option can be combined with the ISSUER, and SUBJECT options in any order. |\n\nThe REQUIRE keyword must be used only once for all specified options, and the AND keyword can be used to separate individual options, but it is not required.\n\nFor example, you can alter a user account to require these TLS options with the following:\n\n`sql\nALTER USER ''alice''@''%''\n REQUIRE SUBJECT ''/CN=alice/O=My Dom, Inc./C=US/ST=Oregon/L=Portland'' AND\n ISSUER ''/C=FI/ST=Somewhere/L=City/ O=Some Company/CN=Peter Parker/emailAddress=p.parker@marvel.com''\n AND CIPHER ''SHA-DES-CBC3-EDH-RSA'';\n`\n\nIf any of these options are set for a specific user account, then any client who tries to connect with that user account will have to be configured to connect with TLS.\n\nSee Securing Connections for Client and Server for information on how to enable TLS on the client and server.\n\nResource Limit Options\n\nIt is possible to set per-account limits for certain server resources. The following table shows the values that can be set per account:\n\n| Limit Type | Description |\n| --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| MAX_QUERIES_PER_HOUR | Number of statements that the account can issue per hour (including updates) |\n| MAX_UPDATES_PER_HOUR | Number of updates (not queries) that the account can issue per hour |\n| MAX_CONNECTIONS_PER_HOUR | Number of connections that the account can start per hour |\n| MAX_USER_CONNECTIONS | Number of simultaneous connections that can be accepted from the same account; if it is 0, max_connections will be used instead; if max_connections is 0, there is no limit for this account''s simultaneous connections. |\n| MAX_STATEMENT_TIME | Timeout, in seconds, for statements executed by the user. See also Aborting Statements that Exceed a Certain Time to Execute. |\n\nIf any of these limits are set to 0, then there is no limit for that resource for that user.\n\nHere is an example showing how to set an account''s resource limits:\n\n`sql\nALTER USER ''someone''@''localhost'' WITH\n MAX_USER_CONNECTIONS 10\n MAX_QUERIES_PER_HOUR 200;\n`\n\nThe resources are tracked per account, which means ''user''@''server''; not per user name or per connection.\n\nThe count can be reset for all users using FLUSH USER_RESOURCES, FLUSH PRIVILEGES or mysqladmin reload.\n\nPer account resource limits are stored in the user table, in the mysql database. Columns used for resources limits are named max_questions, max_updates, max_connections (for MAX_CONNECTIONS_PER_HOUR), and max_user_connections (for MAX_USER_CONNECTIONS).\n\nPassword Expiry\n\nBesides automatic password expiry, as determined by default_password_lifetime, password expiry times can be set on an individual user basis, overriding the global setting, for example:\n\n`sql\nALTER USER ''monty''@''localhost'' PASSWORD EXPIRE INTERVAL 120 DAY;\nALTER USER ''monty''@''localhost'' PASSWORD EXPIRE NEVER;\nALTER USER ''monty''\n\n[Truncated — full content at mariadb.com/docs]', '', 'https://mariadb.com/docs/server/reference/sql-statements/account-management-sql-statements/alter-user'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (492, 10, 'CREATE ROLE', 'Description\n-----------\n\nThe CREATE ROLE statement creates one or more MariaDB roles. To use it, you must have the global CREATE USER privilege or the INSERT privilege for the mysql database. For each account, CREATE ROLE creates a new row in the mysql.user table that has no privileges, and with the corresponding is_role field set to Y. It also creates a record in the mysql.roles_mapping table.\n\nIf any of the specified roles already exist, ERROR 1396 (HY000) results. If an error occurs, CREATE ROLE will still create the roles that do not result in an error. The maximum length for a role is 128 characters. Role names can be quoted, as explained in the Identifier names page. Only one error is produced for all roles which have not been created:\n\n``\nERROR 1396 (HY000): Operation CREATE ROLE failed for ''a'',''b'',''c''\n`\n\nFailed CREATE or DROP operations, for both users and roles, produce the same error code.\n\nPUBLIC and NONE are reserved, and cannot be used as role names. NONE is used to unset a role and PUBLIC has a special use in other systems, such as Oracle, so is reserved for compatibility purposes.\n\nFor valid identifiers to use as role names, see Identifier Names.\n\nWITH ADMIN\n\nThe optional WITH ADMIN clause determines whether the current user, the current role or another user or role has use of the newly created role. If the clause is omitted, WITH ADMIN CURRENT_USER` is treated as the default, which means that the current user will be able to GRANT this role to users.\n\nExamples\n--------\n\nCREATE ROLE developer WITH ADMIN lorinda@localhost;\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/account-management-sql-statements/create-role', '', 'https://mariadb.com/docs/server/reference/sql-statements/account-management-sql-statements/create-role'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (493, 10, 'CREATE USER', 'Description\n-----------\n\nThe CREATE USER statement creates new MariaDB accounts. To use it, you must have the global CREATE USER privilege or the INSERT privilege for the mysql database.\n\nFor each account, CREATE USER creates a new row in the mysql.user view (and the underlying mysql.global_priv table) that has no privileges.\n\nFor each account, CREATE USER creates a new row in mysql.user table that has no privileges.\n\nIf any of the specified accounts, or any permissions for the specified accounts, already exist, then the server returns ERROR 1396 (HY000). If an error occurs, CREATE USER will still create the accounts that do not result in an error. Only one error is produced for all users which have not been created:\n\n``\nERROR 1396 (HY000): \n Operation CREATE USER failed for ''u1''@''%'',''u2''@''%''\n`\n\nCREATE USER, DROP USER, CREATE ROLE, and DROP ROLE all produce the same error code when they fail.\n\nSee Account Names below for details on how account names are specified.\n\nOne can also create users with GRANT if SQL_MODE does not have NO_AUTO_CREATE_USER set. NO_AUTO_CREATE_USER is set by default.\n\nOR REPLACE\n\nIf the optional OR REPLACE clause is used, it is basically a shortcut for:\n\n`sql\nDROP USER IF EXISTS name;\nCREATE USER name ...;\n`\n\nFor example:\n\n`sql\nCREATE USER foo2@test IDENTIFIED BY ''password'';\nERROR 1396 (HY000): Operation CREATE USER failed for ''foo2''@''test''\n\nCREATE OR REPLACE USER foo2@test IDENTIFIED BY ''password'';\nQuery OK, 0 rows affected (0.00 sec)\n`\n\nIF NOT EXISTS\n\nWhen the IF NOT EXISTS clause is used, MariaDB will return a warning instead of an error if the specified user already exists.\n\nFor example:\n\n`sql\nCREATE USER foo2@test IDENTIFIED BY ''password'';\nERROR 1396 (HY000): Operation CREATE USER failed for ''foo2''@''test''\n\nCREATE USER IF NOT EXISTS foo2@test IDENTIFIED BY ''password'';\nQuery OK, 0 rows affected, 1 warning (0.00 sec)\n\nSHOW WARNINGS;\n+-------+------+----------------------------------------------------+\n| Level | Code | Message |\n+-------+------+----------------------------------------------------+\n| Note | 1973 | Can''t create user ''foo2''@''test''; it already exists |\n+-------+------+----------------------------------------------------+\n`\n\nAuthentication Options\n\nIf more than one authentication mechanism is declared using the OR keyword, the mechanisms are attempted in the order they are declared in the CREATE USER statement. As soon as one of the authentication mechanisms is successful, authentication is complete. If none of them is successful, the authentication has failed.\n\nIDENTIFIED BY ''password''\n\nThe optional IDENTIFIED BY clause can be used to provide an account with a password. The password should be specified in plain text. It will be hashed by the PASSWORD function prior to being stored in the mysql.user/mysql.global_priv_table table.\n\nFor example, if our password is mariadb, then we can create the user with:\n\n`sql\nCREATE USER foo2@test IDENTIFIED BY ''mariadb'';\n`\n\nIf you do not specify a password with the IDENTIFIED BY clause, the user\\\nwill be able to connect without a password. A blank password is not a wildcard\\\nto match any password. The user must connect without providing a password if no\\\npassword is set.\n\nThe only authentication plugins that this clause supports are mysql_native_password and mysql_old_password.\n\nIDENTIFIED BY PASSWORD ''password_hash''\n\nThe optional IDENTIFIED BY PASSWORD clause can be used to provide an account with a password that has already been hashed. The password should be specified as a hash that was provided by the PASSWORD function. It will be stored in the mysql.user/mysql.global_priv_table table as-is.\n\nFor example, if our password is mariadb, then we can find the hash with:\n\n`sql\nSELECT PASSWORD(''mariadb'');\n+-------------------------------------------+\n| PASSWORD(''mariadb'') |\n+-------------------------------------------+\n| 54958E764CE10E50764C2EECBB71D01F08549980 |\n+-------------------------------------------+\n1 row in set (0.00 sec)\n`\n\nAnd then we can create a user with the hash:\n\n`sql\nCREATE USER foo2@test IDENTIFIED BY PASSWORD ''54958E764CE10E50764C2EECBB71D01F08549980'';\n`\n\nIf you do not specify a password with the IDENTIFIED BY clause, the user will be able to connect without a password. A blank password is not a wildcard to match any password. The user must connect without providing a password if no password is set.\n\nThe only authentication plugins that this clause supports are mysql_native_password and mysql_old_password.\n\nIDENTIFIED {VIA|WITH} authentication_plugin\n\nThe optional IDENTIFIED VIA authentication_plugin allows you to specify that the account should be authenticated by a specific authentication plugin. The plugin name must be an active authentication plugin as per SHOW PLUGINS. If it doesn''t show up in that output, then you will need to install it with INSTALL PLUGIN or INSTALL SONAME.\n\nVIA and WITH are synonyms.\n\nFor example, this could be used with the PAM authentication plugin:\n\n`sql\nCREATE USER foo2@test IDENTIFIED VIA pam;\n`\n\nSome authentication plugins allow additional arguments to be specified after a USING or AS keyword. For example, the PAM authentication plugin accepts a service name:\n\n`sql\nCREATE USER foo2@test IDENTIFIED VIA pam USING ''mariadb'';\n`\n\nThe exact meaning of the additional argument would depend on the specific authentication plugin.\n\nThe USING or AS keyword can also be used to provide a plain-text password to a plugin if it''s provided as an argument to the PASSWORD() function. This is only valid for authentication plugins that have implemented a hook for the PASSWORD() function. For example, the ed25519 authentication plugin supports this:\n\n`sql\nCREATE USER safe@''%'' IDENTIFIED VIA ed25519 USING PASSWORD(''secret'');\n`\n\nOne can specify many authentication plugins, they all work as alternatives ways of authenticating a user:\n\n`sql\nCREATE USER safe@''%'' IDENTIFIED VIA ed25519 USING PASSWORD(''secret'') OR unix_socket;\n`\n\nBy default, when you create a user without specifying an authentication plugin, MariaDB uses the mysql_native_password plugin.\n\nTLS Options\n\nMariaDB allows you to encrypt data in transit between the server and clients using the Transport Layer Security (TLS) protocol. TLS was formerly known as Secure Socket Layer (SSL), but strictly speaking the SSL protocol is a predecessor to TLS and, that version of the protocol is now considered insecure. The documentation still uses the term SSL often and for compatibility reasons TLS-related server system and status variables still use the prefix ssl_, but internally, MariaDB only supports its secure successors.\n\nBy default, MariaDB transmits data between the server and clients without encrypting it. This is generally acceptable when the server and client run on the same host or in networks where security is guaranteed through other means. However, in cases where the server and client exist on separate networks or they are in a high-risk network, the lack of encryption does introduce security concerns as a malicious actor could potentially eavesdrop on the traffic as it is sent over the network between them.\n\nTo mitigate this concern, MariaDB allows you to encrypt data in transit between the server and clients using the Transport Layer Security (TLS) protocol. TLS was formerly known as Secure Socket Layer (SSL), but strictly speaking the SSL protocol is a predecessor to TLS and, that version of the protocol is now considered insecure. The documentation still uses the term SSL often and for compatibility reasons TLS-related server system and status variables still use the prefix ssl_, but internally, MariaDB only supports its secure successors.\n\nSee Secure Connections Overview for more information about how to determine whether your MariaDB server has TLS support.\n\nYou can set certain TLS-related restrictions for specific user accounts. For instance, you might use this with user accounts that require access to sensitive data while sending it across networks that you do not control. These restrictions can be enabled for a user account with the CREATE USER, ALTER USER, or GRANT statements. The following options are available:\n\n| Option | Description |\n| ------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| REQUIRE NONE | TLS is not required for this account, but can still be used. |\n| REQUIRE SSL | The account must use TLS, but no valid X509 certificate is required. This option cannot be combined with other TLS options. |\n| REQUIRE X509 | The account must use TLS and must have a valid X509 certificate. This option implies REQUIRE SSL. This option cannot be combined with other TLS options. |\n| REQUIRE ISSUER ''issuer'' | The account must use TLS and must have a valid X509 certificate. Also, the Certificate Authority must be the one specified via the string issuer. This option implies REQUIRE X509. This option can be combined with the SUBJECT, and CIPHER options in any order. |\n| REQUIRE SUBJECT ''subject'' | The account must use TLS and must have a valid X509 certificate. Also, the certificate''s Subject must be the one specified via the string subject. This option implies REQUIRE X509. This option can be combined with the ISSUER, and CIPHER options in any order. |\n| REQUIRE CIPHER ''cipher'' | The account must use TLS, but no valid X509 certificate is required. Also, the encryption used for the connection must use a specific cipher method specified in the string cipher. This option implies REQUIRE SSL. This option can be combined with the ISSUER, and SUBJECT options in any order. |\n\nThe REQUIRE keyword must be used only once for all specified options, and the AND keyword can be used to separate individual options, but it is not required.\n\nFor example, you can create a user account that requires these TLS options with the following:\n\n`sql\nCREATE USER ''alice''@''%''\n REQUIRE SUBJECT ''/CN=alice/O=My Dom, Inc./C=US/ST=Oregon/L=Portland''\n AND ISSUER ''/C=FI/ST=Somewhere/L=City/ O=Some Company/CN=Peter Parker/emailAddress=p.parker@marvel.com''\n AND CIPHER ''SHA-DES-CBC3-EDH-RSA'';\n`\n\nIf any of these options are set for a specific user account, then any client who tries to connect with that user account will have to be configured to connect with TLS.\n\nSee Securing Connections for Client and Server for information on how to enable TLS on the client and server.\n\nResource Limit Options\n\nIt is possible to set per-account limits for certain server resources. The following table shows the values that can be set per account:\n\n| Limit Type | Decription |\n| --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| MAX_QUERIES_PER_HOUR | Number of statements that the account can issue per hour (including updates) |\n| MAX_UPDATES_PER_HOUR | Number of updates (not queries) that the account can issue per hour |\n| MAX_CONNECTIONS_PER_HOUR | Number of connections that the account can start per hour |\n| MAX_USER_CONNECTIONS | Number of simultaneous connections that can be accepted from the same account; if it is 0, max_connections will be used instead; if max_connections is 0, there is no limit for this account''s simultaneous connections. |\n| MAX_STATEMENT_TIME | Timeout, in seconds, for statements executed by the user. See also Aborting Statements that Exceed a Certain Time to Execute. |\n\nIf any of these limits are set to 0, then there is no limit for that resource for that user.\n\nHere is an example showing how to create a user with resource limits:\n\n`sql\nCREATE USER ''someone''@''localhost'' WITH\n MAX_USER_CONNECTIONS 10\n MAX_QUERIES_PER_HOUR 200;\n`\n\nThe resources are tracked per account, which means ''user''@''server''; not per user name or per connection.\n\nThe count can be reset for all users using FLUSH USER_RESOURCES, FLUSH PRIVILEGES or mariadb-admin reload.\n\nPer account resource limits are stored in the user table, in the mysql database. Columns used for resources limits are named max_questions, max_updates, max_connections (for MAX_CONNECTIONS_PER_HOUR), and max_user_connections (for MAX_USER_CONNECTIONS).\n\nAccount Names\n\nAccount names have both a user name component and a host name component, and are specified as ''user_name''@''host_name''.\n\nThe user name and host name may be unquoted, quoted as strings using double quotes (") or\\\nsingle quotes (''), or quoted as identifiers using backticks (\\\\\\). You must use quotes\\\nwhen using special characters (such as a hyphen) or wildcard characters. If you quote, you\\\nmust quote the user name and host name separately (for example ''user_name''@''host_name'').\n\nHost Name Component\n\nIf the host name is not provided, it is assumed to be ''%''.\n\nHost names may contain the wildcard characters % and _. They are matched as if by\\\nthe LIKE clause. If you need to use a wildcard character literally (for example, to\\\nmatch a domain name with an underscore), prefix the character with a backslash. See LIKE\\\n\n[Truncated — full content at mariadb.com/docs]', '', 'https://mariadb.com/docs/server/reference/sql-statements/account-management-sql-statements/create-user'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (494, 10, 'DROP ROLE', 'Description\n-----------\n\nThe DROP ROLE statement removes one or more MariaDB roles. To use this statement, you must have the global CREATE USER privilege or the DELETE privilege for the mysql database.\n\nDROP ROLE does not disable roles for connections which selected them with SET ROLE. If a role has previously been set as a default role, DROP ROLE does not remove the record of the default role from the mysql.user table. If the role is subsequently recreated and granted, it will again be the user''s default. Use SET DEFAULT ROLE NONE to explicitly remove this.\n\nIf any of the specified user accounts do not exist, ERROR 1396 (HY000)results. If an error occurs, DROP ROLE will still drop the roles that do not result in an error. Only one error is produced for all roles which have not been dropped:\n\n``bnf\nERROR 1396 (HY000): Operation DROP ROLE failed for ''a'',''b'',''c''\n`\n\nFailed CREATE or DROP operations, for both users and roles, produce the same error code.\n\nIF EXISTS\n\nIf the IF EXISTS` clause is used, MariaDB will return a warning instead of an error if the role does not exist.\n\nExamples\n--------\n\nDROP ROLE journalist;\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/account-management-sql-statements/drop-role', '', 'https://mariadb.com/docs/server/reference/sql-statements/account-management-sql-statements/drop-role'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (495, 10, 'DROP USER', 'Syntax\n------\n\nDROP USER [IF EXISTS] user_name [, user_name] ... [FORCE]\n\nDescription\n-----------\n\nThe DROP USER statement removes one or more MariaDB accounts. It removes privilege rows for the account from all grant tables. To use this statement, you must have the global CREATE USER privilege or the DELETE privilege for the mysql database. Each account is named using the same format as for the CREATE USER statement; for example, ''jeffrey''@''localhost''. If you specify only the user name part of the account name, a host name part of ''%'' is used. For additional information about specifying account names, see CREATE USER.\n\nIf you specify an account that is currently connected, it is deleted, but the statement completes with a warning:\n\n``sql\nDropped users ''user''@''host[,...]'' have active connections. Use KILL CONNECTION if they should not be used anymore.\n`\n\nThis means that the user account with all its privileges is still active until the connection is terminated. As the warning implies, use a KILL CONNECTION statement to terminate a connection, or (more proactively) use the FORCE clause to forcibly close connections of the users named in the DROP USER statement. This ends connections, and immediately deletes the users.\n\nIn Oracle mode, if a user is connected, the DROP USER statement fails with an error:\n\n`sql\nOperation DROP USER failed for ''foo''@''localhost''.\n`\n\nAgain, use the FORCE clause to prevent that error.\n\nIf you specify an account that is currently connected, it is not deleted until the connection is closed. The connection is not automatically closed.\n\nHowever, a deleted user cannot initiate new connections any more.\n\nIf any of the specified user accounts do not exist, ERROR 1396 (HY000) results. If an error occurs, DROP USER still drops the accounts that do not result in an error. Only one error is produced for all users which have not been dropped:\n\n`bnf\nERROR 1396 (HY000): Operation DROP USER failed for ''u1''@''%'',''u2''@''%''\n`\n\nFailed CREATE or DROP operations, for both users and roles, produce the same error.\n\nIF EXISTS\n\nIf the IF EXISTS clause is used, MariaDB returns a note instead of an error if the user does not exist.\n\nThe CREATE USER statement creates new MariaDB accounts. To use it, you must have the global CREATE USER privilege or the INSERT privilege for the mysql database.\n\nIf the IF EXISTS` clause is used, MariaDB returns a note instead of an error if the user does not exist.\n\nExamples\n--------\n\nDROP USER bob;\n\nDROP USER foo2@localhost,foo2@''127.%'';\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/account-management-sql-statements/drop-user', '', 'https://mariadb.com/docs/server/reference/sql-statements/account-management-sql-statements/drop-user'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (496, 10, 'GRANT', 'Description\n-----------\n\nThe GRANT statement allows you to grant privileges or roles to accounts. To use GRANT, you must have the GRANT OPTION privilege, and you must have the privileges that you are granting.\n\nUse the REVOKE statement to revoke privileges granted with the GRANT statement.\n\nUse the SHOW GRANTS statement to determine what privileges an account has.\n\nAccount Names\n\nFor GRANT statements, account names are specified as the username argument in the same way as they are for CREATE USER statements. See account names from the CREATE USER page for details on how account names are specified.\n\nImplicit Account Creation\n\nThe GRANT statement also allows you to implicitly create accounts in some cases.\n\nIf the account does not yet exist, then GRANT can implicitly create it. To implicitly create an account with GRANT, a user is required to have the same privileges that would be required to explicitly create the account with the CREATE USER statement.\n\nIf the NO_AUTO_CREATE_USER SQL_MODE is set, then accounts can only be created if authentication information is specified, or with a CREATE USER statement. If no authentication information is provided, GRANT will produce an error when the specified account does not exist, for example:\n\n``sql\nSHOW VARIABLES LIKE ''%sql_mode%'' ;\n`\n\n
+---------------+--------------------------------------------+\n| Variable_name | Value                                      |\n+---------------+--------------------------------------------+\n| sql_mode      | NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION |\n+---------------+--------------------------------------------+\n
\n\n`sql\nGRANT USAGE ON . TO ''user123''@''%'' IDENTIFIED BY '''';\n`\n\n`\nERROR 1133 (28000): Can''t find any matching row in the user table\n`\n\n`sql\nGRANT USAGE ON . TO ''user123''@''%'' \n IDENTIFIED VIA PAM using ''mariadb'' require ssl ;\nQuery OK, 0 rows affected (0.00 sec)\n`\n\n`sql\nSELECT host, user FROM mysql.user WHERE user=''user123'' ;\n`\n\n`\n+------+----------+\n| host | user |\n+------+----------+\n| % | user123 |\n+------+----------+\n`\n\nPrivilege Levels\n\nPrivileges can be set globally, for an entire database, for a table or routine, or for individual columns in a table. Certain privileges can only be set at certain levels.\n\nGlobal privileges do not take effect immediately and are only applied to connections created after the GRANT statement was executed.\n\n Global privileges priv_type are granted using . for priv_level. Global privileges include privileges to administer the database and manage user accounts, as well as privileges for all tables, functions, and procedures. Global privileges are stored in mysql.global_priv table.\n Database privileges priv_type are granted using db_name. for priv_level, or using just to use the current database. Database privileges include privileges to create tables and functions, as well as privileges for all tables, functions, and procedures in the database. Database privileges are stored in the mysql.db table.\n Table privileges priv_type are granted using db_name.tbl_namefor priv_level, or using just tbl_name to specify a table in the current database. The TABLE keyword is optional. Table privileges include the ability to select and change data in the table. Certain table privileges can be granted for individual columns.\n Column privileges priv_type are granted by specifying a table for priv_level and providing a column list after the privilege type. They allow you to control exactly which columns in a table users can select and change.\n Function privileges priv_type are granted using FUNCTION db_name.routine_name for priv_level, or using just FUNCTION routine_name to specify a function in the current database.\n Procedure privileges priv_type are granted using PROCEDURE db_name.routine_name for priv_level, or using just PROCEDURE routine_name to specify a procedure in the current database.\n\nThe USAGE Privilege\n\nThe USAGE privilege grants no real privileges. The SHOW GRANTS statement will show a global USAGE privilege for a newly-created user. You can use USAGE with the GRANT statement to change options like GRANT OPTIONand MAX_USER_CONNECTIONS without changing any account privileges.\n\nThe ALL PRIVILEGES Privilege\n\nThe ALL PRIVILEGES privilege grants all available privileges. Granting all privileges only affects the given privilege level. For example, granting all privileges on a table does not grant any privileges on the database or globally.\n\nUsing ALL PRIVILEGES does not grant the special GRANT OPTION privilege.\n\nYou can use ALL instead of ALL PRIVILEGES.\n\nThe GRANT OPTION Privilege\n\nUse the WITH GRANT OPTION clause to give users the ability to grant privileges to other users at the given privilege level. Users with the GRANT OPTION privilege can only grant privileges they have. They cannot grant privileges at a higher privilege level than they have the GRANT OPTION privilege.\n\nThe GRANT OPTION privilege cannot be set for individual columns. If you use WITH GRANT OPTION when specifying column privileges, the GRANT OPTION privilege will be granted for the entire table.\n\nUsing the WITH GRANT OPTION clause is equivalent to listing GRANT OPTION as a privilege.\n\nGlobal Privileges\n\nThe following table lists the privileges that can be granted globally. You can also grant all database, table, and function privileges globally. When granted globally, these privileges apply to all databases, tables, or functions, including those created later.\n\nTo set a global privilege, use . for _priv_level_.\n\nBINLOG ADMIN\n\nEnables administration of the binary log, including the PURGE BINARY LOGS statement and setting the system variables:\n\n binlog_annotate_row_events\n binlog_cache_size\n binlog_commit_wait_count\n binlog_commit_wait_usec\n binlog_direct_non_transactional_updates\n binlog_expire_logs_seconds\n binlog_file_cache_size\n binlog_format\n binlog_row_image\n binlog_row_metadata\n binlog_stmt_cache_size\n expire_logs_days\n log_bin_compress\n log_bin_compress_min_len\n log_bin_trust_function_creators\n max_binlog_cache_size\n max_binlog_size\n max_binlog_stmt_cache_size\n sql_log_bin and\n sync_binlog.\n\nBINLOG ADMIN isn''t available.\n\nBINLOG MONITOR\n\nNew name for REPLICATION CLIENT. REPLICATION CLIENT can still be used, though.\n\nUse REPLICATION CLIENT instead. SHOW REPLICA STATUS isn''t included in this privilege, and REPLICA MONITOR is required.\n\nPermits running SHOW commands related to the binary log, in particular the SHOW BINLOG STATUS and SHOW BINARY LOGS statements.\n\nBINLOG REPLAY\n\nEnables replaying the binary log with the BINLOG statement (generated by mariadb-binlog), executing SET timestamp when secure_timestamp is set to replication, and setting the session values of system variables usually included in BINLOG output, in particular:\n\n gtid_domain_id\n gtid_seq_no\n pseudo_thread_id\n server_id.\n\nBINLOG REPLAY isn''t available.\n\nCONNECTION ADMIN\n\nEnables administering connection resource limit options. This includes ignoring the limits specified by max_user_connections and max_password_errors, and allowing one extra connection over max_connections\n\nThe statements specified in init_connect are not executed, killing connections and queries owned by other users is permitted. The following connection-related system variables can be changed:\n\n connect_timeout\n disconnect_on_expired_password\n extra_max_connections\n init_connect\n max_connections\n max_connect_errors\n max_password_errors\n proxy_protocol_networks\n secure_auth\n slow_launch_time\n thread_pool_exact_stats\n thread_pool_dedicated_listener\n thread_pool_idle_timeout\n thread_pool_max_threads\n thread_pool_min_threads\n thread_pool_oversubscribe\n thread_pool_prio_kickup_timer\n thread_pool_priority\n thread_pool_size, and\n thread_pool_stall_limit.\n\nCREATE USER\n\nCreate a user using the CREATE USER statement, or implicitly create a user with the GRANT statement.\n\nFEDERATED ADMIN\n\nExecute CREATE SERVER, ALTER SERVER, and DROP SERVER statements.\n\nFEDERATED ADMIN is not available.\n\nFILE\n\nRead and write files on the server, using statements like LOAD DATA INFILE or functions like LOAD_FILE(). Also needed to create CONNECT outward tables. MariaDB server must have the permissions to access those files.\n\nGRANT OPTION\n\nGrant global privileges. You can only grant privileges that you have.\n\nPROCESS\n\nShow information about the active processes, for example via SHOW PROCESSLIST or mariadb-admin processlist. If you have the PROCESS privilege, you can see all threads. Otherwise, you can see only your own threads (that is, threads associated with the MariaDB account that you are using).\n\nREAD_ONLY ADMIN\n\nUser ignores the read_only system variable, and can perform write operations even when the read_only option is active.\n\nA user with that privilege can also change the (global) value of read_only.\n\nThe READ_ONLY ADMIN privilege has been removed from SUPER. The benefit of this is that one can remove the READ_ONLY ADMIN privilege from all users and ensure that no one can make any changes on any non-temporary tables. This is useful on replicas when one wants to ensure that the replica is kept identical to the primary.\n\nUser ignores the read_only system variable, and can perform write operations even when the read_only option is active.\n\nA user with that privilege can also change the (global) value of read_only.\n\nThe READ_ONLY ADMIN privilege is included in SUPER.\n\nREAD_ONLY ADMIN isn''t available.\n\nRELOAD\n\nExecute FLUSH statements or equivalent mariadb-admin commands.\n\nREPLICATION CLIENT\n\nExecute SHOW MASTER STATUS and SHOW BINARY LOGS informative statements. Renamed to BINLOG MONITOR (but still supported as an alias for compatibility reasons).\n\nExecute SHOW MASTER STATUS and SHOW BINARY LOGS informative statements. SHOW SLAVE STATUS is part of REPLICATION CLIENT.\n\nExecute SHOW MASTER STATUS and SHOW BINARY LOGS informative statements. Using BINLOG MONITOR instead is still supported as an alias.\n\nExecute SHOW MASTER STATUS and SHOW BINARY LOGS informative statements. Renamed to BINLOG MONITOR in MariaDB 10.5.2 (but still supported as an alias for compatibility reasons). SHOW SLAVE STATUS was part of REPLICATION CLIENT prior to MariaDB 10.5.\n\nREPLICATION MASTER ADMIN\n\nPermits administration of primary servers, including the SHOW REPLICA HOSTS statement, and setting the gtid_binlog_state, gtid_domain_id, master_verify_checksum and server_id system variables.\n\nREPLICATION MASTER ADMIN is not available.\n\nREPLICA MONITOR\n\nPermit SHOW REPLICA STATUS and SHOW RELAYLOG EVENTS.\n\nSee _Reasoning_ tab as to why this was implemented.\n\nWhen a user would upgrade from an older major release to a MariaDB 10.5 minor release prior to MariaDB 10.5.9, certain user accounts would lose capabilities. For example, a user account that had the REPLICATION CLIENT privilege in older major releases could run SHOW REPLICA STATUS, but after upgrading to a MariaDB 10.5 minor release prior to MariaDB 10.5.9, they could no longer run SHOW REPLICA STATUS, because that statement was changed to require the REPLICATION REPLICA ADMIN privilege.\n\nThis issue is fixed in MariaDB 10.5.9 with this new privilege, which now grants the user the ability to execute SHOW [ALL] (SLAVE | REPLICA) STATUS.\n\nWhen a database is upgraded from an older major release to MariaDB Server 10.5.9 or later, any user accounts with the REPLICATION CLIENT or REPLICATION SLAVE privileges will automatically be granted the new REPLICA MONITOR privilege. The privilege fix occurs when the server is started up, not when mariadb-upgrade is performed.\n\nHowever, when a database is upgraded from an early 10.5 minor release to 10.5.9 and later, the user will have to fix any user account privileges manually.\n\nREPLICA MONITOR is not available.\n\nREPLICATION REPLICA\n\nSynonym for REPLICATION SLAVE.\n\nREPLICATION REPLICA is not available.\n\nREPLICATION SLAVE\n\nAccounts used by replica servers on the primary need this privilege. This is needed to get the updates made on the master. REPLICATION REPLICA is an alias for REPLICATION SLAVE.\n\nAccounts used by replica servers on the primary need this privilege. This is needed to get the updates made on the master.\n\nREPLICATION SLAVE ADMIN\n\nPermits administering replica servers, including START REPLICA/SLAVE, STOP REPLICA/SLAVE, CHANGE MASTER, SHOW REPLICA/SLAVE STATUS, SHOW RELAYLOG EVENTS statements, replaying the binary log with the BINLOG statement (generated by mariadb-binlog), and setting the system variables:\n\n gtid_cleanup_batch_size\n gtid_ignore_duplicates\n gtid_pos_auto_engines\n gtid_slave_pos\n gtid_strict_mode\n init_slave\n read_binlog_speed_limit\n relay_log_purge\n relay_log_recovery\n replicate_do_db\n replicate_do_table\n replicate_events_marked_for_skip\n replicate_ignore_db\n replicate_ignore_table\n replicate_wild_do_table\n replicate_wild_ignore_table\n slave_compressed_protocol\n slave_ddl_exec_mode\n slave_domain_parallel_threads\n slave_exec_mode\n slave_max_allowed_packet\n slave_net_timeout\n slave_parallel_max_queued\n slave_parallel_mode\n slave_parallel_threads\n slave_parallel_workers\n slave_run_triggers_for_rbr\n slave_sql_verify_checksum\n slave_transaction_retry_interval\n slave_type_conversions\n sync_master_info\n sync_relay_log, and\n sync_relay_log_info.\n\nREPLICATION SLAVE ADMIN is not available.\n\nSET USER\n\nEnables setting the DEFINER when creating triggers, views, stored functions and stored procedures.\n\nSET USER isn''t available.\n\nSHOW DATABASES\n\nList all databases using the SHOW DATABASES statement. Without the SHOW DATABASES privilege, you can still issue the SHOW DATABASES statement, but it will only list databases containing tables on which you have privileges.\n\nSHUTDOWN\n\nShut down the server using SHUTDOWN or the mariadb-admin shutdown command.\n\nSUPER\n\nExecute superuser statements: CHANGE MASTER TO, KILL (users who do not have this privilege can only KILL their own threads), PURGE LOGS, SET global system variables, or the mariadb-admin debug command. Also, this permission allows the user to write data even if the read_only startup option is set, enable or disable logging, enable or disable replication on replica, specify a DEFINER for statements that support that clause, connect once reaching the MAX_CONNECTIONS. If a statement has been specified for the init-connect mariadbd option, that command will not be executed when a user with SUPER privileges connects to the server.\n\nThe SUPER privilege has been split into multiple smaller privileges to allow for more fine-grained privileges (MDEV-21743). The privileges are:\n\n SET USER\n FEDERATED ADMIN\n CONNECTION ADMIN\n REPLICATION SLAVE ADMIN\n BINLOG ADMIN\n BINLOG REPLAY\n REPLICA MONITOR\n BINLOG MONITOR\n REPLICATION MASTER ADMIN\n READ_ONLY ADMIN\n\nThese grants are no longer a part of SUPER and need to be granted separately.\n\nThe READ_ONLY ADMIN privilege has been removed from SUPER. The benefit of this is that one can remove the READ_ONLY ADMIN privilege from all users and ensure that no one can make any changes on any non-temporary tables. This is useful on\n\n[Truncated — full content at mariadb.com/docs]', '', 'https://mariadb.com/docs/server/reference/sql-statements/account-management-sql-statements/grant'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (497, 10, 'RENAME USER', 'Description\n-----------\n\nThe RENAME USER statement renames existing MariaDB accounts. To use it, you must have the global CREATE USER privilege or the UPDATE privilege for the mysql database. Each account is named using the same format as for the CREATE USER statement; for example, ''jeffrey''@''localhost''.\\\nIf you specify only the user name part of the account name, a host name part of ''%'' is used.\n\nIf any of the old user accounts do not exist or any of the new user accounts already exist, ERROR 1396 (HY000) results. If an error occurs, RENAME USERwill still rename the accounts that do not result in an error.\n\nFor modifying an existing account, see ALTER USER.\n\nExamples\n--------\n\nCREATE USER ''donald'', ''mickey'';\nRENAME USER ''donald'' TO ''duck''@''localhost'', ''mickey'' TO ''mouse''@''localhost'';\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/account-management-sql-statements/rename-user', '', 'https://mariadb.com/docs/server/reference/sql-statements/account-management-sql-statements/rename-user'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (498, 10, 'REVOKE', 'Description\n-----------\n\nThe REVOKE statement enables system administrators to revoke privileges (or roles - see section below) from MariaDB accounts. Each account is named using the same format as for the GRANT statement; for example, jeffrey@localhost. If you specify only the user name part of the account name, a host name part of % is used. For details on the levels at which privileges exist, the available priv_type and priv_level values, and the syntax for specifying users and passwords, see GRANT.\n\nTo use the first syntax (REVOKE ... ON ... FROM ...), you must have the GRANT OPTION privilege, and you must have the privileges that you are revoking. Also, remember to specify the ON clause (in many cases, ON . to revoke privileges for all objects):\n\n``sql\nREVOKE ALL ON . FROM ''myuser''@''localhost'';\n`\n\nThis leaves the USAGE privilege, and can leave other privileges, too. For that reason, the second syntax (REVOKE ALL PRIVILEGES, GRANT OPTION FROM ...) is preferable, which drops all global, database, table, column, and routine privileges for the named user or users:\n\n`sql\nREVOKE ALL PRIVILEGES, GRANT OPTION FROM user [, user] ...\n`\n\nTo use this REVOKE syntax, you must have the global CREATE USER privilege or the UPDATE privilege for the mysql database. See GRANT. For that syntax, the ON . clause must not be used (it yields an error).\n\nRevoking all privileges doesn''t remove _all_ privileges, not even with the second syntax. The user still keeps the USAGE privilege, making it possible to connect to the server (but nothing else). To remove that privilege, too, remove the user entirely with a DROP USER` statement.\n\nExamples\n--------\n\nREVOKE SUPER ON . FROM ''myuser''@''localhost'';\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/account-management-sql-statements/revoke', '', 'https://mariadb.com/docs/server/reference/sql-statements/account-management-sql-statements/revoke'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (499, 10, 'SET DEFAULT ROLE', 'Description\n-----------\n\nThe SET DEFAULT ROLE statement sets a default role for a specified (or current) user. A default role is automatically enabled when a user connects (an implicit SET ROLE statement is executed immediately after a connection is established).\n\nTo be able to set a role as a default, the role must already have been granted to that user, and one needs the privileges to enable this role (if you cannot do SET ROLE X, you won''t be able to do SET DEFAULT ROLE X). To set a default role for another user one needs to have write access to the mysql database.\n\nTo remove a user''s default role, use SET DEFAULT ROLE NONE [ FOR user@host ]. The record of the default role is not removed if the role is dropped or revoked, so if the role is subsequently re-created or granted, it will again be the user''s default role.\n\nThe default role is stored in the default_role column in the mysql.user table/view, as well as in the Information Schema APPLICABLE_ROLES table, so these can be viewed to see which role has been assigned to a user as the default.\n\nExamples\n--------\n\nSET DEFAULT ROLE journalist;\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/account-management-sql-statements/set-default-role', '', 'https://mariadb.com/docs/server/reference/sql-statements/account-management-sql-statements/set-default-role'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (500, 10, 'SET PASSWORD', 'Syntax\n------\n\nSET PASSWORD [FOR user] =\n {\n PASSWORD(''some password'')\n | OLD_PASSWORD(''some password'')\n | ''encrypted password''\n }\n\nDescription\n-----------\n\nThe SET PASSWORD statement assigns a password to an existing MariaDB user account.\n\nIf the password is specified using the PASSWORD() or OLD_PASSWORD() function, the literal text of the password should be given. If the password is specified without using either function, the password should be the already-encrypted password value as returned by PASSWORD().\n\nOLD_PASSWORD() should only be used if your MariaDB/MySQL clients are very old (< 4.0.0).\n\nWith no FOR clause, this statement sets the password for the current user. Any client that has connected to the server using a non-anonymous account can change the password for that account.\n\nWith a FOR clause, this statement sets the password for a specific account on the current server host. Only clients that have the UPDATE privilege for the mysql database can do this. The user value should be given in user_name@host_name format, where user_name and host_name are exactly as they are listed in the User and Host columns of the mysql.user table (or view in current versions) entry.\n\nThe argument to PASSWORD() and the password given to MariaDB clients can be of arbitrary length.\n\nAuthentication Plugin Support\n\nSET PASSWORD (with or without PASSWORD()) works for accounts authenticated via any authentication plugin that supports passwords stored in the mysql.global_priv table.\n\nThe ed25519, mysql_native_password, and mysql_old_password authentication plugins store passwords in the mysql.global_priv table.\n\nIf you run SET PASSWORD on an account that authenticates with one of these authentication plugins that stores passwords in the mysql.global_priv table, then the PASSWORD() function is evaluated by the specific authentication plugin used by the account. The authentication plugin hashes the password with a method that is compatible with that specific authentication plugin.\n\nThe unix_socket, named_pipe, gssapi, and pam authentication plugins do not store passwords in the mysql.global_priv table. These authentication plugins rely on other methods to authenticate the user.\n\nIf you attempt to run SET PASSWORD on an account that authenticates with one of these authentication plugins that doesn''t store a password in the mysql.global_priv table, then MariaDB Server will issue an error like the following:\n\n``\nSET PASSWORD IS ignored FOR users authenticating via unix_socket plugin\n``\n\nSee Authentication from MariaDB 10.4 for an overview of authentication changes in MariaDB.\n\nPasswordless User Accounts\n\nUser accounts do not always require passwords to login.\n\nThe unix_socket , named_pipe and gssapi authentication plugins do not require a password to authenticate the user.\n\nThe pam authentication plugin may or may not require a password to authenticate the user, depending on the specific configuration.\n\nThe mysql_native_password and mysql_old_password authentication plugins require passwords for authentication, but the password can be blank. In that case, no password is required.\n\nIf you provide a password while attempting to log into the server as an account that doesn''t require a password, then MariaDB server will simply ignore the password.\n\nA user account can be defined to use multiple authentication plugins in a specific order of preference. This specific scenario may be more noticeable in these versions, since an account could be associated with some authentication plugins that require a password, and some that do not.\n\nExamples\n--------\n\nSET PASSWORD FOR ''bob''@''%.loc.gov'' = PASSWORD(''newpass'');\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/account-management-sql-statements/set-password', '', 'https://mariadb.com/docs/server/reference/sql-statements/account-management-sql-statements/set-password'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (501, 10, 'SET ROLE', 'Description\n-----------\n\nOnly one role can be current at a time. Executing SET ROLE replaces the current role; it does not add to a list of current roles. This is SQL Standard compliant behavior which differs from MySQL, where you may have several current roles at a time.\n\nThe SET ROLE statement switches the current role for the session, enabling its associated permissions. To have no current role, set NONE.\n\nIf a role that doesn''t exist, or to which the user has not been assigned, is specified, an ERROR 1959 (OP000): Invalid role specification error occurs.\n\nAn automatic SET ROLE is implicitly performed when a user connects if that user has been assigned a default role. See SET DEFAULT ROLE.\n\nExamples\n--------\n\n--Checking the current role status\nSELECT CURRENT_ROLE;\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/account-management-sql-statements/set-role', '', 'https://mariadb.com/docs/server/reference/sql-statements/account-management-sql-statements/set-role'); +INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (502, 26, 'ANALYZE FORMAT=JSON', 'Description\n-----------\n\nANALYZE FORMAT=JSON is a mix of the EXPLAIN FORMAT=JSON and ANALYZE statement features. The ANALYZE FORMAT=JSON $statement will execute $statement, and then print the output of EXPLAIN FORMAT=JSON, amended with data from the query execution.\n\nBasic Execution Data\n\nYou can get the following also from tabular ANALYZE statement form:\n\n r_rows is provided for any node that reads rows. It shows how many rows were read, on average.\n r_filtered is provided whenever there is a condition that is checked. It shows the percentage of rows left after checking the condition.\n\nAdvanced Execution Data\n\nThe most important data not available in the regular tabular ANALYZE statement are:\n\n r_loops field. This shows how many times the node was executed. Most query plan elements have this field.\n r_total_time_ms field. It shows how much time in total, in milliseconds, was spent executing this node. If the node has subnodes, their execution time is included.\n For UPDATE and DELETE statements, top-level query_block.r_total_time_ms does include the time to make row deletions/updates but does NOT include the time to commit the changes.\n r_buffer_size field. Query plan nodes that make use of buffers report the size of buffer that was used.\n\nInnoDB engine statistics\n\nStarting from MariaDB 10.6.15, MariaDB 10.8.8, MariaDB 10.9.8, MariaDB 10.10.6, MariaDB 10.11.5, MariaDB 11.0.3, MariaDB 11.1.2 and MariaDB 11.2.1 (MDEV-31577), the following statistics are reported for InnoDB tables:\n\n``json\n"r_engine_stats": {\n "pages_accessed": integer,\n "pages_updated": integer,\n "pages_read_count": integer,\n "pages_prefetch_read_count": integer,\n "pages_read_time_ms": double,\n "old_rows_read": integer\n }\n`\n\nOnly non-zero members are printed.\n\n pages_accessed is the total number of buffer pool pages accessed when reading this table.\n pages_updated is the total number of buffer pool pages that were modified during the execution of the statement.\n pages_read_count is the number of pages that InnoDB had to read from disk for this table. If the query touches "hot" data in the InnoDB buffer pool, this value will be 0 and not present.\n pages_prefetch_read_count Number of pages for which read-ahead was initiated. Not all such pages will necessarily be accessed.\n pages_read_time_ms is the total time spent reading the table.\n old_rows_read is the number of old row versions that InnoDB had to read. Old row version is the version of the row that is not visible to this transaction.\n\nSHOW ANALYZE FORMAT=JSON\n\nMariaDB starting with 10.9\n\nSHOW ANALYZE FORMAT=JSON for \\\nextends ANALYZE [FORMAT=JSON] to allow one to analyze a query currently running in another\nconnection.\n\nData About Individual Query Plan Nodes\n--------------------------------------\n\n* filesort node reports whether sorting was done with LIMIT n parameter, and\nhow many rows were in the sort result. \n* block-nl-join node has r_loops field, which allows to tell whether Using\njoin buffer was efficient \n* range-checked-for-each-record reports counters that show the result of the\ncheck. \n* expression-cache is used for subqueries, and it reports how many times the\ncache was used, and what cache hit ratio was.\n* union_result node has r_rows so one can see how many rows were produced\nafter UNION operation\n* and so forth\n\nUse Cases\n---------\n\nSee Examples of ANALYZE FORMAT=JSON.\n\nURL: https://mariadb.com/kb/en/analyze-format-json/','','https://mariadb.com/kb/en/analyze-format-json/'); -insert into help_topic (help_topic_id,help_category_id,name,description,example,url) values (468,28,'ANALYZE FORMAT=JSON Examples','Example #1\n----------\n\nCustomers who have ordered more than 1M goods.\n\nANALYZE FORMAT=JSON\nSELECT COUNT(*)\nFROM customer\nWHERE\n (SELECT SUM(o_totalprice) FROM orders WHERE o_custkey=c_custkey) > 1000*1000;\n\nThe query takes 40 seconds over cold cache\n\nEXPLAIN: {\n \"query_block\": {\n \"select_id\": 1,\n \"r_loops\": 1,\n \"r_total_time_ms\": 39872,\n \"table\": {\n \"table_name\": \"customer\",\n \"access_type\": \"index\",\n \"key\": \"i_c_nationkey\",\n \"key_length\": \"5\",\n \"used_key_parts\": [\"c_nationkey\"],\n \"r_loops\": 1,\n \"rows\": 150303,\n \"r_rows\": 150000,\n \"r_total_time_ms\": 270.3,\n \"filtered\": 100,\n \"r_filtered\": 60.691,\n \"attached_condition\": \"((subquery#2) > ((1000 * 1000)))\",\n \"using_index\": true\n },\n \"subqueries\": [\n {\n \"query_block\": {\n \"select_id\": 2,\n \"r_loops\": 150000,\n \"r_total_time_ms\": 39531,\n \"table\": {\n \"table_name\": \"orders\",\n \"access_type\": \"ref\",\n \"possible_keys\": [\"i_o_custkey\"],\n \"key\": \"i_o_custkey\",\n \"key_length\": \"5\",\n \"used_key_parts\": [\"o_custkey\"],\n \"ref\": [\"dbt3sf1.customer.c_custkey\"],\n \"r_loops\": 150000,\n \"rows\": 7,\n \"r_rows\": 10,\n \"r_total_time_ms\": 39208,\n \"filtered\": 100,\n \"r_filtered\": 100\n }\n }\n }\n ]\n }\n}\nANALYZE shows that 39.2 seconds were spent in the subquery, which was executed\n150K times (for every row of outer table).\n\nURL: https://mariadb.com/kb/en/analyze-formatjson-examples/','','https://mariadb.com/kb/en/analyze-formatjson-examples/'); -insert into help_topic (help_topic_id,help_category_id,name,description,example,url) values (469,28,'ANALYZE Statement','Description\n-----------\n\nThe ANALYZE statement is similar to the EXPLAIN statement. ANALYZE statement\nwill invoke the optimizer, execute the statement, and then produce EXPLAIN\noutput instead of the result set. The EXPLAIN output will be annotated with\nstatistics from statement execution.\n\nThis lets one check how close the optimizer\'s estimates about the query plan\nare to the reality. ANALYZE produces an overview, while the ANALYZE\nFORMAT=JSON command provides a more detailed view of the query plan and the\nquery execution.\n\nThe syntax is\n\nANALYZE explainable_statement;\n\nwhere the statement is any statement for which one can run EXPLAIN.\n\nCommand Output\n--------------\n\nConsider an example:\n\nANALYZE SELECT * FROM tbl1 \nWHERE key1 \n BETWEEN 10 AND 200 AND\n col1 LIKE \'foo%\'\\G\n\n*************************** 1. row ***************************\n id: 1\n select_type: SIMPLE\n table: tbl1\n type: range\npossible_keys: key1\n key: key1\n key_len: 5\n ref: NULL\n rows: 181\n r_rows: 181\n filtered: 100.00\n r_filtered: 10.50\n Extra: Using index condition; Using where\n\nCompared to EXPLAIN, ANALYZE produces two extra columns:\n\n* r_rows is an observation-based counterpart of the rows column. It shows how\nmany rows were actually read from the table. \n* r_filtered is an observation-based counterpart of the filtered column. It\nshows which fraction of rows was left after applying the WHERE condition.\n\nInterpreting the Output\n-----------------------\n\nJoins\n-----\n\nLet\'s consider a more complicated example.\n\nANALYZE SELECT *\nFROM orders, customer \nWHERE\n customer.c_custkey=orders.o_custkey AND\n customer.c_acctbal < 0 AND\n orders.o_totalprice > 200*1000\n\n+----+-------------+----------+------+---------------+-------------+---------+-\n------------------+--------+--------+----------+------------+-------------+\n| id | select_type | table | type | possible_keys | key | key_len |\nref | rows | r_rows | filtered | r_filtered | Extra |\n+----+-------------+----------+------+---------------+-------------+---------+-\n------------------+--------+--------+----------+------------+-------------+\n| 1 | SIMPLE | customer | ALL | PRIMARY,... | NULL | NULL |\nNULL | 149095 | 150000 | 18.08 | 9.13 | Using where |\n| 1 | SIMPLE | orders | ref | i_o_custkey | i_o_custkey | 5 |\ncustomer.c_custkey | 7 | 10 | 100.00 | 30.03 | Using where |\n+----+-------------+----------+------+---------------+-------------+---------+-\n------------------+--------+--------+----------+------------+-------------+\n\nHere, one can see that\n\n* For table customer, customer.rows=149095, customer.r_rows=150000. The\nestimate for number of rows we will read was fairly precise\n* customer.filtered=18.08, customer.r_filtered=9.13. The optimizer somewhat\noverestimated the number of records that will match selectivity of condition\nattached to `customer` table (in general, when you have a full scan and\nr_filtered is less than 15%, it\'s time to consider adding an appropriate\nindex).\n* For table orders, orders.rows=7, orders.r_rows=10. This means that on\naverage, there are 7 orders for a given c_custkey, but in our case there were\n10, which is close to the expectation (when this number is consistently far\nfrom the expectation, it may be time to run ANALYZE TABLE, or even edit the\ntable statistics manually to get better query plans).\n* orders.filtered=100, orders.r_filtered=30.03. The optimizer didn\'t have any\nway to estimate which fraction of records will be left after it checks the\ncondition that is attached to table orders (it\'s orders.o_totalprice >\n200*1000). So, it used 100%. In reality, it is 30%. 30% is typically not\nselective enough to warrant adding new indexes. For joins with many tables, it\nmight be worth to collect and use column statistics for columns in question,\nthis may help the optimizer to pick a better query plan.\n\nMeaning of NULL in r_rows and r_filtered\n----------------------------------------\n\nLet\'s modify the previous example slightly\n\nANALYZE SELECT * \nFROM orders, customer \nWHERE\n customer.c_custkey=orders.o_custkey AND\n customer.c_acctbal < -0 AND\n customer.c_comment LIKE \'%foo%\' AND\n orders.o_totalprice > 200*1000;\n\n+----+-------------+----------+------+---------------+-------------+---------+-\n------------------+--------+--------+----------+------------+-------------+\n| id | select_type | table | type | possible_keys | key | key_len |\nref | rows | r_rows | filtered | r_filtered | Extra |\n+----+-------------+----------+------+---------------+-------------+---------+-\n------------------+--------+--------+----------+------------+-------------+\n| 1 | SIMPLE | customer | ALL | PRIMARY,... | NULL | NULL |\nNULL | 149095 | 150000 | 18.08 | 0.00 | Using where |\n| 1 | SIMPLE | orders | ref | i_o_custkey | i_o_custkey | 5 |\ncustomer.c_custkey | 7 | NULL | 100.00 | NULL | Using where |\n+----+-------------+----------+------+---------------+-------------+---------+-\n------------------+--------+--------+----------+------------+-------------+\n\nHere, one can see that orders.r_rows=NULL and orders.r_filtered=NULL. This\nmeans that table orders was not scanned even once. Indeed, we can also see\ncustomer.r_filtered=0.00. This shows that a part of WHERE attached to table\n`customer` was never satisfied (or, satisfied in less than 0.01% of cases).\n\nANALYZE FORMAT=JSON\n-------------------\n\nANALYZE FORMAT=JSON produces JSON output. It produces much more information\nthan tabular ANALYZE.\n\nNotes\n-----\n\n* ANALYZE UPDATE or ANALYZE DELETE will actually make updates/deletes (ANALYZE\nSELECT will perform the select operation and then discard the resultset).\n* PostgreSQL has a similar command, EXPLAIN ANALYZE.\n* The EXPLAIN in the slow query log feature allows MariaDB to have ANALYZE\noutput of slow queries printed into the slow query log (see MDEV-6388).\n\nURL: https://mariadb.com/kb/en/analyze-statement/','','https://mariadb.com/kb/en/analyze-statement/'); -insert into help_topic (help_topic_id,help_category_id,name,description,example,url) values (470,28,'EXPLAIN','Syntax\n------\n\nEXPLAIN tbl_name [col_name | wild]\n\nOr\n\nEXPLAIN [EXTENDED | PARTITIONS | FORMAT=JSON] \n {SELECT select_options | UPDATE update_options | DELETE delete_options}\n\nDescription\n-----------\n\nThe EXPLAIN statement can be used either as a synonym for DESCRIBE or as a way\nto obtain information about how MariaDB executes a SELECT, UPDATE or DELETE\nstatement:\n\n* \'EXPLAIN tbl_name\' is synonymous with \n \'DESCRIBE tbl_name\' or\n \'SHOW COLUMNS FROM tbl_name\'.\n* When you precede a SELECT, UPDATE or a DELETE statement with the keyword \n EXPLAIN, MariaDB displays information from the optimizer\n about the query execution plan. That is, MariaDB explains how it would\n process the SELECT, UPDATE or DELETE, including information about how tables\n are joined and in which order. EXPLAIN EXTENDED can be\n used to provide additional information.\n* EXPLAIN PARTITIONS is useful only when examining queries involving\npartitioned tables. For details, see Partition pruning and selection.\n* ANALYZE statement performs the query as well as producing EXPLAIN output,\nand provides actual as well as estimated statistics.\n* EXPLAIN output can be printed in the slow query log. See EXPLAIN in the Slow\nQuery Log for details.\n\nSHOW EXPLAIN shows the output of a running statement. In some cases, its\noutput can be closer to reality than EXPLAIN.\n\nThe ANALYZE statement runs a statement and returns information about its\nexecution plan. It also shows additional columns, to check how much the\noptimizer\'s estimation about filtering and found rows are close to reality.\n\nThere is an online EXPLAIN Analyzer that you can use to share EXPLAIN and\nEXPLAIN EXTENDED output with others.\n\nEXPLAIN can acquire metadata locks in the same way that SELECT does, as it\nneeds to know table metadata and, sometimes, data as well.\n\nColumns in EXPLAIN ... SELECT\n-----------------------------\n\n+--------------------------------------+--------------------------------------+\n| Column name | Description |\n+--------------------------------------+--------------------------------------+\n| id | Sequence number that shows in which |\n| | order tables are joined. |\n+--------------------------------------+--------------------------------------+\n| select_type | What kind of SELECT the table comes |\n| | from. |\n+--------------------------------------+--------------------------------------+\n| table | Alias name of table. Materialized |\n| | temporary tables for sub queries |\n| | are named |\n+--------------------------------------+--------------------------------------+\n| type | How rows are found from the table |\n| | (join type). |\n+--------------------------------------+--------------------------------------+\n| possible_keys | keys in table that could be used to |\n| | find rows in the table |\n+--------------------------------------+--------------------------------------+\n| key | The name of the key that is used to |\n| | retrieve rows. NULL is no key was |\n| | used. |\n+--------------------------------------+--------------------------------------+\n| key_len | How many bytes of the key that was |\n| | used (shows if we are using only |\n| | parts of the multi-column key). |\n+--------------------------------------+--------------------------------------+\n| ref | The reference that is used as the |\n| | key value. |\n+--------------------------------------+--------------------------------------+\n| rows | An estimate of how many rows we |\n| | will find in the table for each key |\n| | lookup. |\n+--------------------------------------+--------------------------------------+\n| Extra | Extra information about this join. |\n+--------------------------------------+--------------------------------------+\n\nHere are descriptions of the values for some of the more complex columns in\nEXPLAIN ... SELECT:\n\n\"Select_type\" Column\n--------------------\n\nThe select_type column can have the following values:\n\n+-----------------+-----------------------------------+-----------------------+\n| Value | Description | Comment |\n+-----------------+-----------------------------------+-----------------------+\n| DEPENDENT | The SUBQUERY is DEPENDENT. | |\n| SUBQUERY | | |\n+-----------------+-----------------------------------+-----------------------+\n| DEPENDENT UNION | The UNION is DEPENDENT. | |\n+-----------------+-----------------------------------+-----------------------+\n| DERIVED | The SELECT is DERIVED from the | |\n| | PRIMARY. | |\n+-----------------+-----------------------------------+-----------------------+\n| MATERIALIZED | The SUBQUERY is MATERIALIZED. | Materialized tables |\n| | | will be populated at |\n| | | first access and |\n| | | will be accessed by |\n| | | the primary key (= |\n| | | one key lookup). |\n| | | Number of rows in |\n| | | EXPLAIN shows the |\n| | | cost of populating |\n| | | the table |\n+-----------------+-----------------------------------+-----------------------+\n| PRIMARY | The SELECT is in the outermost | |\n| | query, but there is also a | |\n| | SUBQUERY within it. | |\n+-----------------+-----------------------------------+-----------------------+\n| SIMPLE | It is a simple SELECT query | |\n| | without any SUBQUERY or UNION. | |\n+-----------------+-----------------------------------+-----------------------+\n| SUBQUERY | The SELECT is a SUBQUERY of the | |\n| | PRIMARY. | |\n+-----------------+-----------------------------------+-----------------------+\n| UNCACHEABLE | The SUBQUERY is UNCACHEABLE. | |\n| SUBQUERY | | |\n+-----------------+-----------------------------------+-----------------------+\n| UNCACHEABLE | The UNION is UNCACHEABLE. | |\n| UNION | | |\n+-----------------+-----------------------------------+-----------------------+\n| UNION | The SELECT is a UNION of the | |\n| | PRIMARY. | |\n+-----------------+-----------------------------------+-----------------------+\n| UNION RESULT | The result of the UNION. | |\n+-----------------+-----------------------------------+-----------------------+\n| LATERAL DERIVED | The SELECT uses a Lateral | |\n| | Derived optimization | |\n+-----------------+-----------------------------------+-----------------------+\n\n\"Type\" Column\n-------------\n\nThis column contains information on how the table is accessed.\n\n+------------------------+---------------------------------------------------+\n| Value | Description |\n+------------------------+---------------------------------------------------+\n| ALL | A full table scan is done for the table (all |\n| | rows are read). This is bad if the table is |\n| | large and the table is joined against a previous |\n| | table! This happens when the optimizer could |\n| | not find any usable index to access rows. |\n+------------------------+---------------------------------------------------+\n| const | There is only one possibly matching row in the |\n| | table. The row is read before the optimization |\n| | phase and all columns in the table are treated |\n| | as constants. |\n+------------------------+---------------------------------------------------+\n| eq_ref | A unique index is used to find the rows. This is |\n| | the best possible plan to find the row. |\n+------------------------+---------------------------------------------------+\n| fulltext | A fulltext index is used to access the rows. |\n+------------------------+---------------------------------------------------+\n| index_merge | A \'range\' access is done for for several index |\n| | and the found rows are merged. The key column |\n| | shows which keys are used. |\n+------------------------+---------------------------------------------------+\n| index_subquery | This is similar as ref, but used for sub queries |\n| | that are transformed to key lookups. |\n+------------------------+---------------------------------------------------+\n| index | A full scan over the used index. Better than |\n| | ALL but still bad if index is large and the |\n| | table is joined against a previous table. |\n+------------------------+---------------------------------------------------+\n| range | The table will be accessed with a key over one |\n| | or more value ranges. |\n+------------------------+---------------------------------------------------+\n| ref_or_null | Like \'ref\' but in addition another search for |\n| | the \'null\' value is done if the first value was |\n| | not found. This happens usually with sub queries. |\n+------------------------+---------------------------------------------------+\n| ref | A non unique index or prefix of an unique index |\n| | is used to find the rows. Good if the prefix |\n| | doesn\'t match many rows. |\n+------------------------+---------------------------------------------------+\n| system | The table has 0 or 1 rows. |\n+------------------------+---------------------------------------------------+\n| unique_subquery | This is similar as eq_ref, but used for sub |\n| | queries that are transformed to key lookups |\n+------------------------+---------------------------------------------------+\n\n\"Extra\" Column\n--------------\n\nThis column consists of one or more of the following values, separated by \';\'\n\nNote that some of these values are detected after the optimization phase.\n\nThe optimization phase can do the following changes to the WHERE clause:\n\n* Add the expressions from the ON and USING clauses to the WHERE\n clause.\n* Constant propagation: If there is column=constant, replace all column\n instances with this constant.\n* Replace all columns from \'const\' tables with their values.\n* Remove the used key columns from the WHERE (as this will be tested as\n part of the key lookup).\n* Remove impossible constant sub expressions.\n For example WHERE \'(a=1 and a=2) OR b=1\' becomes \'b=1\'.\n* Replace columns with other columns that has identical values:\n Example: WHERE a=b and a=c may be treated\n as \'WHERE a=b and a=c and b=c\'.\n* Add extra conditions to detect impossible row conditions earlier. This\n happens mainly with OUTER JOIN where we in some cases add detection\n of NULL values in the WHERE (Part of \'Not exists\' optimization).\n This can cause an unexpected \'Using where\' in the Extra column.\n* For each table level we remove expressions that have already been tested when\n we read the previous row. Example: When joining tables t1 with t2\n using the following WHERE \'t1.a=1 and t1.a=t2.b\', we don\'t have to\n test \'t1.a=1\' when checking rows in t2 as we already know that this\n expression is true.\n\n+------------------------+---------------------------------------------------+\n| Value | Description |\n+------------------------+---------------------------------------------------+\n| const row not found | The table was a system table (a table with |\n| | should exactly one row), but no row was found. |\n+------------------------+---------------------------------------------------+\n| Distinct | If distinct optimization (remove duplicates) was |','','https://mariadb.com/kb/en/explain/'); -update help_topic set description = CONCAT(description, '\n| | used. This is marked only for the last table in |\n| | the SELECT. |\n+------------------------+---------------------------------------------------+\n| Full scan on NULL key | The table is a part of the sub query and if the |\n| | value that is used to match the sub query will |\n| | be NULL, we will do a full table scan. |\n+------------------------+---------------------------------------------------+\n| Impossible HAVING | The used HAVING clause is always false so the |\n| | SELECT will return no rows. |\n+------------------------+---------------------------------------------------+\n| Impossible WHERE | The used WHERE clause is always false so the |\n| noticed after reading | SELECT will return no rows. This case was |\n| const tables. | detected after we had read all \'const\' tables |\n| | and used the column values as constant in the |\n| | WHERE clause. For example: WHERE const_column=5 |\n| | and const_column had a value of 4. |\n+------------------------+---------------------------------------------------+\n| Impossible WHERE | The used WHERE clause is always false so the |\n| | SELECT will return no rows. For example: WHERE |\n| | 1=2 |\n+------------------------+---------------------------------------------------+\n| No matching min/max | During early optimization of MIN()/MAX() values |\n| row | it was detected that no row could match the |\n| | WHERE clause. The MIN()/MAX() function will |\n| | return NULL. |\n+------------------------+---------------------------------------------------+\n| no matching row in | The table was a const table (a table with only |\n| const table | one possible matching row), but no row was found. |\n+------------------------+---------------------------------------------------+\n| No tables used | The SELECT was a sub query that did not use any |\n| | tables. For example a there was no FROM clause |\n| | or a FROM DUAL clause. |\n+------------------------+---------------------------------------------------+\n| Not exists | Stop searching after more row if we find one |\n| | single matching row. This optimization is used |\n| | with LEFT JOIN where one is explicitly searching |\n| | for rows that doesn\'t exists in the LEFT JOIN |\n| | TABLE. Example: SELECT * FROM t1 LEFT JOIN t2 on |\n| | (...) WHERE t2.not_null_column IS NULL. As |\n| | t2.not_null_column can only be NULL if there was |\n| | no matching row for on condition, we can stop |\n| | searching if we find a single matching row. |\n+------------------------+---------------------------------------------------+\n| Open_frm_only | For information_schema tables. Only the frm |\n| | (table definition file was opened) was opened |\n| | for each matching row. |\n+------------------------+---------------------------------------------------+\n| Open_full_table | For information_schema tables. A full table open |\n| | for each matching row is done to retrieve the |\n| | requested information. (Slow) |\n+------------------------+---------------------------------------------------+\n| Open_trigger_only | For information_schema tables. Only the trigger |\n| | file definition was opened for each matching row. |\n+------------------------+---------------------------------------------------+\n| Range checked for | This only happens when there was no good default |\n| each record (index | index to use but there may some index that could |\n| map: ...) | be used when we can treat all columns from |\n| | previous table as constants. For each row |\n| | combination the optimizer will decide which |\n| | index to use (if any) to fetch a row from this |\n| | table. This is not fast, but faster than a full |\n| | table scan that is the only other choice. The |\n| | index map is a bitmask that shows which index |\n| | are considered for each row condition. |\n+------------------------+---------------------------------------------------+\n| Scanned 0/1/all | For information_schema tables. Shows how many |\n| databases | times we had to do a directory scan. |\n+------------------------+---------------------------------------------------+\n| Select tables | All tables in the join was optimized away. This |\n| optimized away | happens when we are only using COUNT(*), MIN() |\n| | and MAX() functions in the SELECT and we where |\n| | able to replace all of these with constants. |\n+------------------------+---------------------------------------------------+\n| Skip_open_table | For information_schema tables. The queried table |\n| | didn\'t need to be opened. |\n+------------------------+---------------------------------------------------+\n| unique row not found | The table was detected to be a const table (a |\n| | table with only one possible matching row) |\n| | during the early optimization phase, but no row |\n| | was found. |\n+------------------------+---------------------------------------------------+\n| Using filesort | Filesort is needed to resolve the query. This |\n| | means an extra phase where we first collect all |\n| | columns to sort, sort them with a disk based |\n| | merge sort and then use the sorted set to |\n| | retrieve the rows in sorted order. If the column |\n| | set is small, we store all the columns in the |\n| | sort file to not have to go to the database to |\n| | retrieve them again. |\n+------------------------+---------------------------------------------------+\n| Using index | Only the index is used to retrieve the needed |\n| | information from the table. There is no need to |\n| | perform an extra seek to retrieve the actual |\n| | record. |\n+------------------------+---------------------------------------------------+\n| Using index condition | Like \'Using where\' but the where condition is |\n| | pushed down to the table engine for internal |\n| | optimization at the index level. |\n+------------------------+---------------------------------------------------+\n| Using index | Like \'Using index condition\' but in addition we |\n| condition(BKA) | use batch key access to retrieve rows. |\n+------------------------+---------------------------------------------------+\n| Using index for | The index is being used to resolve a GROUP BY or |\n| group-by | DISTINCT query. The rows are not read. This is |\n| | very efficient if the table has a lot of |\n| | identical index entries as duplicates are |\n| | quickly jumped over. |\n+------------------------+---------------------------------------------------+\n| Using intersect(...) | For index_merge joins. Shows which index are |\n| | part of the intersect. |\n+------------------------+---------------------------------------------------+\n| Using join buffer | We store previous row combinations in a row |\n| | buffer to be able to match each row against all |\n| | of the rows combinations in the join buffer at |\n| | one go. |\n+------------------------+---------------------------------------------------+\n| Using sort_union(...) | For index_merge joins. Shows which index are |\n| | part of the union. |\n+------------------------+---------------------------------------------------+\n| Using temporary | A temporary table is created to hold the result. |\n| | This typically happens if you are using GROUP |\n| | BY, DISTINCT or ORDER BY. |\n+------------------------+---------------------------------------------------+\n| Using where | A WHERE expression (in additional to the |\n| | possible key lookup) is used to check if the row |\n| | should be accepted. If you don\'t have \'Using |\n| | where\' together with a join type of ALL, you are |\n| | probably doing something wrong! |\n+------------------------+---------------------------------------------------+\n| Using where with | Like \'Using where\' but the where condition is |\n| pushed condition | pushed down to the table engine for internal |\n| | optimization at the row level. |\n+------------------------+---------------------------------------------------+\n| Using buffer | The UPDATE statement will first buffer the rows, |\n| | and then run the updates, rather than do updates |\n| | on the fly. See Using Buffer UPDATE Algorithm |\n| | for a detailed explanation. |\n+------------------------+---------------------------------------------------+\n\nEXPLAIN EXTENDED\n----------------\n\nThe EXTENDED keyword adds another column, filtered, to the output. This is a\npercentage estimate of the table rows that will be filtered by the condition.\n\nAn EXPLAIN EXTENDED will always throw a warning, as it adds extra Message\ninformation to a subsequent SHOW WARNINGS statement. This includes what the\nSELECT query would look like after optimizing and rewriting rules are applied\nand how the optimizer qualifies columns and tables.\n\nExamples\n--------\n\nAs synonym for DESCRIBE or SHOW COLUMNS FROM:\n\nDESCRIBE city;\n+------------+----------+------+-----+---------+----------------+\n| Field | Type | Null | Key | Default | Extra |\n+------------+----------+------+-----+---------+----------------+\n| Id | int(11) | NO | PRI | NULL | auto_increment |\n| Name | char(35) | YES | | NULL | |\n| Country | char(3) | NO | UNI | | |\n| District | char(20) | YES | MUL | | |\n| Population | int(11) | YES | | NULL | |\n+------------+----------+------+-----+---------+----------------+\n\nA simple set of examples to see how EXPLAIN can identify poor index usage:\n\nCREATE TABLE IF NOT EXISTS `employees_example` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n `first_name` varchar(30) NOT NULL,\n `last_name` varchar(40) NOT NULL,\n `position` varchar(25) NOT NULL,\n `home_address` varchar(50) NOT NULL,\n `home_phone` varchar(12) NOT NULL,\n `employee_code` varchar(25) NOT NULL,\n PRIMARY KEY (`id`),\n UNIQUE KEY `employee_code` (`employee_code`),\n KEY `first_name` (`first_name`,`last_name`)\n) ENGINE=Aria;\n\nINSERT INTO `employees_example` (`first_name`, `last_name`, `position`,\n`home_address`, `home_phone`, `employee_code`)\n VALUES\n (\'Mustapha\', \'Mond\', \'Chief Executive Officer\', \'692 Promiscuous Plaza\',\n\'326-555-3492\', \'MM1\'),\n (\'Henry\', \'Foster\', \'Store Manager\', \'314 Savage Circle\', \'326-555-3847\',\n\'HF1\'),\n (\'Bernard\', \'Marx\', \'Cashier\', \'1240 Ambient Avenue\', \'326-555-8456\', \'BM1\'),\n (\'Lenina\', \'Crowne\', \'Cashier\', \'281 Bumblepuppy Boulevard\', \'328-555-2349\',\n\'LC1\'),\n (\'Fanny\', \'Crowne\', \'Restocker\', \'1023 Bokanovsky Lane\', \'326-555-6329\',\n\'FC1\'),\n (\'Helmholtz\', \'Watson\', \'Janitor\', \'944 Soma Court\', \'329-555-2478\', \'HW1\');\n\nSHOW INDEXES FROM employees_example;\n+-------------------+------------+---------------+--------------+--------------\n+-----------+-------------+----------+--------+------+------------+---------+--\n------------+\n| Table | Non_unique | Key_name | Seq_in_index | Column_name \n | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment |\nIndex_comment |\n+-------------------+------------+---------------+--------------+--------------\n+-----------+-------------+----------+--------+------+------------+---------+--\n------------+\n| employees_example | 0 | PRIMARY | 1 | id \n | A | 7 | NULL | NULL | | BTREE | |\n |\n| employees_example | 0 | employee_code | 1 |\nemployee_code | A | 7 | NULL | NULL | | BTREE \n | | |\n| employees_example | 1 | first_name | 1 | first_name \n | A | NULL | NULL | NULL | | BTREE | |\n |') WHERE help_topic_id = 470; -update help_topic set description = CONCAT(description, '\n| employees_example | 1 | first_name | 2 | last_name \n | A | NULL | NULL | NULL | | BTREE | |\n |\n+-------------------+------------+---------------+--------------+--------------\n+-----------+-------------+----------+--------+------+------------+---------+--\n------------+\n\nSELECT on a primary key:\n\nEXPLAIN SELECT * FROM employees_example WHERE id=1;\n+------+-------------+-------------------+-------+---------------+---------+---\n-----+-------+------+-------+\n| id | select_type | table | type | possible_keys | key |\nkey_len | ref | rows | Extra |\n+------+-------------+-------------------+-------+---------------+---------+---\n-----+-------+------+-------+\n| 1 | SIMPLE | employees_example | const | PRIMARY | PRIMARY | 4\n | const | 1 | |\n+------+-------------+-------------------+-------+---------------+---------+---\n-----+-------+------+-------+\n\nThe type is const, which means that only one possible result could be\nreturned. Now, returning the same record but searching by their phone number:\n\nEXPLAIN SELECT * FROM employees_example WHERE home_phone=\'326-555-3492\';\n+------+-------------+-------------------+------+---------------+------+-------\n-+------+------+-------------+\n| id | select_type | table | type | possible_keys | key |\nkey_len | ref | rows | Extra |\n+------+-------------+-------------------+------+---------------+------+-------\n-+------+------+-------------+\n| 1 | SIMPLE | employees_example | ALL | NULL | NULL | NULL \n | NULL | 6 | Using where |\n+------+-------------+-------------------+------+---------------+------+-------\n-+------+------+-------------+\n\nHere, the type is All, which means no index could be used. Looking at the rows\ncount, a full table scan (all six rows) had to be performed in order to\nretrieve the record. If it\'s a requirement to search by phone number, an index\nwill have to be created.\n\nSHOW EXPLAIN example:\n\nSHOW EXPLAIN FOR 1;\n+------+-------------+-------+-------+---------------+------+---------+------+-\n-------+-------------+\n| id | select_type | table | type | possible_keys | key | key_len | ref |\nrows | Extra |\n+------+-------------+-------+-------+---------------+------+---------+------+-\n-------+-------------+\n| 1 | SIMPLE | tbl | index | NULL | a | 5 | NULL |\n1000107 | Using index |\n+------+-------------+-------+-------+---------------+------+---------+------+-\n-------+-------------+\n1 row in set, 1 warning (0.00 sec)\n\nExample of ref_or_null Optimization\n-----------------------------------\n\nSELECT * FROM table_name\n WHERE key_column=expr OR key_column IS NULL;\n\nref_or_null is something that often happens when you use subqueries with NOT\nIN as then one has to do an extra check for NULL values if the first value\ndidn\'t have a matching row.\n\nURL: https://mariadb.com/kb/en/explain/') WHERE help_topic_id = 470; -insert into help_topic (help_topic_id,help_category_id,name,description,example,url) values (471,28,'EXPLAIN ANALYZE','The syntax for the EXPLAIN ANALYZE feature was changed to ANALYZE statement,\navailable since MariaDB 10.1.0. See ANALYZE statement.\n\nURL: https://mariadb.com/kb/en/explain-analyze/','','https://mariadb.com/kb/en/explain-analyze/'); -insert into help_topic (help_topic_id,help_category_id,name,description,example,url) values (472,28,'EXPLAIN FORMAT=JSON','Synopsis\n--------\n\nEXPLAIN FORMAT=JSON is a variant of EXPLAIN command that produces output in\nJSON form. The output always has one row which has only one column titled\n\"JSON\". The contents are a JSON representation of the query plan, formatted\nfor readability:\n\nEXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE col1=1\\G\n\n*************************** 1. row ***************************\nEXPLAIN: {\n \"query_block\": {\n \"select_id\": 1,\n \"table\": {\n \"table_name\": \"t1\",\n \"access_type\": \"ALL\",\n \"rows\": 1000,\n \"filtered\": 100,\n \"attached_condition\": \"(t1.col1 = 1)\"\n }\n }\n}\n\nOutput is different from MySQL\n------------------------------\n\nThe output of MariaDB\'s EXPLAIN FORMAT=JSON is different from EXPLAIN\nFORMAT=JSON in MySQL.The reasons for that are:\n\n* MySQL\'s output has deficiencies. Some are listed here: EXPLAIN FORMAT=JSON\nin MySQL\n* The output of MySQL\'s EXPLAIN FORMAT=JSON is not defined. Even MySQL\nWorkbench has trouble parsing it (see this blog post).\n* MariaDB has query optimizations that MySQL does not have. Ergo, MariaDB\ngenerates query plans that MySQL does not generate.\n\nA (as yet incomplete) list of how MariaDB\'s output is different from MySQL can\nbe found here: EXPLAIN FORMAT=JSON differences from MySQL.\n\nOutput Format\n-------------\n\nTODO: MariaDB\'s output format description.\n\nURL: https://mariadb.com/kb/en/explain-format-json/','','https://mariadb.com/kb/en/explain-format-json/'); -insert into help_topic (help_topic_id,help_category_id,name,description,example,url) values (473,28,'DESCRIBE','Syntax\n------\n\n{DESCRIBE | DESC} tbl_name [col_name | wild]\n\nDescription\n-----------\n\nDESCRIBE provides information about the columns in a table. It is a shortcut\nfor SHOW COLUMNS FROM. These statements also display information for views.\n\ncol_name can be a column name, or a string containing the SQL \"%\" and \"_\"\nwildcard characters to obtain output only for the columns with names matching\nthe string. There is no need to enclose the string within quotes unless it\ncontains spaces or other special characters.\n\nDESCRIBE city;\n+------------+----------+------+-----+---------+----------------+\n| Field | Type | Null | Key | Default | Extra |\n+------------+----------+------+-----+---------+----------------+\n| Id | int(11) | NO | PRI | NULL | auto_increment |\n| Name | char(35) | YES | | NULL | |\n| Country | char(3) | NO | UNI | | |\n| District | char(20) | YES | MUL | | |\n| Population | int(11) | YES | | NULL | |\n+------------+----------+------+-----+---------+----------------+\n\nThe description for SHOW COLUMNS provides more information about the output\ncolumns.\n\nURL: https://mariadb.com/kb/en/describe/','','https://mariadb.com/kb/en/describe/'); -insert into help_topic (help_topic_id,help_category_id,name,description,example,url) values (474,29,'Identifier Names','Databases, tables, indexes, columns, aliases, views, stored routines,\ntriggers, events, variables, partitions, tablespaces, savepoints, labels,\nusers, roles, are collectively known as identifiers, and have certain rules\nfor naming.\n\nIdentifiers may be quoted using the backtick character - `. Quoting is\noptional for identifiers that don\'t contain special characters, or for\nidentifiers that are not reserved words. If the ANSI_QUOTES SQL_MODE flag is\nset, double quotes (\") can also be used to quote identifiers. If the MSSQL\nflag is set, square brackets ([ and ]) can be used for quoting.\n\nEven when using reserved words as names, fully qualified names do not need to\nbe quoted. For example, test.select has only one possible meaning, so it is\ncorrectly parsed even without quotes.\n\nUnquoted\n--------\n\nThe following characters are valid, and allow identifiers to be unquoted:\n\n* ASCII: [0-9,a-z,A-Z$_] (numerals 0-9, basic Latin letters, both lowercase\nand uppercase, dollar sign, underscore)\n* Extended: U+0080 .. U+FFFF\n\nQuoted\n------\n\nThe following characters are valid, but identifiers using them must be quoted:\n\n* ASCII: U+0001 .. U+007F (full Unicode Basic Multilingual Plane (BMP) except\nfor U+0000)\n* Extended: U+0080 .. U+FFFF \n* Identifier quotes can themselves be used as part of an identifier, as long\nas they are quoted.\n\nFurther Rules\n-------------\n\nThere are a number of other rules for identifiers:\n\n* Identifiers are stored as Unicode (UTF-8)\n* Identifiers may or may not be case-sensitive. See Indentifier\nCase-sensitivity.\n* Database, table and column names can\'t end with space characters\n* Identifier names may begin with a numeral, but can\'t only contain numerals\nunless quoted.\n* An identifier starting with a numeral, followed by an \'e\', may be parsed as\na floating point number, and needs to be quoted.\n* Identifiers are not permitted to contain the ASCII NUL character (U+0000)\nand supplementary characters (U+10000 and higher).\n* Names such as 5e6, 9e are not prohibited, but it\'s strongly recommended not\nto use them, as they could lead to ambiguity in certain contexts, being\ntreated as a number or expression.\n* User variables cannot be used as part of an identifier, or as an identifier\nin an SQL statement.\n\nQuote Character\n---------------\n\nThe regular quote character is the backtick character - `, but if the\nANSI_QUOTES SQL_MODE option is specified, a regular double quote - \" may be\nused as well.\n\nThe backtick character can be used as part of an identifier. In that case the\nidentifier needs to be quoted. The quote character can be the backtick, but in\nthat case, the backtick in the name must be escaped with another backtick.\n\nMaximum Length\n--------------\n\n* Databases, tables, columns, indexes, constraints, stored routines, triggers,\nevents, views, tablespaces, servers and log file groups have a maximum length\nof 64 characters.\n* Compound statement labels have a maximum length of 16 characters\n* Aliases have a maximum length of 256 characters, except for column aliases\nin CREATE VIEW statements, which are checked against the maximum column length\nof 64 characters (not the maximum alias length of 256 characters).\n* Users have a maximum length of 80 characters.\n* Roles have a maximum length of 128 characters.\n* Multi-byte characters do not count extra towards towards the character limit.\n\nMultiple Identifiers\n--------------------\n\nMariaDB allows the column name to be used on its own if the reference will be\nunambiguous, or the table name to be used with the column name, or all three\nof the database, table and column names. A period is used to separate the\nidentifiers, and the period can be surrounded by spaces.\n\nExamples\n--------\n\nUsing the period to separate identifiers:\n\nCREATE TABLE t1 (i int);\n\nINSERT INTO t1(i) VALUES (10);\n\nSELECT i FROM t1;\n+------+\n| i |\n+------+\n| 10 |\n+------+\n\nSELECT t1.i FROM t1;\n+------+\n| i |\n+------+\n| 10 |\n+------+\n\nSELECT test.t1.i FROM t1;\n+------+\n| i |\n+------+\n| 10 |\n+------+\n\nThe period can be separated by spaces:\n\nSELECT test . t1 . i FROM t1;\n+------+\n| i |\n+------+\n| 10 |\n+------+\n\nResolving ambiguity:\n\nCREATE TABLE t2 (i int);\n\nSELECT i FROM t1 LEFT JOIN t2 ON t1.i=t2.i;\nERROR 1052 (23000): Column \'i\' in field list is ambiguous\n\nSELECT t1.i FROM t1 LEFT JOIN t2 ON t1.i=t2.i;\n+------+\n| i |\n+------+\n| 10 |\n+------+\n\nCreating a table with characters that require quoting:\n\nCREATE TABLE 123% (i int);\nERROR 1064 (42000): You have an error in your SQL syntax; \n check the manual that corresponds to your MariaDB server version for the\nright syntax \n to use near \'123% (i int)\' at line 1\n\nCREATE TABLE `123%` (i int);\nQuery OK, 0 rows affected (0.85 sec)\n\nCREATE TABLE `TABLE` (i int);\nQuery OK, 0 rows affected (0.36 sec)\n\nUsing double quotes as a quoting character:\n\nCREATE TABLE \"SELECT\" (i int);\nERROR 1064 (42000): You have an error in your SQL syntax; \n check the manual that corresponds to your MariaDB server version for the\nright syntax \n to use near \'\"SELECT\" (i int)\' at line 1\n\nSET sql_mode=\'ANSI_QUOTES\';\nQuery OK, 0 rows affected (0.03 sec)\n\nCREATE TABLE \"SELECT\" (i int);\nQuery OK, 0 rows affected (0.46 sec)\n\nUsing an identifier quote as part of an identifier name:\n\nSHOW VARIABLES LIKE \'sql_mode\';\n+---------------+-------------+\n| Variable_name | Value |\n+---------------+-------------+\n| sql_mode | ANSI_QUOTES |\n+---------------+-------------+\n\nCREATE TABLE \"fg`d\" (i int);\nQuery OK, 0 rows affected (0.34 sec)\n\nCreating the table named * (Unicode number: U+002A) requires quoting.\n\nCREATE TABLE `*` (a INT);\n\nFloating point ambiguity:\n\nCREATE TABLE 8984444cce5d (x INT);\nQuery OK, 0 rows affected (0.38 sec)\n\nCREATE TABLE 8981e56cce5d (x INT);\nERROR 1064 (42000): You have an error in your SQL syntax; \n check the manual that corresponds to your MariaDB server version for the\nright syntax \n to use near \'8981e56cce5d (x INT)\' at line 1\n\nCREATE TABLE `8981e56cce5d` (x INT);\nQuery OK, 0 rows affected (0.39 sec)\n\nURL: https://mariadb.com/kb/en/identifier-names/','','https://mariadb.com/kb/en/identifier-names/'); -insert into help_topic (help_topic_id,help_category_id,name,description,example,url) values (475,29,'Identifier Case-sensitivity','Whether objects are case-sensitive or not is partly determined by the\nunderlying operating system. Unix-based systems are case-sensitive, Windows is\nnot, while Mac OS X is usually case-insensitive by default, but devices can be\nconfigured as case-sensitive using Disk Utility.\n\nDatabase, table, table aliases and trigger names are affected by the systems\ncase-sensitivity, while index, column, column aliases, stored routine and\nevent names are never case sensitive.\n\nLog file group name are case sensitive.\n\nThe lower_case_table_names server system variable plays a key role. It\ndetermines whether table names, aliases and database names are compared in a\ncase-sensitive manner. If set to 0 (the default on Unix-based systems), table\nnames and aliases and database names are compared in a case-sensitive manner.\nIf set to 1 (the default on Windows), names are stored in lowercase and not\ncompared in a case-sensitive manner. If set to 2 (the default on Mac OS X),\nnames are stored as declared, but compared in lowercase.\n\nIt is thus possible to make Unix-based systems behave like Windows and ignore\ncase-sensitivity, but the reverse is not true, as the underlying Windows\nfilesystem can not support this.\n\nEven on case-insensitive systems, you are required to use the same case\nconsistently within the same statement. The following statement fails, as it\nrefers to the table name in a different case.\n\nSELECT * FROM a_table WHERE A_table.id>10;\n\nFor a full list of identifier naming rules, see Identifier Names.\n\nPlease note that lower_case_table_names is a database initialization\nparameter. This means that, along with innodb_page_size, this variable must be\nset before running mariadb-install-db, and will not change the behavior of\nservers unless applied before the creation of core system databases.\n\nURL: https://mariadb.com/kb/en/identifier-case-sensitivity/','','https://mariadb.com/kb/en/identifier-case-sensitivity/'); -insert into help_topic (help_topic_id,help_category_id,name,description,example,url) values (476,29,'Binary Literals','Binary literals can be written in one of the following formats: b\'value\',\nB\'value\' or 0bvalue, where value is a string composed by 0 and 1 digits.\n\nBinary literals are interpreted as binary strings, and are convenient to\nrepresent VARBINARY, BINARY or BIT values.\n\nTo convert a binary literal into an integer, just add 0.\n\nExamples\n--------\n\nPrinting the value as a binary string:\n\nSELECT 0b1000001;\n+-----------+\n| 0b1000001 |\n+-----------+\n| A |\n+-----------+\n\nConverting the same value into a number:\n\nSELECT 0b1000001+0;\n+-------------+\n| 0b1000001+0 |\n+-------------+\n| 65 |\n+-------------+\n\nURL: https://mariadb.com/kb/en/binary-literals/','','https://mariadb.com/kb/en/binary-literals/'); -insert into help_topic (help_topic_id,help_category_id,name,description,example,url) values (477,29,'Boolean Literals','In MariaDB, FALSE is a synonym of 0 and TRUE is a synonym of 1. These\nconstants are case insensitive, so TRUE, True, and true are equivalent.\n\nThese terms are not synonyms of 0 and 1 when used with the IS operator. So,\nfor example, 10 IS TRUE returns 1, while 10 = TRUE returns 0 (because 1 != 10).\n\nThe IS operator accepts a third constant exists: UNKNOWN. It is always a\nsynonym of NULL.\n\nTRUE and FALSE are reserved words, while UNKNOWN is not.\n\nURL: https://mariadb.com/kb/en/sql-language-structure-boolean-literals/','','https://mariadb.com/kb/en/sql-language-structure-boolean-literals/'); -insert into help_topic (help_topic_id,help_category_id,name,description,example,url) values (478,29,'Date and Time Literals','Standard syntaxes\n-----------------\n\nMariaDB supports the SQL standard and ODBC syntaxes for DATE, TIME and\nTIMESTAMP literals.\n\nSQL standard syntax:\n\n* DATE \'string\'\n* TIME \'string\'\n* TIMESTAMP \'string\'\n\nODBC syntax:\n\n* {d \'string\'}\n* {t \'string\'}\n* {ts \'string\'}\n\nThe timestamp literals are treated as DATETIME literals, because in MariaDB\nthe range of DATETIME is closer to the TIMESTAMP range in the SQL standard.\n\nstring is a string in a proper format, as explained below.\n\nDATE literals\n-------------\n\nA DATE string is a string in one of the following formats: \'YYYY-MM-DD\' or\n\'YY-MM-DD\'. Note that any punctuation character can be used as delimiter. All\ndelimiters must consist of 1 character. Different delimiters can be used in\nthe same string. Delimiters are optional (but if one delimiter is used, all\ndelimiters must be used).\n\nA DATE literal can also be an integer, in one of the following formats:\nYYYYMMDD or YYMMDD.\n\nAll the following DATE literals are valid, and they all represent the same\nvalue:\n\n\'19940101\'\n\'940101\'\n\'1994-01-01\'\n\'94/01/01\'\n\'1994-01/01\'\n\'94:01!01\'\n19940101\n940101\n\nDATETIME literals\n-----------------\n\nA DATETIME string is a string in one of the following formats: \'YYYY-MM-DD\nHH:MM:SS\' or \'YY-MM-DD HH:MM:SS\'. Note that any punctuation character can be\nused as delimiter for the date part and for the time part. All delimiters must\nconsist of 1 character. Different delimiters can be used in the same string.\nThe hours, minutes and seconds parts can consist of one character. For this\nreason, delimiters are mandatory for DATETIME literals.\n\nThe delimiter between the date part and the time part can be a T or any\nsequence of space characters (including tabs, new lines and carriage returns).\n\nA DATETIME literal can also be a number, in one of the following formats:\nYYYYMMDDHHMMSS, YYMMDDHHMMSS, YYYYMMDD or YYMMDD. In this case, all the time\nsubparts must consist of 2 digits.\n\nAll the following DATE literals are valid, and they all represent the same\nvalue:\n\n\'1994-01-01T12:30:03\'\n\'1994/01/01\\n\\t 12+30+03\'\n\'1994/01\\\\01\\n\\t 12+30-03\'\n\'1994-01-01 12:30:3\'\n\nTIME literals\n-------------\n\nA TIME string is a string in one of the following formats: \'D HH:MM:SS\',\n\'HH:MM:SS, \'D HH:MM\', \'HH:MM\', \'D HH\', or \'SS\'. D is a value from 0 to 34\nwhich represents days. : is the only allowed delimiter for TIME literals.\nDelimiters are mandatory, with an exception: the \'HHMMSS\' format is allowed.\nWhen delimiters are used, each part of the literal can consist of one\ncharacter.\n\nA TIME literal can also be a number in one of the following formats: HHMMSS,\nMMSS, or SS.\n\nThe following literals are equivalent:\n\n\'09:05:00\'\n\'9:05:0\'\n\'9:5:0\'\n\'090500\'\n\n2-digit years\n-------------\n\nThe year part in DATE and DATETIME literals is determined as follows:\n\n* 70 - 99 = 1970 - 1999\n* 00 - 69 = 2000 - 2069\n\nMicroseconds\n------------\n\nDATETIME and TIME literals can have an optional microseconds part. For both\nstring and numeric forms, it is expressed as a decimal part. Up to 6 decimal\ndigits are allowed. Examples:\n\n\'12:30:00.123456\'\n123000.123456\n\nSee Microseconds in MariaDB for details.\n\nDate and time literals and the SQL_MODE\n---------------------------------------\n\nUnless the SQL_MODE NO_ZERO_DATE flag is set, some special values are allowed:\nthe \'0000-00-00\' DATE, the \'00:00:00\' TIME, and the 0000-00-00 00:00:00\nDATETIME.\n\nIf the ALLOW_INVALID_DATES flag is set, the invalid dates (for example, 30th\nFebruary) are allowed. If not, if the NO_ZERO_DATE is set, an error is\nproduced; otherwise, a zero-date is returned.\n\nUnless the NO_ZERO_IN_DATE flag is set, each subpart of a date or time value\n(years, hours...) can be set to 0.\n\nURL: https://mariadb.com/kb/en/date-and-time-literals/','','https://mariadb.com/kb/en/date-and-time-literals/'); -insert into help_topic (help_topic_id,help_category_id,name,description,example,url) values (479,29,'Hexadecimal Literals','Hexadecimal literals can be written using any of the following syntaxes:\n\n* x\'value\'\n* X\'value\' (SQL standard)\n* 0xvalue (ODBC)\n\nvalue is a sequence of hexadecimal digits (from 0 to 9 and from A to F). The\ncase of the digits does not matter. With the first two syntaxes, value must\nconsist of an even number of digits. With the last syntax, digits can be even,\nand they are treated as if they had an extra 0 at the beginning.\n\nNormally, hexadecimal literals are interpreted as binary string, where each\npair of digits represents a character. When used in a numeric context, they\nare interpreted as integers. (See the example below). In no case can a\nhexadecimal literal be a decimal number.\n\nThe first two syntaxes; X\'value\' and x\'value, follow the SQL standard, and\nbehave as a string in all contexts in MariaDB since MariaDB 10.0.3 and MariaDB\n5.5.31 (fixing MDEV-4489). The latter syntax, 0xvalue, is a MySQL/MariaDB\nextension for hex hybrids and behaves as a string or as a number depending on\ncontext. MySQL treats all syntaxes the same, so there may be different results\nin MariaDB and MySQL (see below).\n\nExamples\n--------\n\nRepresenting the a character with the three syntaxes explained above:\n\nSELECT x\'61\', X\'61\', 0x61;\n+-------+-------+------+\n| x\'61\' | X\'61\' | 0x61 |\n+-------+-------+------+\n| a | a | a |\n+-------+-------+------+\n\nHexadecimal literals in a numeric context:\n\nSELECT 0 + 0xF, -0xF;\n+---------+------+\n| 0 + 0xF | -0xF |\n+---------+------+\n| 15 | -15 |\n+---------+------+\n\nFun with Types\n--------------\n\nCREATE TABLE t1 (a INT, b VARCHAR(10));\nINSERT INTO t1 VALUES (0x31, 0x61),(COALESCE(0x31), COALESCE(0x61));\n\nSELECT * FROM t1;\n+------+------+\n| a | b |\n+------+------+\n| 49 | a |\n| 1 | a |\n+------+------+\n\nThe reason for the differing results above is that when 0x31 is inserted\ndirectly to the column, it\'s treated as a number, while when 0x31 is passed to\nCOALESCE(), it\'s treated as a string, because:\n\n* HEX values have a string data type by default.\n* COALESCE() has the same data type as the argument.\n\nDifferences Between MariaDB and MySQL\n-------------------------------------\n\nSELECT x\'0a\'+0;\n+---------+\n| x\'0a\'+0 |\n+---------+\n| 0 |\n+---------+\n1 row in set, 1 warning (0.00 sec)\n\nWarning (Code 1292): Truncated incorrect DOUBLE value: \'\\x0A\'\n\nSELECT X\'0a\'+0;\n+---------+\n| X\'0a\'+0 |\n+---------+\n| 0 |\n+---------+\n1 row in set, 1 warning (0.00 sec)\n\nWarning (Code 1292): Truncated incorrect DOUBLE value: \'\\x0A\'\n\nSELECT 0x0a+0;\n+--------+\n| 0x0a+0 |\n+--------+\n| 10 |\n+--------+\n\nIn MySQL (up until at least MySQL 8.0.26):\n\nSELECT x\'0a\'+0;\n+---------+\n| x\'0a\'+0 |\n+---------+\n| 10 |\n+---------+\n\nSELECT X\'0a\'+0;\n+---------+\n| X\'0a\'+0 |\n+---------+\n| 10 |\n+---------+\n\nSELECT 0x0a+0;\n+--------+\n| 0x0a+0 |\n+--------+\n| 10 |\n+--------+\n\nURL: https://mariadb.com/kb/en/hexadecimal-literals/','','https://mariadb.com/kb/en/hexadecimal-literals/'); -insert into help_topic (help_topic_id,help_category_id,name,description,example,url) values (480,29,'Identifier Qualifiers','Qualifiers are used within SQL statements to reference data structures, such\nas databases, tables, or columns. For example, typically a SELECT query\ncontains references to some columns and at least one table.\n\nQualifiers can be composed by one or more identifiers, where the initial parts\naffect the context within which the final identifier is interpreted:\n\n* For a database, only the database identifier needs to be specified.\n* For objects which are contained in a database (like tables, views,\nfunctions, etc) the database identifier can be specified. If no database is\nspecified, the current database is assumed (see USE and DATABASE() for more\ndetails). If there is no default database and no database is specified, an\nerror is issued.\n* For column names, the table and the database are generally obvious from the\ncontext of the statement. It is however possible to specify the table\nidentifier, or the database identifier plus the table identifier.\n* An identifier is fully-qualified if it contains all possible qualifiers, for\nexample, the following column is fully qualified: db_name.tbl_name.col_name.\n\nIf a qualifier is composed by more than one identifier, a dot (.) must be used\nas a separator. All identifiers can be quoted individually. Extra spacing\n(including new lines and tabs) is allowed.\n\nAll the following examples are valid:\n\n* db_name.tbl_name.col_name\n* tbl_name\n* `db_name`.`tbl_name`.`col_name`\n* `db_name` . `tbl_name`\n* db_name. tbl_name\n\nIf a table identifier is prefixed with a dot (.), the default database is\nassumed. This syntax is supported for ODBC compliance, but has no practical\neffect on MariaDB. These qualifiers are equivalent:\n\n* tbl_name\n* . tbl_name\n* .`tbl_name`\n* . `tbl_name`\n\nFor DML statements, it is possible to specify a list of the partitions using\nthe PARTITION clause. See Partition Pruning and Selection for details.\n\nURL: https://mariadb.com/kb/en/identifier-qualifiers/','','https://mariadb.com/kb/en/identifier-qualifiers/'); -insert into help_topic (help_topic_id,help_category_id,name,description,example,url) values (481,29,'Identifier to File Name Mapping','Some identifiers map to a file name on the filesystem. Databases each have\ntheir own directory, while, depending on the storage engine, table names and\nindex names may map to a file name.\n\nNot all characters that are allowed in table names can be used in file names.\nEvery filesystem has its own rules of what characters can be used in file\nnames. To let the user create tables using all characters allowed in the SQL\nStandard and to not depend on whatever particular filesystem a particular\ndatabase resides, MariaDB encodes \"potentially unsafe\" characters in the table\nname to derive the corresponding file name.\n\nThis is implemented using a special character set. MariaDB converts a table\nname to the \"filename\" character set to get the file name for this table. And\nit converts the file name from the \"filename\" character set to, for example,\nutf8 to get the table name for this file name.\n\nThe conversion rules are as follows: if the identifier is made up only of\nbasic Latin numbers, letters and/or the underscore character, the encoding\nmatches the name (see however Identifier Case Sensitivity). Otherwise they are\nencoded according to the following table:\n\n+-----------------+------------+-----------+--------+-----------+-----------+\n| Code Range | Pattern | Number | Used | Unused | Blocks |\n+-----------------+------------+-----------+--------+-----------+-----------+\n| 00C0..017F | [@][0..4][ | 5*20= 100 | 97 | 3 | Latin-1 |\n| | ..z] | | | | Supplemen |\n| | | | | | + Latin |\n| | | | | | Extended- |\n| | | | | | |\n+-----------------+------------+-----------+--------+-----------+-----------+\n| 0370..03FF | [@][5..9][ | 5*20= 100 | 88 | 12 | Greek |\n| | ..z] | | | | and |\n| | | | | | Coptic |\n+-----------------+------------+-----------+--------+-----------+-----------+\n| 0400..052F | [@][g..z][ | 20*7= 140 | 137 | 3 | Cyrillic |\n| | ..6] | | | | + |\n| | | | | | Cyrillic |\n| | | | | | Supplemen |\n| | | | | | |\n+-----------------+------------+-----------+--------+-----------+-----------+\n| 0530..058F | [@][g..z][ | 20*2= 40 | 38 | 2 | Armenian |\n| | ..8] | | | | |\n+-----------------+------------+-----------+--------+-----------+-----------+\n| 2160..217F | [@][g..z][ | 20*1= 20 | 16 | 4 | Number |\n| | ] | | | | Forms |\n+-----------------+------------+-----------+--------+-----------+-----------+\n| 0180..02AF | [@][g..z][ | 20*11=220 | 203 | 17 | Latin |\n| | ..k] | | | | Extended- |\n| | | | | | + IPA |\n| | | | | | Extension |\n| | | | | | |\n+-----------------+------------+-----------+--------+-----------+-----------+\n| 1E00..1EFF | [@][g..z][ | 20*7= 140 | 136 | 4 | Latin |\n| | ..r] | | | | Extended |\n| | | | | | Additiona |\n| | | | | | |\n+-----------------+------------+-----------+--------+-----------+-----------+\n| 1F00..1FFF | [@][g..z][ | 20*8= 160 | 144 | 16 | Greek |\n| | ..z] | | | | Extended |\n+-----------------+------------+-----------+--------+-----------+-----------+\n| .... .... | [@][a..f][ | 6*20= 120 | 0 | 120 | RESERVED |\n| | ..z] | | | | |\n+-----------------+------------+-----------+--------+-----------+-----------+\n| 24B6..24E9 | [@][@][a.. | 26 | 26 | 0 | Enclosed |\n| | ] | | | | Alphanume |\n| | | | | | ics |\n+-----------------+------------+-----------+--------+-----------+-----------+\n| FF21..FF5A | [@][a..z][ | 26 | 26 | 0 | Halfwidth |\n| | ] | | | | and |\n| | | | | | Fullwidth |\n| | | | | | forms |\n+-----------------+------------+-----------+--------+-----------+-----------+\n\nCode Range values are UCS-2.\n\nAll of this encoding happens transparently at the filesystem level with one\nexception. Until MySQL 5.1.6, an old encoding was used. Identifiers created in\na version before MySQL 5.1.6, and which haven\'t been updated to the new\nencoding, the server prefixes mysql50 to their name.\n\nExamples\n--------\n\nFind the file name for a table with a non-Latin1 name:\n\nselect cast(convert(\"this_is_таблица\" USING filename) as binary);\n+------------------------------------------------------------------+\n| cast(convert(\"this_is_таблица\" USING filename) as binary) |\n+------------------------------------------------------------------+\n| this_is_@y0@g0@h0@r0@o0@i1@g0 |\n+------------------------------------------------------------------+\n\nFind the table name for a file name:\n\nselect convert(_filename \"this_is_@y0@g0@h0@r0@o0@i1@g0\" USING utf8);\n+---------------------------------------------------------------+\n| convert(_filename \"this_is_@y0@g0@h0@r0@o0@i1@g0\" USING utf8) |\n+---------------------------------------------------------------+\n| this_is_таблица |\n+---------------------------------------------------------------+\n\nAn old table created before MySQL 5.1.6, with the old encoding:\n\nSHOW TABLES;\n+--------------------+\n| Tables_in_test |\n+--------------------+\n| #mysql50#table@1 |\n+--------------------+\n\nThe prefix needs to be supplied to reference this table:\n\nSHOW COLUMNS FROM `table@1`;\nERROR 1146 (42S02): Table \'test.table@1\' doesn\'t exist\n\nSHOW COLUMNS FROM `#mysql50#table@1`;\n+-------+---------+------+-----+---------+-------+\n| Field | Type | Null | Key | Default | Extra |\n+-------+---------+------+-----+---------+-------+\n| i | int(11) | YES | | NULL | |\n+-------+---------+------+-----+---------+-------+\n\nURL: https://mariadb.com/kb/en/identifier-to-file-name-mapping/','','https://mariadb.com/kb/en/identifier-to-file-name-mapping/'); -insert into help_topic (help_topic_id,help_category_id,name,description,example,url) values (482,29,'Numeric Literals','Numeric literals are written as a sequence of digits from 0 to 9. Initial\nzeros are ignored. A sign can always precede the digits, but it is optional\nfor positive numbers. In decimal numbers, the integer part and the decimal\npart are divided with a dot (.).\n\nIf the integer part is zero, it can be omitted, but the literal must begin\nwith a dot.\n\nThe notation with exponent can be used. The exponent is preceded by an E or e\ncharacter. The exponent can be preceded by a sign and must be an integer. A\nnumber N with an exponent part X, is calculated as N * POW(10, X).\n\nIn some cases, adding zeroes at the end of a decimal number can increment the\nprecision of the expression where the number is used. For example, PI() by\ndefault returns a number with 6 decimal digits. But the PI()+0.0000000000\nexpression (with 10 zeroes) returns a number with 10 decimal digits.\n\nHexadecimal literals are interpreted as numbers when used in numeric contexts.\n\nExamples\n--------\n\n10\n+10\n-10\n\nAll these literals are equivalent:\n\n0.1\n.1\n+0.1\n+.1\n\nWith exponents:\n\n0.2E3 -- 0.2 * POW(10, 3) = 200\n.2e3\n.2e+2\n1.1e-10 -- 0.00000000011\n-1.1e10 -- -11000000000\n\nURL: https://mariadb.com/kb/en/numeric-iterals/','','https://mariadb.com/kb/en/numeric-iterals/'); -insert into help_topic (help_topic_id,help_category_id,name,description,example,url) values (483,29,'Reserved Words','The following is a list of all reserved words in MariaDB.\n\nReserved words cannot be used as Identifiers, unless they are quoted.\n\nThe definitive list of reserved words for each version can be found by\nexamining the sql/lex.h and sql/sql_yacc.yy files.\n\nReserved Words\n--------------\n\n+--------------------------------------------+--------------------------------+\n| Keyword | Notes |\n+--------------------------------------------+--------------------------------+\n| ACCESSIBLE | |\n+--------------------------------------------+--------------------------------+\n| ADD | |\n+--------------------------------------------+--------------------------------+\n| ALL | |\n+--------------------------------------------+--------------------------------+\n| ALTER | |\n+--------------------------------------------+--------------------------------+\n| ANALYZE | |\n+--------------------------------------------+--------------------------------+\n| AND | |\n+--------------------------------------------+--------------------------------+\n| AS | |\n+--------------------------------------------+--------------------------------+\n| ASC | |\n+--------------------------------------------+--------------------------------+\n| ASENSITIVE | |\n+--------------------------------------------+--------------------------------+\n| BEFORE | |\n+--------------------------------------------+--------------------------------+\n| BETWEEN | |\n+--------------------------------------------+--------------------------------+\n| BIGINT | |\n+--------------------------------------------+--------------------------------+\n| BINARY | |\n+--------------------------------------------+--------------------------------+\n| BLOB | |\n+--------------------------------------------+--------------------------------+\n| BOTH | |\n+--------------------------------------------+--------------------------------+\n| BY | |\n+--------------------------------------------+--------------------------------+\n| CALL | |\n+--------------------------------------------+--------------------------------+\n| CASCADE | |\n+--------------------------------------------+--------------------------------+\n| CASE | |\n+--------------------------------------------+--------------------------------+\n| CHANGE | |\n+--------------------------------------------+--------------------------------+\n| CHAR | |\n+--------------------------------------------+--------------------------------+\n| CHARACTER | |\n+--------------------------------------------+--------------------------------+\n| CHECK | |\n+--------------------------------------------+--------------------------------+\n| COLLATE | |\n+--------------------------------------------+--------------------------------+\n| COLUMN | |\n+--------------------------------------------+--------------------------------+\n| CONDITION | |\n+--------------------------------------------+--------------------------------+\n| CONSTRAINT | |\n+--------------------------------------------+--------------------------------+\n| CONTINUE | |\n+--------------------------------------------+--------------------------------+\n| CONVERT | |\n+--------------------------------------------+--------------------------------+\n| CREATE | |\n+--------------------------------------------+--------------------------------+\n| CROSS | |\n+--------------------------------------------+--------------------------------+\n| CURRENT_DATE | |\n+--------------------------------------------+--------------------------------+\n| CURRENT_ROLE | |\n+--------------------------------------------+--------------------------------+\n| CURRENT_TIME | |\n+--------------------------------------------+--------------------------------+\n| CURRENT_TIMESTAMP | |\n+--------------------------------------------+--------------------------------+\n| CURRENT_USER | |\n+--------------------------------------------+--------------------------------+\n| CURSOR | |\n+--------------------------------------------+--------------------------------+\n| DATABASE | |\n+--------------------------------------------+--------------------------------+\n| DATABASES | |\n+--------------------------------------------+--------------------------------+\n| DAY_HOUR | |\n+--------------------------------------------+--------------------------------+\n| DAY_MICROSECOND | |\n+--------------------------------------------+--------------------------------+\n| DAY_MINUTE | |\n+--------------------------------------------+--------------------------------+\n| DAY_SECOND | |\n+--------------------------------------------+--------------------------------+\n| DEC | |\n+--------------------------------------------+--------------------------------+\n| DECIMAL | |\n+--------------------------------------------+--------------------------------+\n| DECLARE | |\n+--------------------------------------------+--------------------------------+\n| DEFAULT | |\n+--------------------------------------------+--------------------------------+\n| DELAYED | |\n+--------------------------------------------+--------------------------------+\n| DELETE | |\n+--------------------------------------------+--------------------------------+\n| DELETE_DOMAIN_ID | |\n+--------------------------------------------+--------------------------------+\n| DESC | |\n+--------------------------------------------+--------------------------------+\n| DESCRIBE | |\n+--------------------------------------------+--------------------------------+\n| DETERMINISTIC | |\n+--------------------------------------------+--------------------------------+\n| DISTINCT | |\n+--------------------------------------------+--------------------------------+\n| DISTINCTROW | |\n+--------------------------------------------+--------------------------------+\n| DIV | |\n+--------------------------------------------+--------------------------------+\n| DO_DOMAIN_IDS | |\n+--------------------------------------------+--------------------------------+\n| DOUBLE | |\n+--------------------------------------------+--------------------------------+\n| DROP | |\n+--------------------------------------------+--------------------------------+\n| DUAL | |\n+--------------------------------------------+--------------------------------+\n| EACH | |\n+--------------------------------------------+--------------------------------+\n| ELSE | |\n+--------------------------------------------+--------------------------------+\n| ELSEIF | |\n+--------------------------------------------+--------------------------------+\n| ENCLOSED | |\n+--------------------------------------------+--------------------------------+\n| ESCAPED | |\n+--------------------------------------------+--------------------------------+\n| EXCEPT | Added in MariaDB 10.3.0 |\n+--------------------------------------------+--------------------------------+\n| EXISTS | |\n+--------------------------------------------+--------------------------------+\n| EXIT | |\n+--------------------------------------------+--------------------------------+\n| EXPLAIN | |\n+--------------------------------------------+--------------------------------+\n| FALSE | |\n+--------------------------------------------+--------------------------------+\n| FETCH | |\n+--------------------------------------------+--------------------------------+\n| FLOAT | |\n+--------------------------------------------+--------------------------------+\n| FLOAT4 | |\n+--------------------------------------------+--------------------------------+\n| FLOAT8 | |\n+--------------------------------------------+--------------------------------+\n| FOR | |\n+--------------------------------------------+--------------------------------+\n| FORCE | |\n+--------------------------------------------+--------------------------------+\n| FOREIGN | |\n+--------------------------------------------+--------------------------------+\n| FROM | |\n+--------------------------------------------+--------------------------------+\n| FULLTEXT | |\n+--------------------------------------------+--------------------------------+\n| GENERAL | |\n+--------------------------------------------+--------------------------------+\n| GRANT | |\n+--------------------------------------------+--------------------------------+\n| GROUP | |\n+--------------------------------------------+--------------------------------+\n| HAVING | |\n+--------------------------------------------+--------------------------------+\n| HIGH_PRIORITY | |\n+--------------------------------------------+--------------------------------+\n| HOUR_MICROSECOND | |\n+--------------------------------------------+--------------------------------+\n| HOUR_MINUTE | |\n+--------------------------------------------+--------------------------------+\n| HOUR_SECOND | |','','https://mariadb.com/kb/en/reserved-words/'); -update help_topic set description = CONCAT(description, '\n+--------------------------------------------+--------------------------------+\n| IF | |\n+--------------------------------------------+--------------------------------+\n| IGNORE | |\n+--------------------------------------------+--------------------------------+\n| IGNORE_DOMAIN_IDS | |\n+--------------------------------------------+--------------------------------+\n| IGNORE_SERVER_IDS | |\n+--------------------------------------------+--------------------------------+\n| IN | |\n+--------------------------------------------+--------------------------------+\n| INDEX | |\n+--------------------------------------------+--------------------------------+\n| INFILE | |\n+--------------------------------------------+--------------------------------+\n| INNER | |\n+--------------------------------------------+--------------------------------+\n| INOUT | |\n+--------------------------------------------+--------------------------------+\n| INSENSITIVE | |\n+--------------------------------------------+--------------------------------+\n| INSERT | |\n+--------------------------------------------+--------------------------------+\n| INT | |\n+--------------------------------------------+--------------------------------+\n| INT1 | |\n+--------------------------------------------+--------------------------------+\n| INT2 | |\n+--------------------------------------------+--------------------------------+\n| INT3 | |\n+--------------------------------------------+--------------------------------+\n| INT4 | |\n+--------------------------------------------+--------------------------------+\n| INT8 | |\n+--------------------------------------------+--------------------------------+\n| INTEGER | |\n+--------------------------------------------+--------------------------------+\n| INTERSECT | Added in MariaDB 10.3.0 |\n+--------------------------------------------+--------------------------------+\n| INTERVAL | |\n+--------------------------------------------+--------------------------------+\n| INTO | |\n+--------------------------------------------+--------------------------------+\n| IS | |\n+--------------------------------------------+--------------------------------+\n| ITERATE | |\n+--------------------------------------------+--------------------------------+\n| JOIN | |\n+--------------------------------------------+--------------------------------+\n| KEY | |\n+--------------------------------------------+--------------------------------+\n| KEYS | |\n+--------------------------------------------+--------------------------------+\n| KILL | |\n+--------------------------------------------+--------------------------------+\n| LEADING | |\n+--------------------------------------------+--------------------------------+\n| LEAVE | |\n+--------------------------------------------+--------------------------------+\n| LEFT | |\n+--------------------------------------------+--------------------------------+\n| LIKE | |\n+--------------------------------------------+--------------------------------+\n| LIMIT | |\n+--------------------------------------------+--------------------------------+\n| LINEAR | |\n+--------------------------------------------+--------------------------------+\n| LINES | |\n+--------------------------------------------+--------------------------------+\n| LOAD | |\n+--------------------------------------------+--------------------------------+\n| LOCALTIME | |\n+--------------------------------------------+--------------------------------+\n| LOCALTIMESTAMP | |\n+--------------------------------------------+--------------------------------+\n| LOCK | |\n+--------------------------------------------+--------------------------------+\n| LONG | |\n+--------------------------------------------+--------------------------------+\n| LONGBLOB | |\n+--------------------------------------------+--------------------------------+\n| LONGTEXT | |\n+--------------------------------------------+--------------------------------+\n| LOOP | |\n+--------------------------------------------+--------------------------------+\n| LOW_PRIORITY | |\n+--------------------------------------------+--------------------------------+\n| MASTER_HEARTBEAT_PERIOD | |\n+--------------------------------------------+--------------------------------+\n| MASTER_SSL_VERIFY_SERVER_CERT | |\n+--------------------------------------------+--------------------------------+\n| MATCH | |\n+--------------------------------------------+--------------------------------+\n| MAXVALUE | |\n+--------------------------------------------+--------------------------------+\n| MEDIUMBLOB | |\n+--------------------------------------------+--------------------------------+\n| MEDIUMINT | |\n+--------------------------------------------+--------------------------------+\n| MEDIUMTEXT | |\n+--------------------------------------------+--------------------------------+\n| MIDDLEINT | |\n+--------------------------------------------+--------------------------------+\n| MINUTE_MICROSECOND | |\n+--------------------------------------------+--------------------------------+\n| MINUTE_SECOND | |\n+--------------------------------------------+--------------------------------+\n| MOD | |\n+--------------------------------------------+--------------------------------+\n| MODIFIES | |\n+--------------------------------------------+--------------------------------+\n| NATURAL | |\n+--------------------------------------------+--------------------------------+\n| NOT | |\n+--------------------------------------------+--------------------------------+\n| NO_WRITE_TO_BINLOG | |\n+--------------------------------------------+--------------------------------+\n| NULL | |\n+--------------------------------------------+--------------------------------+\n| NUMERIC | |\n+--------------------------------------------+--------------------------------+\n| OFFSET | Added in MariaDB 10.6.0 |\n+--------------------------------------------+--------------------------------+\n| ON | |\n+--------------------------------------------+--------------------------------+\n| OPTIMIZE | |\n+--------------------------------------------+--------------------------------+\n| OPTION | |\n+--------------------------------------------+--------------------------------+\n| OPTIONALLY | |\n+--------------------------------------------+--------------------------------+\n| OR | |\n+--------------------------------------------+--------------------------------+\n| ORDER | |\n+--------------------------------------------+--------------------------------+\n| OUT | |\n+--------------------------------------------+--------------------------------+\n| OUTER | |\n+--------------------------------------------+--------------------------------+\n| OUTFILE | |\n+--------------------------------------------+--------------------------------+\n| OVER | |\n+--------------------------------------------+--------------------------------+\n| PAGE_CHECKSUM | |\n+--------------------------------------------+--------------------------------+\n| PARSE_VCOL_EXPR | |\n+--------------------------------------------+--------------------------------+\n| PARTITION | |\n+--------------------------------------------+--------------------------------+\n| POSITION | |\n+--------------------------------------------+--------------------------------+\n| PRECISION | |\n+--------------------------------------------+--------------------------------+\n| PRIMARY | |\n+--------------------------------------------+--------------------------------+\n| PROCEDURE | |\n+--------------------------------------------+--------------------------------+\n| PURGE | |\n+--------------------------------------------+--------------------------------+\n| RANGE | |\n+--------------------------------------------+--------------------------------+\n| READ | |\n+--------------------------------------------+--------------------------------+\n| READS | |\n+--------------------------------------------+--------------------------------+\n| READ_WRITE | |\n+--------------------------------------------+--------------------------------+\n| REAL | |\n+--------------------------------------------+--------------------------------+\n| RECURSIVE | |\n+--------------------------------------------+--------------------------------+\n| REF_SYSTEM_ID | |\n+--------------------------------------------+--------------------------------+\n| REFERENCES | |\n+--------------------------------------------+--------------------------------+\n| REGEXP | |\n+--------------------------------------------+--------------------------------+\n| RELEASE | |\n+--------------------------------------------+--------------------------------+\n| RENAME | |') WHERE help_topic_id = 483; -update help_topic set description = CONCAT(description, '\n+--------------------------------------------+--------------------------------+\n| REPEAT | |\n+--------------------------------------------+--------------------------------+\n| REPLACE | |\n+--------------------------------------------+--------------------------------+\n| REQUIRE | |\n+--------------------------------------------+--------------------------------+\n| RESIGNAL | |\n+--------------------------------------------+--------------------------------+\n| RESTRICT | |\n+--------------------------------------------+--------------------------------+\n| RETURN | |\n+--------------------------------------------+--------------------------------+\n| RETURNING | |\n+--------------------------------------------+--------------------------------+\n| REVOKE | |\n+--------------------------------------------+--------------------------------+\n| RIGHT | |\n+--------------------------------------------+--------------------------------+\n| RLIKE | |\n+--------------------------------------------+--------------------------------+\n| ROW_NUMBER | From MariaDB 10.7 |\n+--------------------------------------------+--------------------------------+\n| ROWS | |\n+--------------------------------------------+--------------------------------+\n| SCHEMA | |\n+--------------------------------------------+--------------------------------+\n| SCHEMAS | |\n+--------------------------------------------+--------------------------------+\n| SECOND_MICROSECOND | |\n+--------------------------------------------+--------------------------------+\n| SELECT | |\n+--------------------------------------------+--------------------------------+\n| SENSITIVE | |\n+--------------------------------------------+--------------------------------+\n| SEPARATOR | |\n+--------------------------------------------+--------------------------------+\n| SET | |\n+--------------------------------------------+--------------------------------+\n| SHOW | |\n+--------------------------------------------+--------------------------------+\n| SIGNAL | |\n+--------------------------------------------+--------------------------------+\n| SLOW | |\n+--------------------------------------------+--------------------------------+\n| SMALLINT | |\n+--------------------------------------------+--------------------------------+\n| SPATIAL | |\n+--------------------------------------------+--------------------------------+\n| SPECIFIC | |\n+--------------------------------------------+--------------------------------+\n| SQL | |\n+--------------------------------------------+--------------------------------+\n| SQLEXCEPTION | |\n+--------------------------------------------+--------------------------------+\n| SQLSTATE | |\n+--------------------------------------------+--------------------------------+\n| SQLWARNING | |\n+--------------------------------------------+--------------------------------+\n| SQL_BIG_RESULT | |\n+--------------------------------------------+--------------------------------+\n| SQL_CALC_FOUND_ROWS | |\n+--------------------------------------------+--------------------------------+\n| SQL_SMALL_RESULT | |\n+--------------------------------------------+--------------------------------+\n| SSL | |\n+--------------------------------------------+--------------------------------+\n| STARTING | |\n+--------------------------------------------+--------------------------------+\n| STATS_AUTO_RECALC | |\n+--------------------------------------------+--------------------------------+\n| STATS_PERSISTENT | |\n+--------------------------------------------+--------------------------------+\n| STATS_SAMPLE_PAGES | |\n+--------------------------------------------+--------------------------------+\n| STRAIGHT_JOIN | |\n+--------------------------------------------+--------------------------------+\n| TABLE | |\n+--------------------------------------------+--------------------------------+\n| TERMINATED | |\n+--------------------------------------------+--------------------------------+\n| THEN | |\n+--------------------------------------------+--------------------------------+\n| TINYBLOB | |\n+--------------------------------------------+--------------------------------+\n| TINYINT | |\n+--------------------------------------------+--------------------------------+\n| TINYTEXT | |\n+--------------------------------------------+--------------------------------+\n| TO | |\n+--------------------------------------------+--------------------------------+\n| TRAILING | |\n+--------------------------------------------+--------------------------------+\n| TRIGGER | |\n+--------------------------------------------+--------------------------------+\n| TRUE | |\n+--------------------------------------------+--------------------------------+\n| UNDO | |\n+--------------------------------------------+--------------------------------+\n| UNION | |\n+--------------------------------------------+--------------------------------+\n| UNIQUE | |\n+--------------------------------------------+--------------------------------+\n| UNLOCK | |\n+--------------------------------------------+--------------------------------+\n| UNSIGNED | |\n+--------------------------------------------+--------------------------------+\n| UPDATE | |\n+--------------------------------------------+--------------------------------+\n| USAGE | |\n+--------------------------------------------+--------------------------------+\n| USE | |\n+--------------------------------------------+--------------------------------+\n| USING | |\n+--------------------------------------------+--------------------------------+\n| UTC_DATE | |\n+--------------------------------------------+--------------------------------+\n| UTC_TIME | |\n+--------------------------------------------+--------------------------------+\n| UTC_TIMESTAMP | |\n+--------------------------------------------+--------------------------------+\n| VALUES | |\n+--------------------------------------------+--------------------------------+\n| VARBINARY | |\n+--------------------------------------------+--------------------------------+\n| VARCHAR | |\n+--------------------------------------------+--------------------------------+\n| VARCHARACTER | |\n+--------------------------------------------+--------------------------------+\n| VARYING | |\n+--------------------------------------------+--------------------------------+\n| WHEN | |\n+--------------------------------------------+--------------------------------+\n| WHERE | |\n+--------------------------------------------+--------------------------------+\n| WHILE | |\n+--------------------------------------------+--------------------------------+\n| WINDOW | Only disallowed for table |\n| | aliases. |\n+--------------------------------------------+--------------------------------+\n| WITH | |\n+--------------------------------------------+--------------------------------+\n| WRITE | |\n+--------------------------------------------+--------------------------------+\n| XOR | |\n+--------------------------------------------+--------------------------------+\n| YEAR_MONTH | |\n+--------------------------------------------+--------------------------------+\n| ZEROFILL | |\n+--------------------------------------------+--------------------------------+\n\nExceptions\n----------\n\nSome keywords are exceptions for historical reasons, and are permitted as\nunquoted identifiers. These include:\n\n+-----------------------------------------------------------------------------+\n| Keyword |\n+-----------------------------------------------------------------------------+\n| ACTION |\n+-----------------------------------------------------------------------------+\n| BIT |\n+-----------------------------------------------------------------------------+\n| DATE |\n+-----------------------------------------------------------------------------+\n| ENUM |\n+-----------------------------------------------------------------------------+\n| NO |\n+-----------------------------------------------------------------------------+\n| TEXT |\n+-----------------------------------------------------------------------------+\n| TIME |\n+-----------------------------------------------------------------------------+\n| TIMESTAMP |\n+-----------------------------------------------------------------------------+\n\nOracle Mode\n-----------\n\nIn Oracle mode, from MariaDB 10.3, there are a number of extra reserved words:\n\n+--------------------------------------------+--------------------------------+\n| Keyword | Notes |\n+--------------------------------------------+--------------------------------+\n| BODY | |\n+--------------------------------------------+--------------------------------+\n| ELSIF | |\n+--------------------------------------------+--------------------------------+\n| GOTO | |') WHERE help_topic_id = 483; -update help_topic set description = CONCAT(description, '\n+--------------------------------------------+--------------------------------+\n| HISTORY | <= MariaDB 10.3.6 only |\n+--------------------------------------------+--------------------------------+\n| MINUS | From MariaDB 10.6.1 |\n+--------------------------------------------+--------------------------------+\n| OTHERS | |\n+--------------------------------------------+--------------------------------+\n| PACKAGE | |\n+--------------------------------------------+--------------------------------+\n| PERIOD | <= MariaDB 10.3.6 only |\n+--------------------------------------------+--------------------------------+\n| RAISE | |\n+--------------------------------------------+--------------------------------+\n| ROWNUM | From MariaDB 10.6.1 |\n+--------------------------------------------+--------------------------------+\n| ROWTYPE | |\n+--------------------------------------------+--------------------------------+\n| SYSDATE | From MariaDB 10.6.1 |\n+--------------------------------------------+--------------------------------+\n| SYSTEM | <= MariaDB 10.3.6 only. Note |\n| | however that SYSTEM sometimes |\n| | needs to be quoted to avoid |\n| | confusion with |\n| | System-versioned tables. |\n+--------------------------------------------+--------------------------------+\n| SYSTEM_TIME | <= MariaDB 10.3.6 only |\n+--------------------------------------------+--------------------------------+\n| VERSIONING | <= MariaDB 10.3.6 only |\n+--------------------------------------------+--------------------------------+\n| WITHOUT | <= MariaDB 10.3.6 only |\n+--------------------------------------------+--------------------------------+\n\nFunction Names\n--------------\n\nIf the IGNORE_SPACE SQL_MODE flag is set, function names become reserved words.\n\nURL: https://mariadb.com/kb/en/reserved-words/') WHERE help_topic_id = 483; -insert into help_topic (help_topic_id,help_category_id,name,description,example,url) values (484,29,'String Literals','Strings are sequences of characters and are enclosed with quotes.\n\nThe syntax is:\n\n[_charset_name]\'string\' [COLLATE collation_name]\n\nFor example:\n\n\'The MariaDB Foundation\'\n_utf8 \'Foundation\' COLLATE utf8_unicode_ci;\n\nStrings can either be enclosed in single quotes or in double quotes (the same\ncharacter must be used to both open and close the string).\n\nThe ANSI SQL-standard does not permit double quotes for enclosing strings, and\nalthough MariaDB does by default, if the MariaDB server has enabled the\nANSI_QUOTES_SQL SQL_MODE, double quotes will be treated as being used for\nidentifiers instead of strings.\n\nStrings that are next to each other are automatically concatenated. For\nexample:\n\n\'The \' \'MariaDB \' \'Foundation\'\n\nand\n\n\'The MariaDB Foundation\'\n\nare equivalent.\n\nThe \\ (backslash character) is used to escape characters (unless the SQL_MODE\nhasn\'t been set to NO_BACKSLASH_ESCAPES). For example:\n\n\'MariaDB\'s new features\'\n\nis not a valid string because of the single quote in the middle of the string,\nwhich is treated as if it closes the string, but is actually meant as part of\nthe string, an apostrophe. The backslash character helps in situations like\nthis:\n\n\'MariaDB\\\'s new features\'\n\nis now a valid string, and if displayed, will appear without the backslash.\n\nSELECT \'MariaDB\\\'s new features\';\n+------------------------+\n| MariaDB\'s new features |\n+------------------------+\n| MariaDB\'s new features |\n+------------------------+\n\nAnother way to escape the quoting character is repeating it twice:\n\nSELECT \'I\'\'m here\', \"\"\"Double\"\"\";\n+----------+----------+\n| I\'m here | \"Double\" |\n+----------+----------+\n| I\'m here | \"Double\" |\n+----------+----------+\n\nEscape Sequences\n----------------\n\nThere are other escape sequences also. Here is a full list:\n\n+-----------------------------------------------+-----------------------------+\n| Escape sequence | Character |\n+-----------------------------------------------+-----------------------------+\n| \\0 | ASCII NUL (0x00). |\n+-----------------------------------------------+-----------------------------+\n| \\\' | Single quote (\"\'\"). |\n+-----------------------------------------------+-----------------------------+\n| \\\" | Double quote (\"\"\"). |\n+-----------------------------------------------+-----------------------------+\n| \\b | Backspace. |\n+-----------------------------------------------+-----------------------------+\n| \\n | Newline, or linefeed,. |\n+-----------------------------------------------+-----------------------------+\n| \\r | Carriage return. |\n+-----------------------------------------------+-----------------------------+\n| \\t | Tab. |\n+-----------------------------------------------+-----------------------------+\n| \\Z | ASCII 26 (Control+Z). See |\n| | note following the table. |\n+-----------------------------------------------+-----------------------------+\n| \\\\ | Backslash (\"\\\"). |\n+-----------------------------------------------+-----------------------------+\n| \\% | \"%\" character. See note |\n| | following the table. |\n+-----------------------------------------------+-----------------------------+\n| \\_ | A \"_\" character. See note |\n| | following the table. |\n+-----------------------------------------------+-----------------------------+\n\nEscaping the % and _ characters can be necessary when using the LIKE operator,\nwhich treats them as special characters.\n\nThe ASCII 26 character (\\Z) needs to be escaped when included in a batch file\nwhich needs to be executed in Windows. The reason is that ASCII 26, in\nWindows, is the end of file (EOF).\n\nBackslash (\\), if not used as an escape character, must always be escaped.\nWhen followed by a character that is not in the above table, backslashes will\nsimply be ignored.\n\nURL: https://mariadb.com/kb/en/string-literals/','','https://mariadb.com/kb/en/string-literals/'); -insert into help_topic (help_topic_id,help_category_id,name,description,example,url) values (485,29,'Table Value Constructors','MariaDB starting with 10.3.3\n----------------------------\nTable Value Constructors were introduced in MariaDB 10.3.3\n\nSyntax\n------\n\nVALUES ( row_value[, row_value...]), (...)...\n\nDescription\n-----------\n\nIn Unions, Views, and sub-queries, a Table Value Constructor (TVC) allows you\nto inject arbitrary values into the result-set. The given values must have the\nsame number of columns as the result-set, otherwise it returns Error 1222.\n\nExamples\n--------\n\nUsing TVC\'s with UNION operations:\n\nCREATE TABLE test.t1 (val1 INT, val2 INT);\nINSERT INTO test.t1 VALUES(5, 8), (3, 4), (1, 2);\n\nSELECT * FROM test.t1\nUNION\nVALUES (70, 90), (100, 110);\n\n+------+------+\n| val1 | val2 |\n+------+------+\n| 5 | 8 | \n| 3 | 4 |\n| 1 | 2 |\n| 70 | 90 |\n| 100 | 110 |\n+------+------+\n\nUsing TVC\'s with a CREATE VIEW statement:\n\nCREATE VIEW v1 AS VALUES (7, 9), (9, 10);\n\nSELECT * FROM v1;\n+---+----+\n| 7 | 9 |\n+---+----+\n| 7 | 9 |\n| 9 | 10 |\n+---+----+\n\nUsing TVC with an ORDER BY clause:\n\nSELECT * FROM test.t1\nUNION\nVALUES (10, 20), (30, 40), (50, 60), (70, 80)\nORDER BY val1 DESC;\n\nUsing TVC with LIMIT clause:\n\nSELECT * FROM test.t1\nUNION\nVALUES (10, 20), (30, 40), (50, 60), (70, 80)\nLIMIT 2 OFFSET 4;\n\n+------+------+\n| val1 | val2 |\n+------+------+\n| 30 | 40 | \n| 50 | 60 |\n+------+------+\n\nURL: https://mariadb.com/kb/en/table-value-constructors/','','https://mariadb.com/kb/en/table-value-constructors/'); -insert into help_topic (help_topic_id,help_category_id,name,description,example,url) values (486,29,'User-Defined Variables','User-defined variables are variables which can be created by the user and\nexist in the session. This means that no one can access user-defined variables\nthat have been set by another user, and when the session is closed these\nvariables expire. However, these variables can be shared between several\nqueries and stored programs.\n\nUser-defined variables names must be preceded by a single at character (@).\nWhile it is safe to use a reserved word as a user-variable name, the only\nallowed characters are ASCII letters, digits, dollar sign ($), underscore (_)\nand dot (.). If other characters are used, the name can be quoted in one of\nthe following ways:\n\n* @`var_name`\n* @\'var_name\'\n* @\"var_name\"\n\nThese characters can be escaped as usual.\n\nUser-variables names are case insensitive, though they were case sensitive in\nMySQL 4.1 and older versions.\n\nUser-defined variables cannot be declared. They can be read even if no value\nhas been set yet; in that case, they are NULL. To set a value for a\nuser-defined variable you can use:\n\n* SET statement;\n* := operator within a SQL statement;\n* SELECT ... INTO.\n\nSince user-defined variables type cannot be declared, the only way to force\ntheir type is using CAST() or CONVERT():\n\nSET @str = CAST(123 AS CHAR(5));\n\nIf a variable has not been used yet, its value is NULL:\n\nSELECT @x IS NULL;\n+------------+\n| @x IS NULL |\n+------------+\n| 1 |\n+------------+\n\nIt is unsafe to read a user-defined variable and set its value in the same\nstatement (unless the command is SET), because the order of these actions is\nundefined.\n\nUser-defined variables can be used in most MariaDB\'s statements and clauses\nwhich accept an SQL expression. However there are some exceptions, like the\nLIMIT clause.\n\nThey must be used to PREPARE a prepared statement:\n\n@sql = \'DELETE FROM my_table WHERE c>1;\';\nPREPARE stmt FROM @sql;\nEXECUTE stmt;\nDEALLOCATE PREPARE stmt;\n\nAnother common use is to include a counter in a query:\n\nSET @var = 0;\nSELECT a, b, c, (@var:=@var+1) AS counter FROM my_table;\n\nInformation Schema\n------------------\n\nUser-defined variables can be viewed in the Information Schema USER_VARIABLES\nTable (as part of the User Variables plugin) from MariaDB 10.2.\n\nFlushing User-Defined Variables\n-------------------------------\n\nUser-defined variables are reset and the Information Schema table emptied with\nthe FLUSH USER_VARIABLES statement.\n\nSET @str = CAST(123 AS CHAR(5));\n\nSELECT * FROM information_schema.USER_VARIABLES ORDER BY VARIABLE_NAME;\n+---------------+----------------+---------------+--------------------+\n| VARIABLE_NAME | VARIABLE_VALUE | VARIABLE_TYPE | CHARACTER_SET_NAME |\n+---------------+----------------+---------------+--------------------+\n| str | 123 | VARCHAR | utf8mb3 |\n+---------------+----------------+---------------+--------------------+\n\nFLUSH USER_VARIABLES;\n\nSELECT * FROM information_schema.USER_VARIABLES ORDER BY VARIABLE_NAME;\nEmpty set (0.000 sec)\n\nURL: https://mariadb.com/kb/en/user-defined-variables/','','https://mariadb.com/kb/en/user-defined-variables/'); -insert into help_topic (help_topic_id,help_category_id,name,description,example,url) values (487,29,'Delimiters','The default delimiter in the mariadb client is the semicolon.\n\nWhen creating stored programs from the command-line, it is likely you will\nneed to differentiate between the regular delimiter and a delimiter inside a\nBEGIN END block. To understand better, consider the following example:\n\nCREATE FUNCTION FortyTwo() RETURNS TINYINT DETERMINISTIC\nBEGIN\n DECLARE x TINYINT;\n SET x = 42;\n RETURN x;\nEND;\n\nIf you enter the above line by line, the mariadb client will treat the first\nsemicolon, at the end of the DECLARE x TINYINT line, as the end of the\nstatement. Since that\'s only a partial definition, it will throw a syntax\nerror, as follows:\n\nCREATE FUNCTION FortyTwo() RETURNS TINYINT DETERMINISTIC\nBEGIN\nDECLARE x TINYINT;\nERROR 1064 (42000): You have an error in your SQL syntax; \ncheck the manual that corresponds to your MariaDB server version\n for the right syntax to use near \'\' at line 3\n\nThe solution is to specify a distinct delimiter for the duration of the\nprocess, using the DELIMITER command. The delimiter can be any set of\ncharacters you choose, but it needs to be a distinctive set of characters that\nwon\'t cause further confusion. // is a common choice, and used throughout the\nKnowledge Base.\n\nHere\'s how the function could be successfully entered from the mariadb client\nwith the new delimiter.\n\nDELIMITER //\n\nCREATE FUNCTION FortyTwo() RETURNS TINYINT DETERMINISTIC\nBEGIN\n DECLARE x TINYINT;\n SET x = 42;\n RETURN x;\nEND\n\n//\n\nDELIMITER ;\n\nAt the end, the delimiter is restored to the default semicolon. The \\g and \\G\ndelimiters can always be used, even when a custom delimiter is specified.\n\nURL: https://mariadb.com/kb/en/delimiters/','','https://mariadb.com/kb/en/delimiters/'); -insert into help_topic (help_topic_id,help_category_id,name,description,example,url) values (488,29,'SQL_MODE=ORACLE','From MariaDB 10.3, setting the sql_mode system variable to Oracle allows the\nserver to understand a subset of Oracle\'s PL/SQL language. For example:\n\nSET SQL_MODE=\'ORACLE\';\n\nAll traditional MariaDB SQL/PSM syntax should work as before, as long as it\ndoes not conflict with Oracle\'s PL/SQL syntax. All MariaDB functions should be\nsupported in both normal and Oracle modes.\n\nPrior to MariaDB 10.3, MariaDB does not support Oracle\'s PL/SQL language, and\nSET SQL_MODE=ORACLE is only an alias for the following sql_mode in those\nversions:\n\nSET SQL_MODE=\'PIPES_AS_CONCAT, ANSI_QUOTES, IGNORE_SPACE, NO_KEY_OPTIONS,\nNO_TABLE_OPTIONS, NO_FIELD_OPTIONS, NO_AUTO_CREATE_USER\';\n\nFrom MariaDB 10.3, SET SQL_MODE=ORACLE is same as:\n\nSET SQL_MODE=\'PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE,ORACLE,NO_KEY_OPTIONS,\nNO_TABLE_OPTIONS,NO_FIELD_OPTIONS,NO_AUTO_CREATE_USER,SIMULTANEOUS_ASSIGNMENT\';\n\nSupported Syntax in Oracle Mode\n-------------------------------\n\nStored Procedures and Stored Functions\n--------------------------------------\n\nOracle mode makes the following changes to Stored Procedures and Stored\nFunctions:\n\n+-----------------------------------------+-----------------------------------+\n| Oracle syntax | Description |\n+-----------------------------------------+-----------------------------------+\n| CREATE PROCEDURE p1 (param OUT INT) | ANSI uses (OUT param INT) |\n+-----------------------------------------+-----------------------------------+\n| CREATE PROCEDURE p1 (a IN OUT INT) | ANSI uses (INOUT param INT) |\n+-----------------------------------------+-----------------------------------+\n| AS before function body | CREATE FUNCTION f1 RETURN NUMBER |\n| | AS BEGIN... |\n+-----------------------------------------+-----------------------------------+\n| IS before function body | CREATE FUNCTION f1 RETURN NUMBER |\n| | IS BEGIN... |\n+-----------------------------------------+-----------------------------------+\n| If function has no parameters then | Example: CREATE PROCEDURE p1 AS |\n| parentheses must be omitted | BEGIN NULL; END; |\n+-----------------------------------------+-----------------------------------+\n| CREATE PROCEDURE p1 AS BEGIN END p1; | Optional routine name after END |\n| | keyword. MDEV-12089 |\n+-----------------------------------------+-----------------------------------+\n| CREATE FUNCTION f1(a VARCHAR) | VARCHAR can be used without |\n| | length for routine parameters |\n| | and RETURN clause. The length is |\n| | inherited from the argument at |\n| | call time. MDEV-10596 |\n+-----------------------------------------+-----------------------------------+\n| CREATE AGGREGATE FUNCTION f1( ) | Creates an aggregate function, |\n| | which performs the function |\n| | against a set of rows and |\n| | returns one aggregate result. |\n+-----------------------------------------+-----------------------------------+\n| No CALL needed in Stored Procedures | In Oracle mode one can call |\n| | other stored procedures with |\n| | name only. MDEV-12107 |\n+-----------------------------------------+-----------------------------------+\n| RETURN. Can also be used in stored | ANSI uses RETURNS. MariaDB mode |\n| procedures | only supports RETURNS in stored |\n| | functions |\n+-----------------------------------------+-----------------------------------+\n\nCursors\n-------\n\nOracle mode makes the following changes to Cursors:\n\n+-----------------------------------------+-----------------------------------+\n| Oracle syntax | Description |\n+-----------------------------------------+-----------------------------------+\n| CREATE PROCEDURE p1 AS CURSOR cur IS | Explicit cursor with FOR loop. |\n| (SELECT a, b FROM t1); BEGIN FOR rec | MDEV-10581 |\n| IN cur ... | |\n+-----------------------------------------+-----------------------------------+\n| CREATE PROCEDURE p1 AS rec IN (SELECT | Implicit cursor with FOR loop. |\n| a, b FROM t1) | MDEV-12098 |\n+-----------------------------------------+-----------------------------------+\n| CURSOR c(prm_a VARCHAR2, prm_b | Cursor with parameters. |\n| VARCHAR2) ... OPEN c(1,2) | MDEV-10597 |\n+-----------------------------------------+-----------------------------------+\n| CURSOR c(prm_a VARCHAR2, prm_b | Cursor with parameters and FOR |\n| VARCHAR2) ... FOR rec in c(1,2) | loop. MDEV-12314 |\n+-----------------------------------------+-----------------------------------+\n| s %ISOPEN, %ROWCOUNT, %FOUND, %NOTFOUND | Explicit cursor attributes. |\n| | MDEV-10582 |\n+-----------------------------------------+-----------------------------------+\n\nLOOP\n----\n\nOracle mode makes the following changes to LOOP:\n\n+-----------------------------------------+-----------------------------------+\n| Oracle syntax | Description |\n+-----------------------------------------+-----------------------------------+\n| FOR i IN 1..10 LOOP ... END LOOP | Numeric FOR loop. MDEV-10580 |\n+-----------------------------------------+-----------------------------------+\n| GOTO | GOTO statement. MDEV-10697 |\n+-----------------------------------------+-----------------------------------+\n| <