Last change
on this file since 4 was
4,
checked in by zhangj, 10 years ago
|
Initial import--MML version from SOLEIL@2013
|
File size:
929 bytes
|
Line | |
---|
1 | function[varargout] = tbattr(table) |
---|
2 | % TBATTR Show structure of a MySQL table |
---|
3 | % INPUTS : TABLE - table name, string |
---|
4 | % OUTPUTS : COLS - list of column names, (m x 1) cell array |
---|
5 | % TYPES - list of columns types, (m x 1) cell array (optional) |
---|
6 | % NOTES : Use DBASE.TABLE syntax to refer to a table not in the current |
---|
7 | % database |
---|
8 | % EXAMPLE : [cols,types] = tbattr('orders') |
---|
9 | % tbattr('project5.data') |
---|
10 | % AUTHOR : Dimitri Shvorob, dimitri.shvorob@vanderbilt.edu, 8/7/06 |
---|
11 | error(nargoutchk(0,2,nargout)) |
---|
12 | if ~mycheck |
---|
13 | error('No MySQL instance detected. Use MYOPEN to connect.') |
---|
14 | end |
---|
15 | try |
---|
16 | [a,b,c,d,e,f] = mym(['describe ' table]); %#ok |
---|
17 | catch |
---|
18 | error(['Table ' table ' not found. Use DBLIST and TBLIST to list available databases and tables.']) |
---|
19 | end |
---|
20 | varargout{1} = a; |
---|
21 | if nargout == 2 |
---|
22 | x = a; |
---|
23 | for k = 1:length(a) |
---|
24 | x{k} = char(cell2mat(b(k))'); |
---|
25 | end |
---|
26 | varargout{2} = x; |
---|
27 | end |
---|
28 | |
---|
Note: See
TracBrowser
for help on using the repository browser.