Standard SQL commands for database management and querying
SELECT * FROM table_name;Select all columns from a tableSELECT col1, col2 FROM table_name;Select specific columnsSELECT DISTINCT column FROM table;Select distinct valuesSELECT * FROM table WHERE condition;Filter resultsINSERT INTO table (col1, col2) VALUES (val1, val2);Insert new rowUPDATE table SET col1 = val1 WHERE condition;Update existing rowsDELETE FROM table WHERE condition;Delete rowsTRUNCATE TABLE table_name;Empty a tableSELECT * FROM t1 INNER JOIN t2 ON t1.id = t2.id;Inner Join (matches only)SELECT * FROM t1 LEFT JOIN t2 ON t1.id = t2.id;Left Join (all from left)SELECT * FROM t1 RIGHT JOIN t2 ON t1.id = t2.id;Right Join (all from right)SELECT * FROM t1 FULL OUTER JOIN t2 ON t1.id = t2.id;Full Join (all from both)SELECT COUNT(*) FROM table;Count rowsSELECT SUM(col) FROM table;Sum valuesSELECT AVG(col) FROM table;Average valueSELECT col, COUNT(*) FROM table GROUP BY col;Group rowsSELECT col, COUNT(*) FROM table GROUP BY col HAVING COUNT(*) > 5;Filter groupsCREATE TABLE table (id INT, name VARCHAR(50));Create tableALTER TABLE table ADD column_name datatype;Add columnDROP TABLE table_name;Delete tableCREATE INDEX idx_name ON table (column);Create indexBeautify and format your SQL queries instantly. Supports multiple SQL dialects.
Try Tool →Learn best practices for optimizing database performance, indexing, and query tuning.
Read Article →Detailed comparison between NoSQL and SQL databases. When to use which?
Compare →