Skip to content
NotesSQL CommandsVerifyPDF

SQL Commands

  1. What are the main categories of SQL commands?

    Category Commands
    DDL CREATE, ALTER, DROP
    DML INSERT, UPDATE, DELETE
    DQL SELECT
    DCL GRANT, REVOKE
    TCL BEGIN, COMMIT, ROLLBACK
    Filtering WHERE, IN, BETWEEN, LIKE
    Aggregation COUNT, SUM, AVG, MIN, MAX
    Grouping GROUP BY, HAVING
    Sorting ORDER BY, LIMIT
    Set operations UNION, INTERSECT, EXCEPT
  2. What are the join types?

    INNER, LEFT, RIGHT, FULL and CROSS JOIN.

  3. What are views?

    Named queries that expose results as a virtual table.

  4. What are indexes?

    Data structures that improve certain queries at the cost of storage and write overhead.

  5. What types of SQL functions are available?

    String manipulation, mathematical functions, date-time operations, pattern matching and type conversion.

  6. What are some recommended practices?

    Use parameterized queries and carefully restrict UPDATE and DELETE operations.

Example

SELECT category_id,
       SUM(amount_cents) AS total
FROM expenses
GROUP BY category_id
HAVING SUM(amount_cents) > 10000
ORDER BY total DESC;

Reference

SQL Commands by Pandeeswari M. Examples use PostgreSQL-compatible syntax.