{ Snipperize } /SQL

SQL snippets

Here are the latest SQL snippets. Please choose your favorite one or add a new one.

Kill All MySQL Connections Based On Condition

Kill All MySQL Connections Based On Condition

SQL / kill, connection, information_schema / by ThePeppersStudio (44 days, 23.31 hours ago)

Get Next Autoincrement Number

Get next autoincrement id.

SQL / autoincrement, information_schema / by ThePeppersStudio (47 days, 14.97 hours ago)

MySQL Age Calculation

Some code for calculating and determining a persons age

SQL / age, calculation, DATE_FORMAT / by ThePeppersStudio (92 days, 23.05 hours ago)

Bayesian Ranking

Use Bayesian values to get a "more fair" ranking than average value based ranking. Example with a "games" table having some ratings in table "ratings"

SQL / Bayesian, ranking / by ThePeppersStudio (130 days, 19.03 hours ago)

Insert or update if unique key already exist

SQL / insert, duplicate, key, update / by ThePeppersStudio (139 days, 16.60 hours ago)

初始化mysql tables

删除已经存在的表后并重建

SQL / mysql, table, drop, create / by ThePeppersStudio (237 days, 19.17 hours ago)

FIND & REPLACE

find and replace in a specific column field.

SQL / find, replace / by ThePeppersStudio (256 days, 2.82 hours ago)

The Worst Performing Indexes

This script shows the top 10 worst indexes (in terms of selectivity %) on the whole MySQL server instance. Selectivity is the percentage of distinct values in an indexed field compared to the number of records in the table. Note that this query can take some time to complete on servers with lots of databases or lots of tables.

SQL / performence / by ThePeppersStudio (256 days, 2.86 hours ago)

  • 1