Document #: US-38901,EN ------------------------------------------------------------------------------ Major subject: analysis Minor subjects: tech_notes Keywords: dba_guide Abstract: The "Changing Ownership of Databases and Database Objects" chapter of the INGRES Database Administrator's Guide. Equivalent to Release 6 Technical Notes #18 and #20, or Release 5 notes #18, #19, #24. Expert note: Changing Ownership of Databases and Database Objects ==================================================== Overview -------- It is sometimes necessary to change the ownership of a database or user object, or to move it to a different database. This chapter gives procedures for changing the ownership of databases and user objects. o What is Ownership? o Objects Whose Ownership Can Be Changed o Changing Ownership of a Database Object o Changing Ownership of a Table o Changing Ownership of a Form o Changing Ownership of a Report o Changing Ownership of a Graph o Changing Ownership of a Database What is Ownership? ------------------ INGRES supports an ownership scheme for databases, the individual tables that make up the database, and related user objects. User objects include forms, reports, and graphs. The hierarchy of ownership involves three different user classes: the INGRES superuser, the DBA, and the end user. Each class entails a different set of ownership privileges, discussed in the INGRES Database Administrator's Guide. Two important rules are that objects cannot be shared: o Among users unless the objects are owned by the DBA o Between databases User objects created by the DBA can be used by anyone who has access to the database. Objects created by anyone other than the DBA are considered private. (ABF applications and the objects they contain are an exception, in that they are always globally accessible.) To make a private object accessible to anyone other than its creator, the ownership of the object must be transferred to the DBA. Objects Whose Ownership Can Be Changed -------------------------------------- This chapter describes changing the ownership of the following user objects: o Tables -- ownership of a table in a database, created through the tables utility, the terminal monitor, or an embedded query language program. o Forms -- ownership of a form, created through VIFRED o Reports -- ownership of a report, created through RBF or Report-Writer o Graphs -- ownership of a graph, created through VIGRAPH o Databases -- ownership of a database in its entirety These procedures do not include changing ownership of database procedures. Changing Ownership of a Database Object --------------------------------------- When changing ownership of an object, you use an appropriate copy variation ('copydb', 'copyform', 'copyrep', 'copygraph') twice, to: o Copy out the object from the database into an intermediate file o Copy in the object under new ownership The copy varies according to the database object. These variations are described in the individual sections below. Here is the procedure for changing ownership of an object: 1. Take the following preparatory steps: Make certain that there is a current backup of the database. Insure that the new user does not already own a similar object with the same name as that of the object whose ownership you wish to change. In that case, the existing duplicate object MUST be destroyed before proceeding. Caution If you fail to do this, the new object, owned by the new user, will not be successfully created, and you may potentially corrupt the existing object with unwanted data. 2. Log in as the DBA of the database (or a superuser). 3. Use the relevant copy ('copydb', 'copyform, 'copyrep, 'copygraph') command to copy the object out of the database into an intermediate file. 4. Then, using the copy ('copydb', 'copyform, 'copyrep', 'copygraph') command in input mode, copy the intermediate file back into the database using the '-u' flag to specify a different owner. An INGRES superuser or the DBA of the database may use this flag. 5. There will now be two copies of the object in the database, one owned by the original owner and one owned by the new owner. To remove the original object, the DBA or superuser logs into the applicable user interface as the original owner (by using the '-u' flag) and deletes the original object. The different copy versions command required for specific user objects are discussed in the sections below. Changing Ownership of a Table ----------------------------- Because only tables owned by the DBA can be accessed by others, it is often necessary to transfer ownership of a private table to the DBA. While the usual purpose is changing from private ownership to public access, the procedure can be used to change ownership of a table from any current owner to any new owner. Using Copydb, Copy.out and Copy.in - - - - - - - - - - - - - - - - - - For changing ownership of a table, you give three commands: First you use a 'copydb' command to create two executable scripts, 'copy.out' and 'copy.in'. A minimal form of the 'copydb' command for this purpose is: copydb -uYou use an 'sql' command in the following format to execute the 'copy.out' script. This command copies the table from the database, with the current ownership, into an intermediate binary file in your current directory: sql -u ]
© William Yuan 2000
Email William