Menu

Learn SQL and Databases with Practical Examples

SQLiz is a practical learning library for SQL and database tools. Browse query examples for MySQL, PostgreSQL, SQLite, MariaDB, and SQL Server, alongside references and setup guides for Oracle, MongoDB, Redis, and more. Use site search to find a function or task, choose a database tutorial below, or browse all articles for installation and programming guides.

MySQL Error 1146: Table Doesn't Exist (42S02)

Fix MySQL Error 1146 (42S02) by checking the selected database, exact table name and case, and whether the table migration ran.

MySQL Error 1061: Duplicate Key Name (42000)

Fix MySQL Error 1061 by inspecting existing indexes and migrations before adding or renaming an index. Learn how it differs from duplicate rows.

MySQL Error 1060: Duplicate Column Name (42S21)

Fix MySQL Error 1060 (42S21) by checking the table definition before adding or redefining a column, and identify duplicate schema migrations.

MySQL Error 1049: Unknown Database (42000)

Fix MySQL Error 1049 (42000) by checking the database name, server, letter case, and account visibility before creating or selecting a database.

MySQL Error 1046: No Database Selected (3D000)

Fix MySQL Error 1046 (3D000) by selecting a database with USE, qualifying table names, or setting the database in your client connection.

MySQL Error 1045: Access Denied for User (28000)

Fix MySQL Error 1045 by checking the password, user@host account, server and protocol, and account authentication or lock status.

MySQL Error 1044: Access Denied to Database (42000)

Fix MySQL Error 1044 by checking the authenticated account and granting only the database or table privileges the operation needs.

MySQL Error 1215: Cannot Add Foreign Key Constraint

Fix MySQL Error 1215 by comparing foreign-key column types, storage engines, indexes, and table definitions, then inspect InnoDB’s latest foreign-key error.

How to Install MongoDB 8.0 on Ubuntu 24.04

Install MongoDB 8.0 Community Edition on Ubuntu 24.04 from MongoDB’s signed APT repository, then verify mongod and connect with mongosh.

How to Install PostgreSQL on Ubuntu 24.04 LTS

Install Ubuntu’s PostgreSQL 16 package or PostgreSQL 18 from PostgreSQL’s official APT repository on Ubuntu 24.04 LTS, then verify the server.

How to Install MariaDB 12.3 LTS on Debian 13

Install MariaDB 12.3 LTS on Debian 13 (Trixie) from MariaDB’s APT repository, verify the server, and create a local application database.

How to Install MariaDB 12.3 LTS on Ubuntu 26.04

Install MariaDB 12.3 LTS on Ubuntu 26.04 from MariaDB’s APT repository, verify the server, and create a local application database.

How to Install PostgreSQL on Debian 13 (Trixie)

Install PostgreSQL on Debian 13 from Debian’s repository or PGDG, choose PostgreSQL 18, create a database role, and verify the server.

How to Install MySQL 9.7 LTS on Fedora 44

Install MySQL 9.7 LTS on Fedora 44 x86_64, verify Oracle’s DNF repository, set the root password, and check the server version.

How to Install MySQL 9.7 LTS on Debian 13

Install MySQL 9.7 LTS on Debian 13 (Trixie), confirm APT is using Oracle’s repository, and verify the server and connection.

SQL Server UPSERT: Insert or Update a Row

Learn a SQL Server insert-or-update pattern with a transaction, UPDLOCK, and SERIALIZABLE, plus when MERGE fits and how unique keys protect data.

SQLite UPSERT: Insert or Update on Conflict

Learn SQLite upsert syntax to skip duplicates or update a conflicting row with the proposed values, including version and constraint caveats.

How to Get the Latest Row per Group in MySQL

Return the latest MySQL row per group with ROW_NUMBER() or MAX() and a join; handle timestamp ties and MySQL 5.7.

MySQL UPSERT with ON DUPLICATE KEY UPDATE

Learn MySQL UPSERT syntax with INSERT … ON DUPLICATE KEY UPDATE, including row aliases, the legacy VALUES() form, and unique-key caveats.

Oracle UPSERT with MERGE: Insert or Update Rows

Use Oracle MERGE to update a row when its key matches or insert it when no row matches, with bind variables, unique-key rules, and batch guidance.

MariaDB UPSERT with ON DUPLICATE KEY UPDATE

Learn MariaDB INSERT … ON DUPLICATE KEY UPDATE for insert-or-update operations, including VALUES(), multi-row inserts, INSERT … SELECT, and unique-key caveats.

How to Get the Top N Rows per Group in MySQL

Use ROW_NUMBER(), RANK(), and PARTITION BY to return the top N MySQL rows within each group, handle ties, and support MySQL 5.7.

SQL UPSERT Syntax by Database

Compare SQL insert-or-update patterns for MySQL, MariaDB, PostgreSQL, SQLite, Oracle, and SQL Server, with unique-key and concurrency caveats.

SQL Server Top N Rows per Group with ROW_NUMBER()

Return the newest or highest-value N rows for each SQL Server group with ROW_NUMBER() or RANK(), including tie handling and deterministic ordering.

Python Oracle CRUD with python-oracledb

Learn to create, read, update, and delete Oracle Database rows from Python with python-oracledb, bind variables, and explicit transaction handling.

Install PostgreSQL on Ubuntu 26.04 LTS

Install PostgreSQL on Ubuntu 26.04 LTS, create an application role and database, or choose a major version from PGDG; verify the service and connect with psql.

Install MariaDB on openSUSE with zypper

Install MariaDB Server on openSUSE with zypper, start its systemd service, secure the local instance, and create a database and user.

How SPIDER_DIRECT_SQL() Works in MariaDB

Learn the three-argument SPIDER_DIRECT_SQL() syntax, how remote query results are stored, what its return value means, and how it differs from background execution.

PostgreSQL SERIAL: Auto-Incrementing Columns

Learn how PostgreSQL SMALLSERIAL, SERIAL, and BIGSERIAL use sequences, what constraints they create, how to return generated IDs, and when to use IDENTITY.

MySQL Error 3780: Incompatible Foreign Key Columns

Fix MySQL Error 3780 by matching foreign-key column types, integer size and signedness, and string character sets and collations.