This tutorial shows how to use Database Toolbox™ with relational databases. To gain the maximum benefit from this toolbox and understand its capabilities, use the following steps and decision flow chart.
If you do not have an installed database and want to store relational data quickly, use the MATLAB® interface to SQLite. For details, see Working with MATLAB Interface to SQLite.
Install your database. For details, refer to your database administrator or your database documentation.
Choose between using the Database Explorer app or the command line.
Choose between using an ODBC driver or a JDBC driver. For details, see Choosing Between ODBC and JDBC Drivers.
For ODBC drivers, the driver is typically preinstalled on your computer. For JDBC drivers, install the driver. For details about ODBC and JDBC drivers, see Driver Installation. If you have questions about which driver you need, refer to your database administrator or your database documentation.
Create a data source for an ODBC-compliant or JDBC-compliant driver. For details, see Configuring Driver and Data Source.
Test the connection to your database using the Database Explorer app or the command line.
Connect to your database using the Database Explorer app or the command line. For details, see Connecting to Database.
Select data from your database and import the data into a MATLAB variable by using the Database Explorer app or the command line. For details, see Data Import Using Database Explorer App or Command Line.
Insert data into your database by exporting data from a MATLAB variable. For details, see the sqlwrite
function.
When you use the Database Explorer app to import data, generate a MATLAB script to automate your tasks. For details, see Generate MATLAB Script.
This flow chart illustrates the steps to take and the decisions to make when you use Database Toolbox with relational databases.