User`s guide

7 Functions — Alphabetical List
7-86
Using DatabaseDatastore Objects
Access collection of data stored in database
MATLAB has various datastores that let you import large data sets into MATLAB for
analysis. A DatabaseDatastore object is a type of datastore that contains the resulting
data from executing an SQL query in a relational database.
With a DatabaseDatastore object, you can perform these tasks:
Preview data.
Read data in chunks.
Read every record in the data set.
Reset the cursor position to the start of the data set.
Continue reading data until the cursor position reaches the end of the data set.
Analyze a large data set stored in a database using MapReduce.
After creating a DatabaseDatastore object, you can write custom functions to run
MapReduce. For details, see “Getting Started with MapReduce”.
Examples
Create a DatabaseDatastore Object
Connect to a Microsoft SQL Server database with Windows Authentication. This code
assumes you are creating a database connection conn using the native ODBC interface
with the authenticated ODBC data source name MS SQL Server Auth and blank user
name and password.
conn = database.ODBCConnection('MS SQL Server Auth','','');
Create a DatabaseDatastore object dbds using the database connection conn and
SQL query sqlquery. This SQL query retrieves all products from the product table
productTable ordered by product number.
sqlquery = ['select * from [toy_store].[dbo].[productTable] '...
'order by productNumber'];