VERSION() is a built-in scalar function (or system variable in some dialects) that returns a text string identifying the exact version of the running database engine, often including build metadata and operating system information. Although not part of the ANSI SQL standard, most major database systems expose an equivalent helper because it is invaluable for diagnostics, feature gating, conditional logic, and support tickets. In MySQL and MariaDB it is implemented as the VERSION() function; PostgreSQL offers the lowercase version() function; SQL Server exposes the @@VERSION global variable; Oracle surfaces version data through the V$VERSION and PRODUCT_COMPONENT_VERSION views; SQLite uses sqlite_version(). Because formatting is vendor-specific, always parse the string defensively if you depend on it in application code. The function is read-only and has no side effects.
#VALUE!
SHOW VARIABLES, @@version_comment, SELECT @@GLOBAL.version, system metadata functions, server properties
MySQL 3.22
It returns a full version string that identifies the exact release and build of the database server you are connected to.
Only if you branch your logic per vendor. The syntax and output format differ, so check the database type first.
Yes. Because it queries the running server, the returned value reflects the current version without a restart of your client.
No. The SQL standard does not define a built-in that reports server version, so you must use the vendor’s approach.