Snippets about sql

10 snippets

Back to all snippets

  1. SNP140

    Create a database user in MariaDB

    One user per application, with only the rights it needs.

    6 lines of sql in 2 blocks, 6 lines of explanation.

    #925 sql mariadb
  2. SNP123

    Update a table from another table

    Copy values across tables with a join, in MySQL, MariaDB and PostgreSQL.

    9 lines of sql in 2 blocks, 5 lines of explanation.

    #952 sql
  3. SNP094

    Upsert in PostgreSQL

    Insert a row, or update it if it already exists, in one statement.

    6 lines of sql in 2 blocks, 5 lines of explanation.

    #591 sql postgres
  4. SNP083

    Tunnel to a remote database over SSH

    Use your local database tools on a server's database that isn't exposed to the internet.

    2 lines of sh in 2 blocks, 7 lines of explanation.

    #962 ssh sql cmd
  5. SNP077

    Delete duplicate rows but keep one

    Clean up a table after finding the duplicates, keeping the oldest of each.

    10 lines of sql in 3 blocks, 6 lines of explanation.

    #396 sql mariadb
  6. SNP044

    Latest row per group in SQL

    The newest order of every customer, in one query.

    14 lines of sql in 2 blocks, 5 lines of explanation.

    #A35 sql
  7. SNP039

    MariaDB in Docker for local development

    A database for the project that you can throw away and recreate in a second.

    17 lines of yaml and sh in 2 blocks, 4 lines of explanation.

  8. SNP033

    Dump and restore a MariaDB database

    Backups, moving a database to another server, or copying production to your machine.

    4 lines of sh in 3 blocks, 6 lines of explanation.

    #953 sql mariadb cmd
  9. SNP024

    Find duplicate rows in SQL

    Which emails are in the users table more than once?

    11 lines of sql in 2 blocks, 3 lines of explanation.

    #936 sql
  10. SNP012

    Concat IDs into a single field in SQL

    Here is how to merge multiple SQL rows into one, values separated by a comma.

    1 line of sql in 1 block, 1 line of explanation.

    #951 sql