Rename Table statement - MapBasic - 2023

MapInfo MapBasic Reference

Product type
Software
Portfolio
Locate
Product family
MapInfo
Product
MapInfo > MapBasic
Version
2023
Language
English
Product name
MapBasic
Title
MapInfo MapBasic Reference
First publish date
1985
Last updated
2023-09-12
Published on
2023-09-12T16:32:32.686312

Purpose

Changes the names (and, optionally, the location) of the files that make up a table. You can issue this statement from the MapBasic window in MapInfo Pro.

Syntax

Rename Table table As newtablespec 

table is the name of an open table.

newtablespec is the new name (and, optionally, path) for the table.

Description

The Rename Table statement assigns a new name to an open table.

The newtablespec parameter specifies the table's new name. If newtablespec contains a directory name, MapBasic attempts to move the table to the specified directory in addition to renaming the table. The Rename Table statement renames the physical files which comprise a table. This effect is permanent (unless/until another Rename Table statement is issued).

Note: This action can invalidate existing workspaces. Any workspaces created before the renaming operation will refer to the table by its previous, no-longer-applicable name.

Do not use the Rename Table statement to assign a temporary, working table name. If you need to assign a temporary name, use the Open Table statement's optional As clause.

The Rename Table statement cannot rename a table that is actually a "view." For example, a StreetInfo table (such as SF_STRTS) is actually a view, combining two other tables (SF_STRT1 and SF_STRT2). You could not rename the SF_STRTS table by calling Rename Table. You cannot rename temporary query tables (for example, QUERY1). You cannot rename tables that have unsaved edits; if a table has unsaved edits, you must either save or discard the edits ( or Rollback) before renaming.

Example

The following example renames the table casanfra as sf_hiway.

Open Table "C:\DATA\CASANFRA.TAB"
Rename Table CASANFRA As "SF_HIWAY.TAB"

The following example renames a table and moves it to a different directory path.

Open Table "C:\DATA\CASANFRA.TAB"
Rename Table CASANFRA As "c:\MAPINFO\SF_HIWAY" 

See Also:

Close Table statement, Drop Table statement