source: MML/trunk/applications/database/mym/utilities/tbattr.m @ 4

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 
1function[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
11error(nargoutchk(0,2,nargout))
12if ~mycheck
13   error('No MySQL instance detected. Use MYOPEN to connect.')
14end
15try
16  [a,b,c,d,e,f] = mym(['describe ' table]);  %#ok
17catch
18  error(['Table ' table ' not found. Use DBLIST and TBLIST to list available databases and tables.'])
19end
20varargout{1} = a; 
21if nargout == 2
22    x = a;
23    for k = 1:length(a)
24        x{k} = char(cell2mat(b(k))');
25    end
26    varargout{2} = x; 
27end 
28 
Note: See TracBrowser for help on using the repository browser.