Datastore for data 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 data from a database table or the results from executing an SQL
query in a relational database. For details about other datastores, see Getting Started with Datastore.
With a DatabaseDatastore
object, you can preview and read records or
chunks in a data set and reset the DatabaseDatastore
to its initial
state. Also, you can analyze a large data set in a database using tall arrays or
MapReduce.
Reading data from DatabaseDatastore
objects is the same as executing
the fetch
function on the data set. Using
DatabaseDatastore
objects provides advantages that enable you to:
Work with databases containing large amounts of data.
Analyze large amounts of data using tall arrays with common MATLAB functions, such as mean
and
histogram
. Create a tall array using the tall
function. For details,
see Tall Arrays for Out-of-Memory Data.
Write MapReduce algorithms that define the chunking and reduction of large
amounts of data by using the mapreduce
function. For
details, see Getting Started with MapReduce. For an example, see Analyze Large Data in Database Using MapReduce. For more
MapReduce examples, see Building Effective
Algorithms with MapReduce.
specifies additional options using one or more name-value pair arguments.
For example, dbds
= databaseDatastore(conn
,source
,Name,Value
)'ReadSize',100
retrieves 100 rows of data
from the DatabaseDatastore
object.
customizes the options for importing a large data set from a database using
the dbds
= databaseDatastore(conn
,source
,opts
)SQLImportOptions
object.
specifies additional options using one or more name-value pair arguments.
For example, dbds
= databaseDatastore(conn
,source
,opts
,Name,Value
)'Catalog','toy_store'
retrieves data from
the toy_store
database catalog.
The DatabaseDatastore
object supports only Microsoft®
SQL Server® 2012 and later versions.
The DatabaseDatastore
object does not support using a
parallel pool with Parallel Computing Toolbox™ installed. To analyze data using tall arrays or to run
MapReduce algorithms, set the global execution environment to be the local
MATLAB session by using mapreducer
. Enter this
code:
mapreducer(0)
hasdata | Determine if data in DatabaseDatastore is
available to read |
preview | Return subset of data from DatabaseDatastore |
read | Read data in DatabaseDatastore |
readall | Read all data in DatabaseDatastore |
reset | Reset DatabaseDatastore to initial
state |
close | Close and invalidate database and driver resource utilizer |
isPartitionable | Determine whether datastore is partitionable |
isShuffleable | Determine whether datastore is shuffleable |
database
| databaseImportOptions
| execute
| fetch
| getoptions
| mysql
| preview
| reset
| setoptions
| sqlread