This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

Run SQL Query

SQL statement to import data into the MATLAB® workspace

Database Toolbox™ lets you create SQL queries either by building them visually using the Database Explorer app or by writing them using SQL. To import data into the MATLAB workspace, run a SQL query and retrieve the data.


exec Execute SQL statement and open cursor
fetch Import data into MATLAB workspace from cursor object or from execution of SQL statement
fetchmulti Import data from multiple resultsets
get Retrieve object properties
resultset Construct resultset object
rsmd Construct resultset metadata object
runsqlscript Run SQL script on database
runstoredprocedure Call stored procedure with and without input and output arguments
set Set properties for database or cursor object
databaseDatastore Datastore for data in database


Database Explorer Configure, explore, and import database data

Using Objects

DatabaseDatastore Datastore for data in database


Import Data Using Database Explorer

Working with Database Explorer

Discover Database Explorer functionality and set preferences.

Configure Data Sources and Connect to Databases

Create a data source and connect to one or more databases.

Refine Results Using Query Criteria and Rules

Define a query without writing SQL code.

Generate SQL and MATLAB Code

Use Database Explorer to generate SQL or MATLAB code.

Import Data Using the Command Line

Creating and Running SQL Queries

Write SQL queries using Database Explorer, the command line, or SQL scripts.

Managing Memory to Import Data

Import data by limiting the number of rows or importing data in batches.

Import Data from Databases into MATLAB

This example shows how to import data from a Microsoft® Access™ database called dbtoolboxdemo into the MATLAB workspace.

Create Queries with Characters and Variables

Write SQL statements that include dates, text, MATLAB variables, and special characters.

Retrieve Image Data Types

Retrieve BINARY or OTHER Sun™ Java® SQL data types, such as bitmap images and MAT-files.

Working with the MATLAB Interface to SQLite

To analyze your data using SQL in MATLAB without access to a database or driver, use the MATLAB interface to SQLite.

Import Data Using the MATLAB® Interface to SQLite

This example shows how to move data between MATLAB® and the MATLAB® interface to SQLite.

Data Type Support

Find supported data types for data import and export.

Data Retrieval Restrictions

Find restrictions on table and column names for data retrieval.

Import Large Data

Import Data Using a DatabaseDatastore Object

This example shows how to import data into MATLAB® using a DatabaseDatastore object.

Analyze Large Data in Database Using Tall Arrays

Find the minimum arrival delay in a large flight data set using a tall table without writing custom functions.

Analyze Large Data in Database Using MapReduce

Write mapper and reducer functions for analyzing large data using a DatabaseDatastore object.

Import Large Data Using Paging

Import large data sets using the database paging syntax.

Preference Settings for Large Data Import

Determine the appropriate batch size for importing large data sets.

Import Data Using Cursors

Import Data Incrementally Using the Cursor Object

This example shows how to work with large data sets by retrieving data incrementally to avoid Java heap errors.

Importing Data Using a Scrollable Cursor

Learn about scrollable cursors and how they behave with different drivers.

Import Data Using a Scrollable Cursor with a Relative Position Offset

This example shows how to use a scrollable cursor to import data using both absolute and relative position offsets.

Perform Other Database Operations

Call a Stored Procedure That Returns Data

This example shows how to call a stored procedure that returns data using the exec function.

Roll Back and Commit Data in a Database

Execute ROLLBACK and COMMIT SQL statements.

Create a Table and Add a Column

Manage databases using the CREATE and ALTER SQL statements.

Change the Database Connection Catalog

Switch between different database catalogs.

Run a Custom Database Function

This example shows how to run a custom database function on Microsoft SQL Server®.

Delete Data from Databases

This example shows how to delete data from your database using MATLAB.

Was this topic helpful?