MATLAB DATABASE TOOLBOX RELEASE NOTES Guide de l'utilisateur Page 453

  • Télécharger
  • Ajouter à mon manuel
  • Imprimer
  • Page
    / 684
  • Table des matières
  • MARQUE LIVRES
  • Noté. / 5. Basé sur avis des utilisateurs
Vue de la page 452
columns
7-23
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(conn,'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)
Retrieve the Column List for a Catalog 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 catalog. Here, this code assumes that the
database contains the catalog name toy_store.
columnlist = columns(dbmeta,'toy_store')
columnlist =
'salesVolume' {1x13 cell}
'suppliers' {1x5 cell}
'yearlySales' {1x3 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.
Vue de la page 452
1 2 ... 448 449 450 451 452 453 454 455 456 457 458 ... 683 684

Commentaires sur ces manuels

Pas de commentaire