Where allowed to run: All environments (*ALL) Threadsafe: No |
Parameters Examples Error messages |
The Copy Library (CPYLIB) command copies the contents of a library to a new library. If the new library does not exist, the command optionally creates it before the copy.
All copied objects are created in the same auxiliary storage pool (ASP) as the new library. Any objects that already exist in the new library remain in the new library after the new objects are copied.
Note: If the new library is created by this command:
Restrictions:
Top |
Keyword | Description | Choices | Notes |
---|---|---|---|
FROMLIB | Existing library | Name | Required, Positional 1 |
TOLIB | New library | Name | Required, Positional 2 |
CRTLIB | Create library | *YES, *NO | Optional |
DATA | Duplicate data | *YES, *NO | Optional |
CST | Duplicate constraints | *YES, *NO | Optional |
TRG | Duplicate triggers | *YES, *NO | Optional |
Top |
Specifies the existing library to be copied.
This is a required parameter.
Top |
Specifies the new library to which objects will be copied from the existing library.
This is a required parameter.
Top |
Specifies whether the new library should be created.
Top |
Specifies whether the data records in database physical files or save files in the existing library are copied to the newly-created object in the new library. Members of physical files are copied whether or not the data contained in them is copied. The specified value is not used for objects which are not database physical files or save files.
Note: The relative record numbers in the new file are the same as those in the original file.
Top |
Specifies whether any constraints associated with database physical files in the existing library are copied to the newly-created files in the new library. The specified value is not used for objects which are not database physical files.
Top |
Specifies whether any triggers associated with database physical files in the existing library are copied to the newly-created files in the new library. The specified value is not used for objects which are not database physical files.
Note: There are special considerations of which to be aware relating to the duplication of triggers. For example, the duplication will differ depending on whether or not the trigger program associated with the existing file was in the same library as the existing file. For additional information, see the Database information in the iSeries Information Center at http://www.ibm.com/eserver/iseries/infocenter.
Top |
Example 1: Copying the Contents of a Library to a New library After Creating the New Library
CPYLIB FROMLIB(MYLIB) TOLIB(NEWLIB)
This command copies the contents of library MYLIB into library NEWLIB after creating library NEWLIB. The data records, constraints, and triggers associated with a database physical file in MYLIB will be copied to the database physical file in NEWLIB.
Example 2: Copying the Contents of a Library to an Existing Library
CPYLIB FROMLIB(MYLIBA) TOLIB(MYLIBB) CRTLIB(*NO) + DATA(*YES) CST(*NO) TRG(*NO) MONMSG MSGID(CPF2358)
This command copies the contents of library MYLIBA into existing library MYLIBB. All copied objects are created in the same auxiliary storage pool (ASP) as library MYLIBB. Any objects that already exist in library MYLIBB remain in library MYLIBB after the new objects are copied. The data records in a database physical file in MYLIBA will be copied to a newly created database physical file in MYLIBB. The constraints and triggers associated with a database physical file in MYLIBA will not be copied to a newly created database physical file in MYLIBB.
The MONMSG command allows you to ignore escape message CPF2358 which may be signalled if all objects in library MYLIBA cannot be copied to library MYLIBB. One reason an object cannot be copied is if the object already exists in library MYLIBB.
Top |
*ESCAPE Messages
Top |