Help Getting started and windows

SQL templates

SQL templates are short, worked examples of common statements, from a plain SELECT to a stored procedure with its DELIMITER lines. Each one opens in a new query tab, with placeholder names such as table_name and col1 for you to replace. They were written for bonSQL; each starts with a comment saying what the statement does, and many have commented-out variations underneath.

The SQL Templates window

Inserting a template

  1. Choose Edit > Insert Templates… or press Ctrl+Shift+T.
  2. Pick a statement from SQL Commands on the left. Preview on the right shows its text.
  3. Click Insert, or double-click the name.

The template opens in a new query tab, so nothing you have already written is touched. Change the names, delete the lines you do not need, and run it with F9 or Ctrl+F9.

The window can be resized, and bonSQL remembers its size and position. The query editor must be showing; if it is hidden (Ctrl+Shift+3), bonSQL asks you to show it first.

The templates

The list is in alphabetical order. By kind of work:

KindTemplates
Reading and changing rowsSelect, Join, Insert, Insert-Select, Update, Delete, Replace, Truncate, Load Data
DatabasesCreate Database, Alter Database, Drop Database, Use
Tables and indexesCreate Table, Alter Table, Rename Table, Drop Table, Describe, Create Index, Backup/Restore
ViewsCreate View, Alter View, Drop View
Stored routinesCreate Procedure, Alter Procedure, Drop Procedure, Create Function, Alter Function, Drop Function
Triggers and eventsCreate Trigger, Drop Trigger, Create Event, Alter Event, Drop Event
SequencesCreate Sequence, Alter Sequence, Drop Sequence
Transactions and locksBegin/Commit/Rollback, Transaction, Lock/Unlock

Things to know

Keeping your own statements

The template list itself cannot be changed. To keep statements of your own for reuse, write them in a query tab and use Favorites > Add To Favorites… (Ctrl+Shift+F). You give the favourite a name and a folder, and it then appears on the Favorites menu. The same dialog can instead add a link to an existing SQL file. Favorites > Organize Favorites… creates folders and renames, moves or deletes favourites.