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 | |
---|
1 | function 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 |
---|
9 | if ~mycheck |
---|
10 | error('No MySQL instance detected. Use MYOPEN to connect.') |
---|
11 | end |
---|
12 | if isempty(dbcurr) |
---|
13 | error('No database currently selected. Use DBOPEN to open a database.') |
---|
14 | end |
---|
15 | if ~isempty(strfind(old,'.')) || ~isempty(strfind(new,'.')) |
---|
16 | error('TBRENAME does not accept DBASE.TABLE syntax.') |
---|
17 | end |
---|
18 | if ~any(strcmpi(tblist,strtrim(old))) |
---|
19 | error(['Table ' old ' not found in current database. Use TBLIST to list available tables.']) |
---|
20 | end |
---|
21 | if any(strcmpi(tblist,strtrim(new))) |
---|
22 | error(['Table ' new ' already exists in current database. Use TBDROP to delete a table.']) |
---|
23 | end |
---|
24 | try |
---|
25 | mym(['rename table ' old ' to ' new]) |
---|
26 | catch |
---|
27 | error(['Table ' old ' not renamed. Check if ' new ' is a valid name.']) |
---|
28 | end |
---|
Note: See
TracBrowser
for help on using the repository browser.