ctrl+shift+p filters: :st2 :st3 :win :osx :linux

My​SQL Snippets

by ancor-dev ST2/ST3

Many snippets for quick creation of sql commands

Labels snippets, mysql, sql



  • Total 19K
  • Win 13K
  • OS X 3K
  • Linux 3K
Oct 19 Oct 18 Oct 17 Oct 16 Oct 15 Oct 14 Oct 13 Oct 12 Oct 11 Oct 10 Oct 9 Oct 8 Oct 7 Oct 6 Oct 5 Oct 4 Oct 3 Oct 2 Oct 1 Sep 30 Sep 29 Sep 28 Sep 27 Sep 26 Sep 25 Sep 24 Sep 23 Sep 22 Sep 21 Sep 20 Sep 19 Sep 18 Sep 17 Sep 16 Sep 15 Sep 14 Sep 13 Sep 12 Sep 11 Sep 10 Sep 9 Sep 8 Sep 7 Sep 6 Sep 5 Sep 4
Windows 16 27 15 24 15 22 27 25 14 23 25 10 20 22 18 31 16 26 15 19 24 16 19 20 28 15 17 20 22 24 28 22 14 14 30 32 22 28 10 12 16 15 17 24 12 19
OS X 4 8 6 5 6 1 1 6 1 5 5 4 2 3 1 3 5 4 2 0 3 7 1 2 2 4 5 6 5 4 8 7 5 4 11 7 7 5 1 1 1 4 2 7 5 2
Linux 5 3 6 6 3 2 6 2 0 5 5 2 4 2 5 7 2 2 7 1 6 5 8 7 7 4 1 7 1 6 6 10 5 8 5 16 4 5 0 4 1 6 11 2 2 4



MySQL Snippets - Sublime Plugin

A sublime plugin complete with MySQL snippets

Quick review: http://youtu.be/rQoqbEiFNoU

Feel free to let me know what else you want added via:

What's included - contents


There are 3 methods for installing this plugin.

  1. Search for “MySQL Snippets” via the “Package Control: Install Packages” menu. Note: If you don't have Sublime Package Control installed, you can find out how to install it here https://sublime.wbond.net/installation

  2. Clone the repository into your Sublime Text 2/3 packages directory. git clone https://github.com/ancor-dev/sublime-sql-snippets.git

  3. Download the .zip file and unzip it into your Sublime Text 2/3 packages directory. Note: You can find your Sublime Text 2/3 packages directory by going to Preferences > Browse Packages.


Snippet Code Description
s-db create a new database
s-db-drop delete the database


Snippet Code Description
s-table create simple table with INT primary key
s–table create simple table with INT primary key, but first remove the old table
s-table-tmp create simple temporary table with engine=memory
s–table-tmp the same, but first remove the old table

s-many-many - Very powerful snippet! Make table for relation many-to-many, make two foreign key constrain, and two indexes in it and make two indexes in corresponding tables

Create Table components

Snippet Code Description
s-fk make foreign key constrain for table creation
s–fk make foreign key constrain for table creation with corresponding indexes
s-idx make default index for table creation
s-idx-txt make FULLTEXT index for table creation
s-pk make primary key
s-uk make unique key


Snippet Code Description
s-i insert multirow
s-ione insert one row
s-ifrom isert data from a sample(other table or database)


Snippet Code Description
s-s default select for extending with help query-options
s-sone select one row by where condition
s-sinline inline select for simple a sample
s-smin inline select for search min value
s-smax inline select for search max value
s-scount inline select for count rows in the table
s-ss select a value SELECT '...';
s-sv select a variable SELECT;

Query options


Snippet Code Description
s- the entity. Like `table`.`column`
s– the entity with a comma. Like , `table`.`column`
s-alias the entity with alias. Like `table`.`column` AS `my_col`
s–alias the same with comma. Like , `table`.`column` AS `my_col`
s-and a part of conditions AND ( ... )
s-or a part of conditions OR ( ... )
s–and a part of conditions with expression AND ( `col` = `col2` )
s–or a part of conditions with expression OR ( `col` = `col2` )
s-e an expression ( `col` = `col2` )


Snippet Code Description
s-f from statement like FROM `table` AS `alias`
s-j inner join statement
s-jleft left join statement
s-jright right join statement
s-w where statement
s-o order by statement
s-l limi statement
s-g group by statement
s-h having statement
s-u union statement


Snippet Code Description
s-u default update snippet with where condition


Snippet Code Description
s-d default delete snippet with where condition

Alter - modify structure

All alter snippets begining from s-alter-* prefix, like s-alter-add.


Snippet Code Description
add add a column to table at the last column
add-first add a column to table at the first column
add-after add a column to table after someone column
auto-increment change auto_increment counter value
change change the column(rename or change type)
modify modify the column(change type and column order)
drop drop the column from the table


Snippet Code Description
idx add an index to the table
idx-drop drop the index from the table
order sort the table by column(yes it indeed possible!)
table-rename rename the table
table-charset change table charset and collate
db-charset change database charset and collate
fk add foreign key to the table
-fk add foreign key to the table with index
fk-drop drop the foreign key from the table
uk add unique key to exists table


Snippet Code Description
s-trig create new trigger
s–trig replace trigger(drop and create new)
s-trig-list list triggers for table
s–trig-list list triggers for table(also specify DB)
s-trig-drop drop the trigger


Snippet Code Description
s-proc create new storage procedure
s–proc replace procedure(drop and create new)
s-proc-drop drop the storage procedure
s-proc-list show stored procedures list(only current database)


Snippet Code Description
s-func create new function
s–func replace function(drop and create new)
s-func-drop drop the function
s-func-list show list of user-defined functions(only current database)


Snippet Code Description
s-hcols details of the table (SHOW FULL COLUMNS FROM ...)
s-hcreate show command for creating the table
s-hidx show indexes for the table
s-hrel show relations of a table (using information_schema)



Snippet Code Description
s-dec declare a variable
s–dec declare a variable with default value
s-dec-s declare a string(VARCHAR) variable
s–dec-s declare a string(VARCHAR) variable with default value
s-dec-cur declare a cursor


Snippet Code Description
s-if create if statement
s–if create if else statement


Snippet Code Description
s-case CASE var_name WHEN 'value' THEN ... END CASE - value based
s-case-w WHEN 'value' THEN ... ; - value based
s-case-wb WHEN 'value' THEN BEGIN ... END; - value based
s–case CASE WHEN var_name = 'value' THEN ... END CASE - condition based
s–case-w WHEN var_name = 'value' THEN ... ; - condition based
s–case-wb WHEN var_name = 'value' THEN BEGIN ... END; - condition based


Snippet Code Description
s-loop LOOP ... END LOOP - Complex snippet. With additional logic!
s-repeat REPEAT ... UNTIL ... END REPEAT construct
s–repeat REPEAT BEGIN ... END; UNTIL ... END REPEAT construct


Snippet Code Description
s-cur powerful complex snippet! Makes ready to use cursor


Snippet Code Description
s-user-list list all users
s-user-add create a new user
s–user-add create a new user with a password (short access s--u)
s-user-add-hash create new user with a password by hash
s-user-drop remove user
s-user-pwd change user password


Snippet Code Description
s-priv-refresh command flush priveleges
s-priv-add add some privileges to user
s-priv-add-all add all privileges to user
s-priv-drop remove some privileges from user
s-priv-drop-all remove all privileges from user
s-priv-list show list of user privileges


Snippet Code Description
s-delim make delimiter $$ statement and at the end delimiter ;
s-utc select current timestamp