Main Content

Connect to Database Programmatically

Establish connection to relational databases and retrieve information about their structures using command line

Database Toolbox™ enables you to connect to various relational databases by installing the database and driver. If you do not want to install a database and driver, you can use the MATLAB Interface to SQLite.

After establishing a database connection, you can explore database contents and structure using the command line. Close the database connection when you are finished.

Objects

connectionRelational database ODBC connection
connectionRelational database JDBC connection

Functions

expand all

closeClose and invalidate database and driver resource utilizer
databaseConnect to database
isopenDetermine if database connection is open
odbcCreate ODBC database connection (Since R2021a)
listDataSourcesList all available data sources (Since R2020b)
sqlfindFind information about all table types in database

Topics

Connect to Database

Retrieve Information About Database Structure