Loading…
Loading…
SQL
A complete SQL course for students and working developers: queries, joins, aggregation, subqueries, window functions, data changes, types and functions, reporting, design, DDL, indexes, security, transactions, procedural SQL, performance and graded exercises. 72 articles with practice quizzes.
A catalogue of common SQL mistakes in queries, schemas and applications, with the fix for each: NOT IN with NULLs, join fan-out hidden by DISTINCT, floating-point money, comma-separated lists, BETWEEN on timestamps, deep OFFSET paging, N+1 queries, EAV tables and more.
kvi5hnuCode Sprout team member11 minHow to find out why a query is slow and fix it: reading EXPLAIN and EXPLAIN ANALYZE, costs, estimated and actual rows, scan and join methods, disk sorts, statistics, misestimates and extended statistics, top-N queries, finding slow queries with pg_stat_statements, and a tuning checklist.
kvi5hnuCode Sprout team member12 minBuilding and running SQL at run time with EXECUTE, format and USING: looping over tables, optional search filters, generating DDL, and staying safe from injection; then storing large text and binary data with TOAST, bytea and the large object facility, and when files belong outside the database.
kvi5hnuCode Sprout team member11 minHow triggers run code automatically when data changes: BEFORE and AFTER triggers, row and statement level, NEW and OLD, timestamps, rule enforcement, audit logs, transition tables, INSTEAD OF triggers, a closure table and its drift check, and when to avoid triggers.
kvi5hnuCode Sprout team member12 minHow to store reusable logic in the database: SQL and PL/pgSQL functions, parameters with defaults and named notation, functions that return tables, volatility and STRICT, procedures with CALL and COMMIT, SECURITY DEFINER, overloading and replacing functions, and when logic belongs in the database.
kvi5hnuCode Sprout team member11 minHandling errors and working through results in PL/pgSQL: EXCEPTION blocks, catching errors by name, SQLSTATE and SQLERRM, raising your own errors, GET STACKED DIAGNOSTICS, skipping bad rows, explicit and SQL cursors, and bulk processing with arrays instead of row-by-row loops.
kvi5hnuCode Sprout team member10 minAn introduction to procedural code inside the database with PL/pgSQL: anonymous DO blocks, functions, declaring variables with %TYPE and %ROWTYPE, SELECT INTO, IF and CASE, loops over ranges, queries and arrays, RAISE NOTICE, and how Oracle PL/SQL and T-SQL compare.
kvi5hnuCode Sprout team member9 minWhat happens when transactions run at the same time: MVCC and row versions, the isolation levels and the anomalies they allow, lost updates and how to prevent them, write skew and SERIALIZABLE, row locks with FOR UPDATE, NOWAIT and SKIP LOCKED, deadlocks, and retrying failed transactions.
kvi5hnuCode Sprout team member15 minHow transactions group statements into all-or-nothing units: BEGIN, COMMIT and ROLLBACK, the ACID properties, autocommit, what happens when a statement fails (and how databases differ), savepoints, transactions in application code, and keeping transactions short.
kvi5hnuCode Sprout team member9 minHow SQL injection works and how to prevent it: why pasting input into SQL text is dangerous, stacked queries, parameterized queries and prepared statements in SQL and application code, safe dynamic identifiers, LIKE and IN lists, ORMs, and defence in depth.
kvi5hnuCode Sprout team member9 minHow databases control who can do what: roles, users and group roles, GRANT and REVOKE on tables and columns, views as a security layer, default privileges, row-level security policies, superusers and owners, and least-privilege designs for applications.
kvi5hnuCode Sprout team member11 minHow to query a database about itself: listing tables and columns with the standard information_schema, finding constraints and foreign keys, PostgreSQL's system catalogs for sizes and indexes, auditing a schema, generating SQL from metadata, comments, and the equivalents in other databases.
kvi5hnuCode Sprout team member8 minHow SQL views work: saving queries under a name, querying and joining views, updatable views and WITH CHECK OPTION, how views depend on tables, using views for security and stable interfaces, and materialized views that store results and need refreshing.
kvi5hnuCode Sprout team member10 minHow database indexes work and how to use them: B-trees, reading EXPLAIN to see whether an index is used, composite index column order, why functions and leading wildcards defeat indexes, expression, partial and covering indexes, selectivity, the cost of indexes, full-text search and trigram indexes.
kvi5hnuCode Sprout team member14 minHow databases generate primary keys: identity columns (ALWAYS and BY DEFAULT), getting new keys back with RETURNING, why gaps appear, sequences shared between tables, SERIAL and AUTO_INCREMENT, random and time-ordered UUIDs, and how to choose between integer and UUID keys.
kvi5hnuCode Sprout team member11 minHow to change existing tables safely: adding, renaming and dropping columns, changing types with USING, adding constraints to existing data with NOT VALID and VALIDATE, foreign key actions such as CASCADE and SET NULL, DROP and CASCADE, transactional DDL, and migrations on live databases.
kvi5hnuCode Sprout team member10 minHow to create tables that protect their data: column definitions, DEFAULT, NOT NULL, UNIQUE and NULLs, PRIMARY KEY, FOREIGN KEY, column and table CHECK constraints, naming constraints, generated columns, exclusion constraints for overlapping ranges, and deferrable constraints.
kvi5hnuCode Sprout team member10 minWhat normalization is and why it matters: update, insert and delete anomalies, functional dependencies and how to test them with SQL, first, second and third normal form and BCNF, decomposing a flat table without losing data, and when to denormalize deliberately.
kvi5hnuCode Sprout team member11 minHow to design a relational database: finding entities and attributes in requirements, choosing primary keys, one-to-many, one-to-one and many-to-many relationships, junction tables, optional and mandatory participation, recursive relationships, and reading ER diagrams in crow's foot notation.
kvi5hnuCode Sprout team member12 minSolutions to SQL problems that trip people up: relational division, pairs bought together, finding changed rows when NULLs are involved, all/none/some conditions, comparing two lists both ways, custom sort orders and the SUM(DISTINCT) trap.
kvi5hnuCode Sprout team member9 min