Compatible Compatible with warning Not compatible Unknown
Syntax | MySQL MariaDB |
Oracle Database |
PostgreSQL | Microsoft SQL Server |
IBM DB2 | SQLite | Other database systems |
ANSI/ISO standard |
Universal alternative | ||
---|---|---|---|---|---|---|---|---|---|---|---|
DELETE FROM tbl | Yes | Yes | Yes | Yes | ? | Yes | |||||
INSERT INTO ... SELECT ... | Yes | Yes | Yes | Yes | ? | Yes | |||||
INSERT INTO tbl (col...) VALUES (...) | Yes | Yes | Yes | Yes | ? | Yes | |||||
INSERT INTO tbl (col...) VALUES (...), (...) | Yes | No | Yes | Yes | ? | Yes | |||||
SELECT * FROM tbl | Yes | Yes | Yes | Yes | Yes | Yes | Microsoft Access | and all others... | SQL-92 | ||
SELECT "col1" FROM tbl | sql_mode=ANSI_QUOTES not set by default |
Yes | Yes | QUOTED_IDENTIFIER is ON by default |
Yes | Yes | SQL-92 | ||||
SELECT DISTINCT ... | Yes | Yes | Yes | Yes | ? | Yes | |||||
SELECT ... UNION SELECT ... | Yes | Yes | Yes | Yes | Yes | Yes | |||||
SELECT ... UNION ALL SELECT ... | Yes | Yes | Yes | Yes | Yes | Yes | |||||
... WHERE ... AND ... OR ... | Yes | ? | ? | Yes | ? | Yes | |||||
... WHERE x BETWEEN 1 AND 9 | Yes | ? | ? | Yes | ? | ? | |||||
... WHERE x IN (...) | Yes | ? | ? | Yes | ? | ? | |||||
... WHERE x IS TRUE OR x IS FALSE OR x IS NULL OR x IS UNKNOWN | Yes | ? | ? | ? | ? | ? | |||||
... GROUP BY ... | Yes | ? | ? | Yes | ? | ? | SQL-92 | ||||
... ORDER BY col1 ASC, col2 DESC | Yes | ? | ? | Yes | ? | Yes | SQL-92 | ||||
UPDATE tbl SET col1 = 'val1', col2 = 'val2' | Yes | Yes | Yes | Yes | ? | Yes | Firebird | ||||
Table modifications | |||||||||||
CREATE TABLE name (col...) | Yes | ? | Yes | Yes | ? | Yes | SQL-92 | ||||
DROP TABLE name | Yes | ? | Yes | Yes | ? | Yes | SQL-92 | ||||
Yes | Yes | Yes | Yes | Yes | No | Firebird | SQL:2008 | DROP TABLE tbl1 CREATE TABLE tbl1 (...) |
|||
Yes | RENAME |
No | EXEC sp_rename | Yes | No | see notes | |||||
Yes | Yes | Yes | EXEC sp_rename | No | Yes | see notes | |||||
Foreign key | |||||||||||
CREATE TABLE tbl1 (... FOREIGN KEY (col1) REFERENCES tbl2 (col2)) | RESTRICT | only ON DELETE NO ACTION | NO ACTION | NO ACTION | ? | NO ACTION | |||||
... CONSTRAINT fk1 FOREIGN KEY ... | Yes | Yes | Yes | Yes | ? | Yes | |||||
... FOREIGN KEY ... ON DELETE CASCADE | Yes | Yes | Yes | Yes | ? | Yes | |||||
... FOREIGN KEY ... ON DELETE SET NULL | Yes | Yes | Yes | Yes | ? | Yes | |||||
RESTRICT | Not explicitly | Yes | Yes | ? | Yes | FOREIGN KEY ... | |||||
Yes | ? | Yes | No | ? | Yes | FOREIGN KEY ... | |||||
InnoDB reject it | ? | Yes | Yes | ? | Yes | ||||||
Yes | No | Yes | Yes | ? | Yes | ||||||
Column modifications | |||||||||||
ALTER TABLE tbl ADD col VARCHAR(20) NULL | Yes | Yes | Yes | Yes | Yes | Yes | |||||
ALTER TABLE tbl DROP COLUMN col | Yes | Yes | Yes | Yes | Yes | since v3.35 (2021) | see notes | ||||
Yes | ? | ? | No | ? | ? | see notes | |||||
since v8.0 (2018) | ? | Yes | EXEC sp_rename | Yes | Yes | see notes | |||||
Yes | Yes | ? | No | ? | ? | see notes | |||||
No | ? | ? | Yes | ? | ? | see notes | |||||
Join syntax | |||||||||||
... FROM tbl LEFT JOIN tbl2 ON ... | Yes | ? | Yes | Yes | Yes | Yes | Informix | ||||
Yes | ? | Yes | Yes | Yes | No | Informix | ...FROM tbl LEFT JOIN tbl2 ON... | ||||
... FROM tbl FULL OUTER JOIN tbl2 ON ... | Yes | ? | Yes | Yes | Yes | No | Informix | ||||
... FROM tbl INNER JOIN tbl2 ON ... | Yes | ? | Yes | Yes | Yes | Yes | Informix | ||||
Paging syntax | |||||||||||
SELECT ... LIMIT 5 OFFSET 0 | Yes | No | Yes | No | ? | Yes | |||||
Yes | No | No | No | ? | No | ||||||
No | No | No | Yes | ? | No | ||||||
SELECT ... ORDER BY col OFFSET 0 ROWS FETCH NEXT 5 ROWS ONLY | No | since v12c (2013) | No | Yes | ? | No | |||||
Comment | |||||||||||
-- One line comment... | Yes | Yes | Yes | Yes | Yes | Yes | |||||
/* Multi-line comment... */ | Yes | Yes | Yes | Yes | Yes | Yes | |||||
Yes | No | No | No | No | No |
Notes
-
Alternative to: ALTER TABLE tbl RENAME TO tbl2
CREATE TABLE tbl2 (...)
INSERT INTO tbl2 SELECT * FROM tbl
DROP TABLE tbl -
Alternative to: ALTER TABLE tbl RENAME/CHANGE/MODIFY/ALTER COLUMN
CREATE TABLE tbl2 (... col2 INT)
INSERT INTO tbl2 SELECT ... col1 FROM tbl
DROP TABLE tbl
CREATE TABLE tbl (... col2 INT)
INSERT INTO tbl SELECT * FROM tbl2
DROP TABLE tbl2
Reference manuals
SQL standard publications