You can connect to a database in various ways using Database Toolbox™. If you have access to a database, create a data source. Then, you can connect to the database either by using the Database Explorer app or the command line. If you do not have an installed database and want to store relational data quickly, you can use the MATLAB® interface to SQLite. For details, see Working with MATLAB Interface to SQLite.
If you already have a database driver installed, you can create a data source.
For an ODBC driver, open the Microsoft® ODBC Data Source Administrator dialog box by using the
configureODBCDataSource function or the Database
For a JDBC driver, open the JDBC Data Source Configuration dialog box
by using the Database Explorer app, or configure a JDBC data source by
databaseConnectionOptions function at the command
For examples, see Configuring Driver and Data Source. Otherwise, see Driver Installation for information about installing your driver. For configuring MySQL® or PostgreSQL native interfaces, see MySQL Native Interface or PostgreSQL Native Interface.
If your data source is already defined, then you are ready to connect to your
database. If you do not define a data source, you can connect to your database using
a DSN-less connection string with the
function. (DSN is a data source name.) For details, see Connecting to Database.
After establishing a connection, you can explore the database and view data using the Database Explorer app or the command line. For details, see Data Import Using Database Explorer App or Command Line.
Operating system authentication enables you to connect to a database using your operating system user account. The operating system performs user validation, and the database does not require a different user name and password. Operating system authentication facilitates the maintenance of database access credentials. For example, Windows® provides operating system authentication that can be configured to work with a Microsoft SQL Server® database. For details about Microsoft SQL Server Windows authentication, see Set up the operating system authentication.
Use this table to choose your best connection option.
Database Explorer app
Several options enable you to connect to your database at the command line. Use this table to choose your best command line connection option.
Command Line Connection Option
Connect to your database with maximum performance.
Connect to your database by using a connection string.
For details, see the
Native interface connection
Achieve maximum platform independence.
Import data without installing a database or driver. For details, see Working with MATLAB Interface to SQLite.
You can create multiple connections at a time to the same database or different
databases. For creating multiple connections using the Database Explorer app, see
Create SQL Queries Using Database Explorer App. Or, you can
database function to create multiple
connections at the command line.