Tag

SQL Differences

SQL differences

DISTINCT ON Works on PostgreSQL Only

DISTINCT ON (customer_id) is a neat way to keep each customer’s latest order on PostgreSQL, and none of the other three engines has it. SQLite, MySQL and MariaDB report a …

SQL differences

MySQL Refuses a Plain DEFAULT Value on TEXT Columns

A notes column declared as TEXT DEFAULT '' works on SQLite, PostgreSQL and MariaDB. MySQL refuses the CREATE TABLE. MySQL 8.0.13 and later accept a default written as an …

SQL differences

MySQL Refuses CREATE INDEX IF NOT EXISTS

Migrations that may run twice often say CREATE INDEX IF NOT EXISTS, and SQLite, PostgreSQL and MariaDB accept it. MySQL stops the migration with a syntax error. MySQL …

SQL differences

PostgreSQL Refuses Select List Names in HAVING

A report of repeat customers names its count of orders n in the select list and filters on that name in HAVING. SQLite, MySQL and MariaDB run it, and PostgreSQL refuses …

SQL differences

SQLite Has No CREATE OR REPLACE VIEW

CREATE OR REPLACE VIEW lets a migration change a view in one step on PostgreSQL, MySQL and MariaDB. On SQLite the statement is a syntax error. SQLite can only drop a view …

SQL differences

SQLite Has No TRUNCATE Statement

Test setups often empty their tables with TRUNCATE TABLE between runs. PostgreSQL, MySQL and MariaDB have it, and SQLite refuses it. SQLite empties a table quickly with a …

SQL differences

VARCHAR Without a Length Fails on MySQL and MariaDB

Schemas written for PostgreSQL often declare names and notes as plain VARCHAR, with no length. MySQL and MariaDB refuse that CREATE TABLE, since they want a length on …