-- Copyright (c) Oracle Corporation 1988, 2003. All Rights Reserved.
--
-- NAME
-- pupbld.sql
--
-- DESCRIPTION
-- Script to install the SQL*Plus PRODUCT_USER_PROFILE tables. These
-- tables allow SQL*Plus to disable commands per user. The tables
-- are used only by SQL*Plus and do not affect other client tools
-- that access the database. Refer to the SQL*Plus manual for table
-- usage information.
--
-- This script should be run on every database that SQL*Plus connects
-- to, even if the tables are not used to restrict commands.
-- sqlplus system/<system_password> @pupbld
--
-- Connect as SYSTEM before running this script
-- If PRODUCT_USER_PROFILE exists, use its values and drop it
SELECT PRODUCT, USERID, ATTRIBUTE, SCOPE, NUMERIC_VALUE, CHAR_VALUE,
DATE_VALUE FROM PRODUCT_USER_PROFILE;
ALTER TABLE SQLPLUS_PRODUCT_PROFILE ADD (LONG_VALUE LONG);
(
PRODUCT VARCHAR2 (30) NOT NULL,
USERID VARCHAR2 (30),
ATTRIBUTE VARCHAR2 (240),
SCOPE VARCHAR2 (240),
NUMERIC_VALUE DECIMAL (15,2),
CHAR_VALUE VARCHAR2 (240),
DATE_VALUE DATE,
LONG_VALUE LONG
);
CREATE VIEW PRODUCT_PRIVS AS
SELECT PRODUCT, USERID, ATTRIBUTE, SCOPE,
NUMERIC_VALUE, CHAR_VALUE, DATE_VALUE, LONG_VALUE
FROM SQLPLUS_PRODUCT_PROFILE
WHERE USERID = 'PUBLIC' OR USER LIKE USERID;
DROP PUBLIC SYNONYM PRODUCT_PROFILE;
CREATE PUBLIC SYNONYM PRODUCT_PROFILE FOR SYSTEM.PRODUCT_PRIVS;
DROP SYNONYM PRODUCT_USER_PROFILE;
CREATE SYNONYM PRODUCT_USER_PROFILE FOR SYSTEM.SQLPLUS_PRODUCT_PROFILE;
DROP PUBLIC SYNONYM PRODUCT_USER_PROFILE;
CREATE PUBLIC SYNONYM PRODUCT_USER_PROFILE FOR SYSTEM.PRODUCT_PRIVS;
-- 所有业务系统用户禁止执行sqlplus一些命令
insert into PRODUCT_USER_PROFILE (product, userid, attribute, char_value)
values ('SQL*Plus','%WENDING','HOST','DISABLED');
values ('SQL*Plus','%WENDING','ALTER','DISABLED');
values ('SQL*Plus','%WENDING','AUDIT','DISABLED');
values ('SQL*Plus','%WENDING','ANALYZE','DISABLED');
values ('SQL*Plus','%WENDING','CREATE','DISABLED');
values ('SQL*Plus','%WENDING','DELETE','DISABLED');
values ('SQL*Plus','%WENDING','DROP','DISABLED');
values ('SQL*Plus','%WENDING','LOCK','DISABLED');
values ('SQL*Plus','%WENDING','NOAUDIT','DISABLED');
values ('SQL*Plus','%WENDING','RENAME','DISABLED');
values ('SQL*Plus','%WENDING','SELECT','DISABLED');
values ('SQL*Plus','%WENDING','UPDATE','DISABLED');
values ('SQL*Plus','%WENDING','VALIDATE','DISABLED');
values ('SQL*Plus','%WENDING','TRUNCATE','DISABLED');
values ('SQL*Plus','%WENDING','GRANT','DISABLED');
values ('SQL*Plus','%WENDING','REVOKE','DISABLED');
values ('SQL*Plus','%WENDING','SET ROLE','DISABLED');
values ('SQL*Plus','%WENDING','SET TRANSACTION','DISABLED');
values ('SQL*Plus','%WENDING','DECLARE','DISABLED');
values ('SQL*Plus','%WENDING','BEGIN','DISABLED');
values ('SQL*Plus','%WENDING','EXECUTE','DISABLED');
values ('SQL*Plus','%WENDING','COPY','DISABLED');
--values ('SQL*Plus','%WENDING','SET','DISABLED');
values ('SQL*Plus','%WENDING','EDIT','DISABLED');
values ('SQL*Plus','%WENDING','PASSWORD','DISABLED');
values ('SQL*Plus','%WENDING','SPOOL','DISABLED');
values ('SQL*Plus','%WENDING','START','DISABLED');
--values ('SQL*Plus','%WENDING','QUIT','DISABLED');
--values ('SQL*Plus','%WENDING','EXIT','DISABLED');
values ('SQL*Plus','%WENDING','RUN','DISABLED');
values ('SQL*Plus','%WENDING','GET','DISABLED');
values ('SQL*Plus','%WENDING','SAVE','DISABLED');
禁用SQL*Plus START的同时也会禁用SQL*Plus @和@@命令。
禁用SQL*Plus HOST的同时也会禁用等同命令(如VMS上的$以及UNIX上的!)。