1.创建service
service_name
The name of the service limited to 64 characters in the Data Dictionary
network_name
The network name of the service as used in SQLNet connect descriptors for client connections. This is limited to the NET service_names character set (see Oracle Database Net Services Reference).
service_name、network_name两个参数是必须的:前者表示数据字典内部使用的名称;后者是监听中对应的名称。
DBMS_SERVICE.CREATE_SERVICE('ernie.us.oracle.com','ernie.us.oracle.com');
2.启动service
DBMS_SERVICE.START_SERVICE('ernie.us.oracle.com');
3.修改service
BEGIN
DBMS_SERVICE.modify_service(
service_name => 'my_new_service',
goal => DBMS_SERVICE.goal_throughput
);
END;
/
4.关闭service
DBMS_SERVICE.STOP_SERVICE('ernie.us.oracle.com');
5.删除service
DBMS_SERVICE.DELETE_SERVICE('ernie.us.oracle.com');
6.断开service的所有会话
DBMS_SERVICE.post_transaction:事务结束,会话就断开。这是默认设置(value:0)。
DBMS_SERVICE.immediate:会话立即断开连接(value:1)
DBMS_SERVICE.noreplay:会话立即断开连接,标记为不再replay(value:2)
DBMS_SERVICE.DISCONNECT_SESSION('ernie.us.oracle.com');
BEGIN
DBMS_SERVICE.disconnect_session(
service_name => 'my_new_service',
disconnect_option => DBMS_SERVICE.immediate
);
END;
/
7.查看service状态
SELECT name,network_name FROM dba_services;
SELECT name,network_name FROM v$active_services;