User`s guide
columns
7-25
'productNumber' 'Quantity' 'Price' 'inventoryDate'
Close the database connection.
close(conn)
Retrieve the Column List for a Catalog, Schema, and Table Name 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 in a database table. Here, this code assumes that the
database contains the catalog name toy_store, the schema name schema, and the table
name inventoryTable.
columnlist = columns(dbmeta,'toy_store','schema','inventoryTable')
columnlist =
'productNumber' 'Quantity' 'Price' 'inventoryDate'
columns returns a cell array with the column names as strings.
Close the database connection.
close(conn)
Input Arguments
conn — Database connection
database connection object