Creating SQL Databases and Selecting Them in MetaTrader Tools
Summary
This introductory tutorial explains how to create a database and make it the active database using MySQL Workbench or MetaEditor. It describes several ways to issue SQL commands, including a command line, a graphical workbench, MQL5 code, and sockets connected to a SQL server. The examples focus on database creation, selecting a database for subsequent operations, and running script statements individually or together.
The article also explains why rerunning a script can fail when its database already exists, and outlines commenting out the creation statement or using a conditional creation pattern to avoid that problem. It notes that database products may have their own commands, so some operations are not portable across SQL systems. The discussion is an introductory setup lesson rather than a trading method: table design, data insertion, and querying are largely deferred to later material.
Key ideas
- SQL can be issued through command-line tools, database workbenches, MQL5 programs, or sockets.
- Create a database with a SQL command rather than by changing a file extension.
- Select the target database before issuing commands that operate within it.
- Workbench scripts can be run statement by statement or as a whole, which affects reruns.
- Conditional creation can help scripts run when a database may already exist.
Tags
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.