Snippets about sql
10 snippets
-
SNP 140
#925
Create a database user in MariaDB
One user per application, with only the rights it needs.
-
SNP 123
#952
Update a table from another table
Copy values across tables with a join, in MySQL, MariaDB and PostgreSQL.
-
SNP 094
#591
Upsert in PostgreSQL
Insert a row, or update it if it already exists, in one statement.
-
SNP 083
#962
Tunnel to a remote database over SSH
Use your local database tools on a server's database that isn't exposed to the internet.
-
SNP 077
#396
Delete duplicate rows but keep one
Clean up a table after finding the duplicates, keeping the oldest of each.
-
SNP 044
#A35
Latest row per group in SQL
The newest order of every customer, in one query.
-
SNP 039
#952
MariaDB in Docker for local development
A database for the project that you can throw away and recreate in a second.
-
SNP 033
#953
Dump and restore a MariaDB database
Backups, moving a database to another server, or copying production to your machine.
-
SNP 024
#936
Find duplicate rows in SQL
Which emails are in the users table more than once?
-
SNP 012
#951
Concat IDs into a single field in SQL
Here is how to merge multiple SQL rows into one, values separated by a comma.