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

Last change on this file since 4 was 4, checked in by zhangj, 11 years ago

Initial import--MML version from SOLEIL@2013

File size: 1021 bytes
Line 
1function tbrename(old,new)
2% TBRENAME  Rename a MySQL table
3% INPUTS  : OLD - old table name, string
4%           NEW - new table name, string
5% OUTPUTS : None
6% EXAMPLE : dbrename('mytable','mytb')
7% NOTES   : The table must reside in current database.
8% AUTHOR  : Dimitri Shvorob, dimitri.shvorob@vanderbilt.edu, 8/7/06
9if ~mycheck
10   error('No MySQL instance detected. Use MYOPEN to connect.')
11end
12if isempty(dbcurr)
13   error('No database currently selected. Use DBOPEN to open a database.')
14end
15if ~isempty(strfind(old,'.')) || ~isempty(strfind(new,'.'))
16   error('TBRENAME does not accept DBASE.TABLE syntax.')
17end
18if ~any(strcmpi(tblist,strtrim(old)))
19   error(['Table ' old ' not found in current database. Use TBLIST to list available tables.'])
20end
21if any(strcmpi(tblist,strtrim(new)))
22   error(['Table ' new ' already exists in current database. Use TBDROP to delete a table.'])
23end
24try
25  mym(['rename table ' old ' to ' new])
26catch
27  error(['Table ' old ' not renamed. Check if ' new ' is a valid name.'])
28end
Note: See TracBrowser for help on using the repository browser.