Delete and clear libraries

When you delete a library with the Delete Library (DLTLIB) command, you delete the objects in the library as well as the library itself.

When you clear a library with the Clear Library (CLRLIB) command, you delete objects in the library without deleting the library. To delete or clear a library, all you need to specify is the library name. For example:

DLTLIB LIB(DISTLIB)
CLRLIB LIB(DISTLIB)

To delete a library, you must have object existence authority for both the library and the objects within the library, and use authority for the library. If you try to delete a library but do not have object existence authority for all the objects in the library, the library and all objects for which you do not have authority are not deleted. All objects for which you have authority are deleted. If you try to delete a library but do not have object existence authority for the library, not only is the library not deleted, but none of the objects in the library are deleted. If you want to delete a specific object (for which you have object existence authority), you can use a delete command for that type of object, such as the Delete Program (DLTPGM) command.

You cannot delete a library in an active job's library list. You must wait until the end of the job before the deletion of the library is allowed. Because of this, you must delete the library before the next routing step begins. When you delete a library, you must be sure no one else needs the library or the objects within the library.

If a library is part of the initial library list defined by the system values QSYSLIBL and QUSRLIBL, the following steps should be followed to delete the library:
  1. Use the Change System Value (CHGSYSVAL) command to remove the library from the system value it is contained in. (The changed system value does not affect the library list of any jobs running.)
  2. Use the Change Library List (CHGLIBL) command to change the job's library list.

    The Change System Library List (CHGSYSLIBL), Add Library List Entry (ADDLIBLE), Edit Library List (EDTLIBL), and Remove Library List Entry (RMVLIBLE) commands are also used to change the library list.

  3. Use the Delete Library (DLTLIB) command to delete the library and the objects in the library.
Note: You cannot delete the library QSYS and should not delete any objects in it. You may cause the system to end because the system needs objects that are in QSYS to operate properly. You should not delete the library QGPL because it also contains some objects that are necessary for the system to be able to perform effectively. You should not use the library QRECOVERY because it is intended for system use only. The library QRECOVERY contains objects that the system needs to operate properly.

To clear a library, you must have object existence authority for the objects within the library and use authority for the library. If you try to clear a library but do not have object existence authority for all the objects in the library, the objects you do not have authority for are not deleted from the library. If an object is allocated to someone else, it is not deleted.

Related tasks
Delete objects
Related information
CL command finder
Clear Library (CLRLIB) command
Delete Library (DLTLIB) command
Change Library List (CHGLIBL) command
Change System Value (CHGSYSVAL) command
Remove Library List Entry (RMVLIBLE) command