DBMS_CACHE Package
The DBMS_CACHE
package facilitates the automatic caching for external table caches in an Autonomous AI Database instance.
- Summary of DBMS_CACHE Subprograms
This table summarizes the subprograms included in theDBMS_CACHE
package.
Parent topic: Autonomous AI Database Supplied Package Reference
Summary of DBMS_CACHE Subprograms
This table summarizes the subprograms included in the DBMS_CACHE
package.
Subprogram | Description |
---|---|
Clears all external table caches for a specified user. |
|
Retrieves external table caching properties. |
|
Retrieves external table caching properties for a specified user. |
|
Refreshes all external table caches for a specified user. |
|
Specifies the external table caching preference for all database users. |
|
Specifies the external table caching preference for a specified user. |
- CLEAR Procedure
Use theDBMS_CACHE.CLEAR
procedure to drop all external table caches for a specified user. - GET_GLOBAL_PROPERTY Procedure
TheDBMS_CACHE.GET_GLOBAL_PROPERTY
procedure retrieves the external table caching preferences for all the users in the database. This procedure is overloaded. - SET_GLOBAL_PROPERTY Procedure
UseDBMS_CACHE.SET_GLOBAL_PROPERTY
procedure to set AUTO caching properties for all database users, including those that enable automatic caching for the database. This procedure is overloaded. - REFRESH Procedure
Use theDBMS_CACHE.REFRESH
procedure to refresh all the AUTO external table caches for a specified user. - GET_USER_PROPERTY Procedure
Use theDBMS_CACHE.GET_USER_PROPERTY
procedure to retrieve automatic caching properties for a user. - SET_USER_PROPERTY Procedure
Use theDBMS_CACHE.SET_USER_PROPERTY
procedure to set AUTO caching properties for a specified schema, including those that enable automatic caching for the schema. This procedure is overloaded.
Parent topic: DBMS_CACHE Package
CLEAR Procedure
Use the DBMS_CACHE.CLEAR
procedure to drop all external table caches for a specified user.
DBMS_CACHE.CLEAR
procedure drops all the external table caches and release the storage space, similar to how the DROP
command works on a database table.
Syntax
DBMS_CACHE.CLEAR
(
owner IN VARCHAR2
);
Parameters
Parameter | Description |
---|---|
|
Specifies the schema name. |
Example
BEGIN
DBMS_CACHE.CLEAR
(
owner => 'SALES');
END;
/
Usage Note
-
You must be logged in as the
ADMIN
user or haveEXECUTE
privilege on theDBMS_CACHE
package to clear a cache.
Parent topic: Summary of DBMS_CACHE Subprograms
GET_GLOBAL_PROPERTY Procedure
The DBMS_CACHE.GET_GLOBAL_PROPERTY
procedure retrieves the external table caching preferences for all the users in the database. This procedure is overloaded.
Syntax
DBMS_CACHE.GET_GLOBAL_PROPERTY
(
property_name IN VARCHAR2,
property_value_num OUT VARCHAR2);
DBMS_CACHE.GET_GLOBAL_PROPERTY
(
property_name IN VARCHAR2,
property_value_str OUT VARCHAR2);
Parameters
Parameter | Description |
---|---|
|
Specifies the property name. Following are the valid values for
property_name :
|
|
Retrieves a |
|
Retrieves a |
Example
SET SERVEROUTPUT ON;
DECLARE
cache_property NUMBER;
BEGIN
DBMS_CACHE.GET_GLOBAL_PROPERTY
(
property_name => 'MAX_CACHE_SIZE',
property_value => cache_property
);
DBMS_OUTPUT.PUT_LINE('MAX_CACHE_SIZE = ' || cache_property);
END;
/
Usage Note
-
You must be logged in as the
ADMIN
user or haveEXECUTE
privilege on theDBMS_CACHE
package to run this procedure.
Parent topic: Summary of DBMS_CACHE Subprograms
SET_GLOBAL_PROPERTY Procedure
Use DBMS_CACHE.SET_GLOBAL_PROPERTY
procedure to set AUTO caching properties for all database users, including those that enable automatic caching for the database. This procedure is overloaded.
By default, automatic caching of external tables is disabled. To enable it, set the cache size to a non-zero value using the MAX_CACHE_SIZE
or MAX_CACHE_SIZE
property of the DBMS_CACHE.SET_GLOBAL_PROPERTY
procedure. This enables automatic caching globally for the database.
Syntax
DBMS_CACHE.SET_GLOBAL_PROPERTY
(
property_name IN VARCHAR2,
property_value_num IN NUMBER);
DBMS_CACHE.SET_GLOBAL_PROPERTY
(
property_name IN VARCHAR2,
property_value_str IN VARCHAR2);
Parameters
Parameter | Description |
---|---|
|
Specifies the property name. Following are the valid values for
property_name :
|
|
Provides a |
|
Provides a |
Examples
BEGIN
DBMS_CACHE.SET_GLOBAL_PROPERTY
(
property_name => 'MAX_CACHE_SIZE',
property_value_num => 50);
END;
/
BEGIN
DBMS_CACHE.SET_GLOBAL_PROPERTY
(
property_name => 'AUTO_REFRESH_MODE',
property_value_str => 'NEW');
END;
/
BEGIN
DBMS_CACHE.SET_GLOBAL_PROPERTY
(
property_name => 'MAX_REFRESH_WINDOW',
property_value_num => 20);
END;
/
Usage Notes
-
You must be logged in as the
ADMIN
user or haveEXECUTE
privilege on theDBMS_CACHE
package to run this procedure. -
The
MAX_REFRESH_WINDOW
property specifies, in second, the maximum time allowed for refreshing external table caches. If the refresh exceeds the specified limit, the cache refresh exits normally, and any remaining eligible caches are queued for the next refresh cycle. -
When you refresh caches using the
DBMS_CACHE.REFRESH
procedure, the procedure parameter take precedence over theAUTO_REFRESH_MODE
property.See REFRESH Procedure for more information.
Parent topic: Summary of DBMS_CACHE Subprograms
REFRESH Procedure
Use the DBMS_CACHE.REFRESH
procedure to refresh all the AUTO external table caches for a specified user.
Syntax
DBMS_CACHE.REFRESH
(
owner IN VARCHAR2,
refresh_type IN VARCHAR2 DEFAULT ALL
);
Parameters
Parameter | Description |
---|---|
|
Specifies the schema name. |
|
Specifies the refresh option. Following are the valid
refresh_type values:
This parameter is optional and defaults to |
Example
BEGIN
DBMS_CACHE.REFRESH
(
owner => 'SALES',
refresh_type => 'CURRENT');
END;
/
Usage Notes
-
You must be logged in as the
ADMIN
user or haveEXECUTE
privilege on theDBMS_CACHE
package to run this procedure. -
If you do not specify a value for the
refresh_type
parameter, Oracle perform refresh based onauto_refresh_mode
value. The default value forauto_refresh_mode
isALL
. -
When the
MAX_REFRESH_WINDOW
property is set, Oracle attempts to perform refresh in the specified window. If the refresh exceeds the specified limit, the cache refresh exits normally, and any remaining eligible caches are queued for the next refresh cycle. -
All AUTO caches in the database are managed by using an eviction algorithm similar to Least Recently Used (LRU). When under space pressure, caches that have been accessed least recently are automatically dropped during the refresh process to release the storage space.
Parent topic: Summary of DBMS_CACHE Subprograms
GET_USER_PROPERTY Procedure
Use the DBMS_CACHE.GET_USER_PROPERTY
procedure to retrieve automatic caching properties for a user.
Syntax
DBMS_CACHE.GET_USER_PROPERTY
(
property_name IN VARCHAR2,
owner IN VARCHAR2 DEFAULT NULL,
property_value_str OUT VARCHAR2);
DBMS_CACHE.GET_USER_PROPERTY
(
property_name IN VARCHAR2,
owner IN VARCHAR2 DEFAULT NULL,
property_value_num OUT NUMBER);
Parameters
Parameter | Description |
---|---|
|
Specifies the property name. Following are the valid values for
property_name :
|
|
Specifies the schema name. This parameter is optional and defaults to the current schema. |
|
Retrieves a |
|
Retrieves a |
Example
SET SERVEROUTPUT ON;
DECLARE
cache_property NUMBER;
BEGIN
DBMS_CACHE.GET_USER_PROPERTY
(
property_name => 'MAX_CACHE_SIZE',
owner => NULL,
property_value => cache_property
);
DBMS_OUTPUT.PUT_LINE('MAX_CACHE_SIZE = ' || cache_property);
END;
/
Usage Note
-
You must be logged in as the
ADMIN
user or haveEXECUTE
privilege on theDBMS_CACHE
package to run this procedure.
Parent topic: Summary of DBMS_CACHE Subprograms
SET_USER_PROPERTY Procedure
Use the DBMS_CACHE.SET_USER_PROPERTY
procedure to set AUTO caching properties for a specified schema, including those that enable automatic caching for the schema. This procedure is overloaded.
Syntax
DBMS_CACHE.SET_USER_PROPERTY
(
property_name IN VARCHAR2,
property_value_num IN NUMBER,
owner IN VARCHAR2 DEFAULT NULL);
DBMS_CACHE.SET_USER_PROPERTY
(
property_name IN VARCHAR2,
property_value_str IN NUMBER,
owner IN VARCHAR2 DEFAULT NULL
);
Parameters
Parameter | Description |
---|---|
|
Specifies the property name. Following are the valid values for
property_name :
|
|
Provides a |
|
Provides a |
|
Specifies the schema name. This parameter is optional and defaults to the current schema. |
Example
BEGIN
DBMS_CACHE.SET_USER_PROPERTY
(
property_name => 'MAX_CACHE_SIZE',
property_value_num => 50,
owner => 'SALES');
END;
/
Usage Note
-
You must be logged in as the
ADMIN
user or haveEXECUTE
privilege on theDBMS_CACHE
package to run this procedure.
Parent topic: Summary of DBMS_CACHE Subprograms