How do I access SQL column default value via JDBC DatabaseMetaData in Database Toolbox v3.10 (R2011b)?
Ältere Kommentare anzeigen
I have a certain SQL table. I would like to access the metadata to determine if a particular column has a default value or not.
I use the following method.
% Define JDBC driver & URL:
>>driver = 'com.microsoft.sqlserver.jdbc.SQLServerDriver';
>>URL = 'jdbc:sqlserver://localhost:1433;database=TickerData;integratedSecurity=true;';
% Connect to database:
>>db = database('TickerInfo','','',driver,URL);
% Get MATLAB metadata object:
>>dbmeta = dmd(db)
dbmeta =
DMDHandle: [1x1 com.microsoft.sqlserver.jdbc.SQLServerDatabaseMetaData]
% Access Java object within (dbmeta) & call getColumns() method.
% It's known that table 'Ticker' has a column 'isThisRecordActive' which has a default value of (1).
>> dbmeta.DMDHandle.getColumns('','','Ticker','isThisRecordActive')
ans =
SQLServerDatabaseMetaData:3
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Database Toolbox finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!