Welcome To Snipplr


Everyone's Recent SQL Snippets



This is useful if you are changing a Drupal site's file upload path and/or changing from a private to a public file store.
3 1140 posted 14 years ago by shrop
Imports data from CSV (excel-compatible format) into MySQL. Also check the mysqlimport utility and the complementary SELECT ... INTO OUTFILE.
4 682 posted 14 years ago by jarnaldich
This will create and then populate a MySQL table with a list of the names and USPS abbreviations for US states and possessions in existence.
3 2179 posted 14 years ago by cbrant
This will create and then populate a MySQL table with a list of the names and ISO 3166 codes for countries in existence.
5 1003 posted 14 years ago by cbrant
If you ever need to build a comma delimited list out of a column in SQL you can easily do this using the COALESCE function.
0 402 posted 14 years ago by mcbutterbuns
1 545 posted 14 years ago by stancell
You can store an IP address in an INT UNSIGNED (4 bytes) which is of course much more efficient and faster than a CHAR(15). MySQL has two built-in functions: INET_ATON() and INET_NTOA(). These two functions are used allover the place in any TCP/IP s...
0 644 posted 14 years ago by zingo
To grant all privileges to a user from any location login to the mysql shell and run the following queries.
3 475 posted 14 years ago by cbrant
To reset the MySQL root password, login to the mysql shell and run the following commands.
1 489 posted 14 years ago by cbrant
Wenn ein INSERT einen doppelten Wert erzeugen würde, wird das UPDATE ausgeführt.
1 361 posted 14 years ago by drk
https://www.chrisjmendez.com/2008/03/23/mysql-commands-i-wish-i-could-remember/
9 536 posted 14 years ago by chrisaiv
4 561 posted 14 years ago by wolfie
An easy way to handle null dates. If date = 0000-00-00 then null, else use date
0 560 posted 14 years ago by Abe
It does not show the grants themselves, but shows all users with grants.
0 468 posted 15 years ago by therobot
1 593 posted 15 years ago by zingo
0 392 posted 15 years ago by Caliban
Generate the SQL necessary to create triggers that use the sequences listed above. NOTE: This particular script assumes that the tables all start with ‘tbl’. It may need to be modified to work with different naming conventions.
0 397 posted 15 years ago by thecrumb
Generate the SQL necessary to create sequences for every table. NOTE: This doesn’t create sequences. The results need to be copied and run as a script.
0 601 posted 15 years ago by thecrumb
Get a list of all the user tables.
0 630 posted 15 years ago by thecrumb
Get all my columns and comments.
0 436 posted 15 years ago by thecrumb
Noob stuff, but I always end up looking this up.
0 452 posted 15 years ago by rengber
Small query to help you relocate those modules you are not using anyways.
2 521 posted 15 years ago by torkil
1 615 posted 15 years ago by Abe