Export (0) Print
Expand All
Expand Minimize
2 out of 4 rated this helpful - Rate this topic

RENAME TABLE Command

Renames a table in the current database.


RENAME TABLE TableName1 TO TableName2

Parameters

TableName1

Specifies the name of the table to be renamed.

TableName2

Specifies the new name of the table.

You cannot use RENAME TABLE to change the name of a free table; use RENAME instead.

The following example creates two databases named mydbc1 and mydbc2, and a table named table1. The table is added to mydbc1 when it is created. The table is then closed and removed from mydbc1. ADD TABLE is then used to add the table to mydbc2. RENAME TABLE is used to change the name of the table from table1 to table2.

CLOSE DATABASES
CREATE DATABASE mydbc1
CREATE DATABASE mydbc2
SET DATABASE TO mydbc1
CREATE TABLE table1 (cField1 C(10), n N(10))  && Adds table to mydbc1
CLOSE TABLES     && A table must be closed to remove it from a database
REMOVE TABLE table1
SET DATABASE TO mydbc2
ADD TABLE table1
RENAME TABLE table1 TO table2
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.