- skip to content

# Database Abstraction Layer

### User Tools

- Login

### Site Tools

- Recent changes
- Media Manager
- Sitemap

### Sidebar

##### Resources

- Reference Manual
- User Guide
- The Data Dictionary
- ADOdb-xmlschema
- ADOdb Active Record
- Performance Monitoring
- Date/Time Library
- Session Management Library
- Unsupported Addons
- Coding Standards

##### Supported Databases

- Access
- ADO
- CSV
- Firebird
- Frontbase
- IBM DB2
- Informix
- Interbase
- LDAP
- Microsoft SQL Server
- MySQL
- Netezza
- ODBC
- ODBTP
- Oracle
- PDO
- Postgresql
- SAP ADS
- SAP ASE
- SAP Maxdb
- SAP Sqlanywhere
- Sqlite
- Sybase
- Plain Text
- Visual Foxpro

##### Other

- Feature Comparison Matrix
- Connection Matrix
- Include File Guide

v5:dictionary:renametablesql

# 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);

v5/dictionary/renametablesql.txt · Last modified: 2016/01/12 17:06 by mnewnham

### Page Tools

- Show pagesource
- Old revisions
- Backlinks
- Rename Page
- Back to top