SQLite Forum

3.25 math functions vs. extension-functions.c
It is a bit unfortunate that there isn't a common definition for the logarithmic function upon which all database systems agree - for mathematicians the base-e logarithm (`LN`) is the only _natural_ logarithm, for computer scientist the base-2 logarithm (`LOG2`) is the only _natural_ logarithm.

**PostGreSQL** uses indeed `LOG` for the _base-10 logarithm_ (see [PostGreSQL documentation](https://www.postgresql.org/docs/devel/functions-math.html), while [**MySQL**](https://dev.mysql.com/doc/refman/8.0/en/mathematical-functions.html#function_log) and [**SQL Server**](https://docs.microsoft.com/de-de/sql/t-sql/functions/log-transact-sql?view=sql-server-ver15) both use `LOG` for the _natural logarithm_. **Oracle** also uses `LOG` for the _natural logarithm_.

AFAIK the latest SQL standard defines the name `LN` for the _natural logarithm_, but no names for other logarithms.

Fortunately, the _SQLite Math Extension_ implements `LN`, `LOG10`, and `LOG2` in addition to `LOG`. So, my recommendation would be:

"Be explicit and use `LN`, `LOG10`, or `LOG2` depending on the type of logarithm you need. Don't use `LOG` unless you need to explicitly specify the base."

Note: This does not relieve you from checking and potentially adjusting the SQL code when moving from one database system to another.