User`s guide
7 Functions — Alphabetical List
7-24
Display the column names for the suppliers table.
columnlist{2,2}
ans =
'SupplierNumber' 'SupplierName' 'City' 'Country' 'FaxNumber'
Close the database connection.
close(conn)
Retrieve the Column List for a Catalog and Schema Using the Database Metadata Object
Create a database connection conn. This code uses database name dbname, user name
username, password pwd, database server name sname, and port number 123456 to
connect to a Microsoft SQL Server database.
conn = database('dbname','username','pwd',...
'Vendor','Microsoft SQL Server',...
'Server','sname',...
'portnumber',123456);
Create the database metadata object dbmeta.
dbmeta = dmd(conn);
Retrieve the column names for each table in a schema. Here, this code assumes that the
database contains the catalog name toy_store and the schema name schema.
columnlist = columns(dbmeta,'toy_store','schema')
columnlist =
'inventoryTable' {1x4 cell}
'invoice' {1x5 cell}
'productTable' {1x5 cell}
...
columns returns a cell array. The first column contains the table names as strings. The
second column contains the corresponding column name lists as cell arrays.
Display the column names for the inventoryTable table.
columnlist{1,2}
ans =