SQL   SyntaxFunctionsData types   compatibility table
Fork Download this doc Report a mistake

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
TRUNCATE TABLE name Yes Yes Yes Yes Yes No Firebird SQL:2008 DROP TABLE tbl1
CREATE TABLE tbl1 (...)
RENAME TABLE tbl TO tbl2 Yes RENAME TABLE... No EXEC sp_rename Yes No see notes
ALTER TABLE tbl RENAME TO tbl2 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
... FOREIGN KEY ... ON DELETE NO ACTION RESTRICT Not explicitly Yes Yes ? Yes FOREIGN KEY ...
... FOREIGN KEY ... ON DELETE RESTRICT Yes ? Yes No ? Yes FOREIGN KEY ...
... FOREIGN KEY ... ON DELETE SET DEFAULT InnoDB reject it ? Yes Yes ? Yes
... FOREIGN KEY ... ON UPDATE ... 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
ALTER TABLE tbl CHANGE col1 col2 INT NOT NULL Yes ? ? No ? ? see notes
ALTER TABLE tbl RENAME COLUMN col1 TO col2 since v8.0 (2018) ? Yes EXEC sp_rename Yes Yes see notes
ALTER TABLE tbl MODIFY col INT NOT NULL Yes Yes ? No ? ? see notes
ALTER TABLE tbl ALTER COLUMN col INT No ? ? Yes ? ? see notes
Join syntax
... FROM tbl LEFT JOIN tbl2 ON ... Yes ? Yes Yes Yes Yes Informix
... FROM tbl RIGHT JOIN tbl2 ON ... 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
SELECT ... LIMIT 0, 5 Yes No No No ? No
SELECT TOP(5) ... 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
# One line comment... Yes No No No No No
Notes
Reference manuals
SQL standard publications