renameTableSql

See Also

executeSqlArray()

Syntax
array renameTableSql (
    string $oldTableName,
    string $newTableName
     )

Description

The method renameTableSql() creates the SQL statement necessary to rename an existing table in the database. In order to actualy rename the table, the output of the command must be executed with the executeSqlArray() method.

Parameters

$oldTableName

The table name must already exist in the database.

$newTableName

The new table name must not yet exist in the database. Names must conform to any database specific requirements such as length limitations and name casing.

Usage

/*
* create a data dictionary object, using the database connection
*/
$dict = NewDataDictionary($db);
 
$oldTableName = "ACT";
$newTableName = 'NEWACT';
 
/*
* create the SQL statement necessary to drop the table and its columns
*/
$sqlarray = $dict->renameTableSql($oldTableName, $newTableNae);
 
/*
 * This returns (for DB2)
Array
(
   [0] => RENAME TABLE ACT TO NEWACT
 
)
*/
 
/*
* This statement actually renames the table
*/
$dict->executeSqlArray($sqlarray);