source: MML/trunk/applications/database/mym/utilities/dbrename.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: 895 bytes
Line 
1function dbrename(oldname,newname)
2% DBRENAME  Rename a MySQL database
3% INPUTS  : OLDNAME - old database name, string
4%           NEWNAME - new database name, string
5% OUTPUTS : None
6% NOTES   : Untested! Will not work with MySQL versions prior to 5.1.7
7% EXAMPLE : dbrename('mydatabase','mydb')
8% AUTHOR  : Dimitri Shvorob, dimitri.shvorob@vanderbilt.edu, 8/7/06
9if ~mycheck
10   error('No MySQL instance detected. Use MYOPEN to connect.')
11end
12oldname = strtrim(oldname);
13if ~any(strcmpi(dblist,oldname))
14   error(['Database ' oldname ' not found. Use DBLIST to list available databases.'])
15end
16newname = strtrim(newname);
17if any(strcmpi(dblist,newname))
18   error(['Database ' newname ' already exists. Use DBDROP to delete a database.'])
19end
20try
21  mym(['rename database ' oldname ' to ' newname])
22catch
23  error(['Database ' oldname ' not renamed. Check if ' newname ' is  a valid name.'])
24end
Note: See TracBrowser for help on using the repository browser.