Previous Topic

Next Topic

How You Change Ownership of a Database Object

When changing ownership of an object, use the appropriate copy method to:

  1. Copy out the object from the database into an intermediate file
  2. Copy in the object under new ownership

Previous Topic

Next Topic

Prepare to Change Ownership of a Database Object

Before changing ownership of a database object, take the following preparatory steps:

  1. Make sure you have a current backup of the database.
  2. Check whether the user already owns an object with the same name as the object whose ownership you are changing.

    If this is the case, the existing duplicate object must be destroyed before proceeding.

    Important! If you fail to do this, the new object, owned by the new user, cannot be successfully created, and you can potentially corrupt the existing object with unwanted data.

Previous Topic

Next Topic

Change Ownership of a Database Object

Follow these basic steps to change ownership of a database object:

  1. Take preparatory steps, as described in Prepare to Change Ownership of a Database Object.
  2. Log in as the DBA of the database.
  3. Use the relevant copy method to copy the object out of the database into an intermediate file.
  4. Using the relevant copy method in input mode, copy the intermediate file into the new database as the new owner (by using the Users branch in the Virtual Nodes toolbar in VDBA, or by using the -u flag for commands).

    There are now two copies of the object in the database, one owned by the original owner and one owned by the new owner.

  5. To remove the original object, the DBA or privileged user uses the applicable Ingres tool as the original owner (by using the Users branch in the Virtual Nodes toolbar in VDBA, or by using the -u flag for commands) and deletes the original object.

Previous Topic

Next Topic

Change Ownership of Tables

Follow these steps to change the ownership of a table:

  1. Generate the executable scripts. In VDBA, use the Generate copy.in and copy.out dialog box, invoked from the Copydb command from the Database Generate Scripts submenu.
  2. Execute the copy.out script, copying the table as the current owner.
  3. Execute the copy.in script, copying the table back in as the new owner.

For detailed steps for performing these procedures in VDBA, see online help.

These tasks can also be accomplished using the copydb and sql commands. For more information, see the Command Reference Guide.

For more information on copying tables and other database objects, see the chapter "Loading and Unloading Databases."

Previous Topic

Next Topic

Example: Change Ownership of Table

The following example changes the ownership of any table from the currently selected user, John, to the user named dba.

  1. In VDBA, open the Generate copy.in and copy.out dialog box for the database in which the table is located. For more information, see online help.
  2. Click Tables to invoke the Specify Tables dialog box. Enable the check box for the table whose ownership you want to change and click OK.
  3. Click OK to create the copy scripts.
  4. At the operating system prompt, enter the following command to copy the table from the database mydb into an intermediate binary file in the current directory:

    sql -ujohn mydb <copy.out

  5. Edit the copy.in file to change the table reference in the grant statement from john.<table> to <dbaname>.<table>. If you do not do this, the grant statements refer to John's table.

    Note: The grant statements are present only if grants are defined for the table being copied.

    There are now two copies of the table, one owned by the user john and the other owned by the user dba. In the usual case, John's version is no longer needed and can be removed. For example, the user john (or another user impersonating john) can easily drop the table in VDBA. For more information, see online help.

  6. At the operating system prompt, enter the following command to copy the table from the intermediate binary file in the database as user dba:

    sql -udba mydb <copy.in

You also need to grant access permissions to the new table owned by user dba. For more information, see the chapter "Ensuring Access Security."

Previous Topic

Next Topic

Change Ownership of Applications

To change the ownership of an application (created with Applications-By-Forms or Vision) from any current owner to any new owner, use the copyapp command.

The command syntax has two forms: copyapp out and copyapp in. To change the ownership, you issue the first form of the command under the current ownership, and the second form under the new ownership.

Previous Topic

Next Topic

Example: Transfer Ownership of an Application to Another User

Assume the user john wants to transfer ownership of the application named app1 in the database mydb to the user dba. The following commands, entered at the operating system prompt, accomplish this, using the default intermediate text file and the current working directory:

copyapp out mydb app1 –ujohn
copyapp in mydb iicopyapp.tmp –a –udba

At this point, there are two copies of the application, one owned by the user john and the other owned by the user dba. In the usual case, John's application is no longer needed and can be removed using Vision or Application-By-Forms.

For a complete description of the flags and parameters for this command, see the copyapp entry in the Command Reference Guide.

Previous Topic

Next Topic

Change Ownership of Forms

Change the ownership of a form from any current owner to any new owner using the copyform command. There are two forms of syntax, one without the –i flag, which copies the forms from a database to a file. The next form, using the –i flag, copies the forms from the text file into a database. To change the ownership, issue the first form of the command under the current ownership, and the second form under the new ownership, as shown in the example that follows.

Previous Topic

Next Topic

Example: Transfer Ownership of Forms to Another User

Assume the user john wants to transfer ownership of the forms named customers and parts in the database mydb to the user dba. The following commands, entered at the operating system prompt, accomplish this:

copyform –ujohn mydb forms.txt customers parts
copyform -i –udba mydb forms.txt

For a complete description of the flags and parameters for this command, see the copyform entry in the Command Reference Guide.

At this point, there are two copies of each form, one owned by the user john and the other owned by the user dba. In the usual case, John's forms are no longer needed and can be removed in Visual Forms Editor.

Previous Topic

Next Topic

Change Ownership of Reports

Change the ownership of a report from any current owner to any new owner using the copyrep and sreport commands. The copyrep command copies the reports out under the current ownership, and sreport copies them back in under the new ownership, as shown in the example that follows.

Previous Topic

Next Topic

Example: Transfer Ownership of Reports to Another User

Assume the user john wants to transfer ownership of the reports named parts_restock and parts_on_order in the database mydb to the user dba. The following commands, entered at the operating system prompt, accomplish this:

copyrep –ujohn -f  mydb text.rw parts_restock parts_on_order
sreport –udba mydb text.rw

For a complete description of the flags and parameters for copyrep and sreport, see the Forms-based Application Development Tools User Guide. These commands are also described in the Command Reference Guide.

At this point, there are two copies of each report, one owned by the user john and the other owned by the user dba. In the usual case, John's reports are no longer needed and can be removed in Report-By-Forms.


© 2007 Ingres Corporation. All rights reserved.