Renaming and Deleting Objects

www.altova.com Print this Topic Previous Page Up One Level Next page

Home >  Exploring and Changing the Database Structure >

Renaming and Deleting Objects

Database objects can be renamed or deleted from various contexts:

 

In the Online Browser, by using the context menu
In the Design Editor
It is also possible to rename an object by double-clicking its title in the Properties window.

 

When you rename or delete a database object, the change is not committed immediately to the database. Instead, a change script is generated in the Database Structure Change Script window, where you can review it before execution.

 

Support for renaming database objects is not uniform across all databases. The following table illustrates objects that can be renamed directly from the graphical user interface of DatabaseSpy, across various database kinds. Some databases may additionally support renaming of keys, check constraints, indexes, as well as stored procedures.

 

Database kind

Rename table?

Rename column?

Rename view?

Access

-

-

-

Firebird

-

Yes

-

IBM DB2

Yes

-

-

IBM DB2 for i

Yes

-

-

Informix

Yes

-

-

MariaDB

Yes

Yes

-

MySQL

Yes

Yes

-

Oracle

Yes

Yes

-

PostgreSQL

Yes

Yes

Yes

Progress OpenEdge

Yes

Yes

-

SQLite

Yes

-

Yes

SQL Server

Yes

Yes

Yes

Sybase

-

-

-

Teradata

Yes

Yes

Yes

 

 

To rename a database object:

1.Do one of the following:

 

In the Online Browser, select a database object and press F2 or double-click its title bar in the Properties window.
In the Online Browser, right-click a database object and select Rename from the context menu.
In a Design Editor window, double-click the title bar of a table or the database object, or right-click and select Rename Table or Rename Column or Rename Key or Rename Index or Rename Check Constraint, respectively, from the context menu.

 

2.Change the name as desired and press Enter. DatabaseSpy generates the required script and displays it in the Database Structure Change Script window.

ds_rename_table

Note:At this stage, the changes are not committed to the database yet. In the Online Browser, the icon dbs_ic_changed_col appears to the left of the object name, which indicates that you are about to rename it. To undo the rename operation without committing it to the database, click Refresh data source Refresh (F5) in the Online Browser.

 

3.Optionally, to modify the generated script before running it, click the Edit Change Script Edit Change Script button.
4.In the Database Structure Change Script window, click Execute Change Script dbs_ic_execute_script.

 

Deleting database objects

In DatabaseSpy's Online Browser, you have several possibilities to delete a database object from a database:

 

Right-click a database object and choose Delete from the context menu.
Select a database object and press Delete.
Right-click a database object and select Show in new SQL Editor | Drop from the context menu.

 

In a Design Editor window, you can do the following to delete a database object:

 

Right-click a database object and choose Delete selected Objects from the context menu.
Select a database object and press Delete.

 

All the options mentioned above are also valid if you have selected more than one database object.

 

While the changes are not committed to the database yet, the objects marked for deletion are displayed with a special "deleted object" icon (for example, dbs_ic_deleted_table in case of tables). To actually delete the database object(s) from the database, execute the script in the Database Structure Change Script window (or, if applicable, in the SQL Editor).


© 2019 Altova GmbH