This is machine translation

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

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

preview

Return subset of data from DatabaseDatastore

Syntax

data = preview(dbds)

Description

example

data = preview(dbds) returns the first eight rows of data from the DatabaseDatastore object dbds without changing its current position.

Note

preview returns data as a table only. preview ignores database preference settings for data return formatting.

If there is no data to read from the query, preview throws an error.

Examples

collapse all

Using a JDBC driver, create a database connection to a Microsoft® SQL Server® database with Windows® authentication. Specify a blank user name and password. The code assumes that you are connecting to database toy_store, database server dbtb04, and port number 54317.

conn = database('toy_store','','','Vendor','Microsoft SQL Server', ...
    'Server','dbtb04','PortNumber',54317,'AuthType','Windows');

Create a DatabaseDatastore object using the database connection and SQL query. This SQL query reads all data from the table.

sqlquery = 'select * from airlinesmall';

dbds = databaseDatastore(conn,sqlquery);

Preview the first eight records in the data set returned by executing the SQL query in the DatabaseDatastore object.

preview(dbds)
ans = 

    Year    Month    DayofMonth    DayOfWeek    DepTime    CRSDepTime    ArrTime    CRSArrTime    UniqueCarrier    FlightNum    TailNum    ActualElapsedTime    CRSElapsedTime    AirTime    ArrDelay    DepDelay    Origin    Dest     Distance    TaxiIn    TaxiOut    Cancelled    CancellationCode    Diverted    CarrierDelay    WeatherDelay    NASDelay    SecurityDelay    LateAircraftDelay
    ____    _____    __________    _________    _______    __________    _______    __________    _____________    _________    _______    _________________    ______________    _______    ________    ________    ______    _____    ________    ______    _______    _________    ________________    ________    ____________    ____________    ________    _____________    _________________

    1990    9        22            6            1801       1750          2005       1938          'NW'             209          'NA'       124                  108               'NA'        27          11         'PHL'     'DTW'     453        'NA'      'NA'       0            'NA'                0           'NA'            'NA'            'NA'        'NA'             'NA'             
    1990    9        11            2             908        910          1613       1554          'NW'             248          'NA'       245                  224               'NA'        19          -2         'PHX'     'DTW'    1671        'NA'      'NA'       0            'NA'                0           'NA'            'NA'            'NA'        'NA'             'NA'             
    1990    9         2            7             NaN       1805           NaN       1900          'NW'             284          'NA'       NaN                   55               'NA'       NaN         NaN         'JAN'     'MEM'     189        'NA'      'NA'       1            'NA'                0           'NA'            'NA'            'NA'        'NA'             'NA'             
    1990    9        29            6            1434       1435          1615       1630          'NW'             305          'NA'       221                  235               'NA'       -15          -1         'MSP'     'LAX'    1536        'NA'      'NA'       0            'NA'                0           'NA'            'NA'            'NA'        'NA'             'NA'             
    1990    9         3            1             925        755          1258       1144          'NW'             350          'NA'       153                  169               'NA'        74          90         'MSP'     'BOS'    1124        'NA'      'NA'       0            'NA'                0           'NA'            'NA'            'NA'        'NA'             'NA'             
    1990    9        22            6             900        900          1241       1222          'AA'              11          'NA'       401                  382               'NA'        19           0         'BOS'     'LAX'    2611        'NA'      'NA'       0            'NA'                0           'NA'            'NA'            'NA'        'NA'             'NA'             
    1990    9        20            4            1338       1335          1853       1907          'AA'              62          'NA'       255                  272               'NA'       -14           3         'ORD'     'SJU'    2072        'NA'      'NA'       0            'NA'                0           'NA'            'NA'            'NA'        'NA'             'NA'             
    1990    9         3            1             710        711           837        847          'AA'             101          'NA'       147                  156               'NA'       -10          -1         'DTW'     'DFW'     987        'NA'      'NA'       0            'NA'                0           'NA'            'NA'            'NA'        'NA'             'NA'             

Close the DatabaseDatastore object and database connection.

close(dbds)

Input Arguments

collapse all

Datastore containing data in a database, specified as a DatabaseDatastore object created using the databaseDatastore function.

Output Arguments

collapse all

Query results, returned as a table of the first eight records in the data set. Executing the SQL statement specified in the Query property of the DatabaseDatastore object creates the data set.

If there is no data to read from the query, preview throws an error.

Introduced in R2014b