Indeed, my bad, that's for MS SQL Server (I'm unsure that will work even
for it, because sp_rename isn't standard SQL.)
Glen
On 07/20/2014 04:28 PM, Dave wrote:
On Mon, Jul 14, 2014 at 4:22 PM, <[email protected]> wrote:
Modified: roller/trunk/app/src/main/resources/sql/macros.vm
URL:
http://svn.apache.org/viewvc/roller/trunk/app/src/main/resources/sql/macros.vm?rev=1610513&r1=1610512&r2=1610513&view=diff
==============================================================================
--- roller/trunk/app/src/main/resources/sql/macros.vm (original)
+++ roller/trunk/app/src/main/resources/sql/macros.vm Mon Jul 14 20:22:00
2014
@@ -82,6 +82,20 @@ Define non-null column with default valu
#end
#end
+#**
+Rename a table.
+For Derby, will not work if there is a view or foreign key that
references the table.
+MySQL requires sp_rename command; unsure if works.
+**#
+#macro(renameTable $oldTableName $newTableName)
+#if ($db.DBTYPE == 'POSTGRESQL' || $db.DBTYPE == 'HSQLDB')
+alter table $oldTableName rename to $newTableName;
+#elseif ($db.DBTYPE == 'MYSQL')
+sp_rename '$oldTableName', '$newTableName';
+#else
+rename table $oldTableName TO $newTableName;
+#end
+#end
Hi Glenn,
The correct syntax for MySQL is "rename table a to b" and not sp_rename.
Did you mean to use sp_rename for MS SQL Server instead?
- Dave