| Database Toolbox User's Guide | Search  Help Desk |
Viewing Information About the Imported Data
In this part of the tutorial, you view information about the data you imported and close the connection. You use these Database Toolbox commands: If you want to see or copy the commands for this part of the tutorial, or if you want to run the set of commands, use the M-filematlab\toolbox\database\dbdemos\dbinfodemo.m.
.connA = database('SampleDB', '', '');
cursorA = exec(connA, 'select country from customers');
cursorA = fetch(cursorA, 10)
.rowsA = rows(cursorA)
rowsA =
10
rows returns the number of rows in the data set, which is 10.
.columnsA = cols(cursorA)
columnsA =
1
cols returns the number of columns in the data set, which is one.
.colnamesA = columnnames(cursorA) colnamesA = 'country'
columnnames returns the names of the columns in the data set. In this
example, there is only one column, and therefore only one column name,
'country', is returned.
.widthA = width(cursorA, 1)
widthA =
15
width returns the column width for the column number you specify. Here,
the width of column one is 15.
.attrA = attr(cursorA)
attrA =
columnName: 'country'
typeName: 'TEXT'
typeValue: 12
columnWidth: 15
precision: []
scale: []
currency: 'false'
readOnly: 'false'
nullable: 'true'
Message: []
column
argument to specify the column for which you want the information.
.close(cursorA)
.close(connA)