⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ch12.htm

📁 21精通SQL
💻 HTM
📖 第 1 页 / 共 4 页
字号:
</BLOCKQUOTE>

<H4><FONT COLOR="#000077">The Connect Role</FONT></H4>
<P>The Connect role can be thought of as the entry-level role. A user who has been
granted Connect role access can be granted various privileges that allow him or her
to do something with a database.</P>
<H5>INPUT/OUTPUT:</H5>
<PRE><FONT COLOR="#0066FF">SQL&gt; <B>GRANT CONNECT TO Bryan;
</B>
Grant succeeded.
</FONT></PRE>
<P>The Connect role enables the user to select, insert, update, and delete records
from tables belonging to other users (after the appropriate permissions have been
granted). The user can also create tables, views, sequences, clusters, and synonyms.
<H4><FONT COLOR="#000077">The Resource Role</FONT></H4>
<P>The Resource role gives the user more access to Oracle databases. In addition
to the permissions that can be granted to the Connect role, Resource roles can also
be granted permission to create procedures, triggers, and indexes.</P>
<H5>INPUT/OUTPUT:</H5>
<PRE><FONT COLOR="#0066FF">SQL&gt; <B>GRANT RESOURCE TO Bryan;</B>

Grant succeeded.
</FONT></PRE>
<H4><FONT COLOR="#000077">The DBA Role</FONT></H4>
<P>The DBA role includes all privileges. Users with this role are able to do essentially
anything they want to the database system. You should keep the number of users with
this role to a minimum to ensure system integrity.</P>
<H5>INPUT/OUTPUT:</H5>
<PRE><FONT COLOR="#0066FF">SQL&gt;<B> GRANT DBA TO Bryan;</B>

Grant succeeded.
</FONT></PRE>
<P>After the three preceding steps, user Bryan was granted the Connect, Resource,
and DBA roles. This is somewhat redundant because the DBA role encompasses the other
two roles, so you can drop them now:</P>
<H5>INPUT/OUTPUT:</H5>
<PRE><FONT COLOR="#0066FF">SQL&gt; <B>REVOKE CONNECT FROM Bryan;</B>

Revoke succeeded.

SQL&gt; <B>REVOKE RESOURCE FROM Bryan;
</B>
Revoke succeeded.
</FONT></PRE>
<P>Bryan can do everything he needs to do with the DBA role.
<H3><FONT COLOR="#000077">User Privileges</FONT></H3>
<P>After you decide which roles to grant your users, your next step is deciding which
permissions these users will have on database objects. (Oracle7 calls these permissions
privileges.) The types of privileges vary, depending on what role you have been granted.
If you actually create an object, you can grant privileges on that object to other
users as long as their role permits access to that privilege. Oracle defines two
types of privileges that can be granted to users: system privileges and object privileges.
(See Tables 12.1 and 12.2.)</P>
<P>System privileges apply systemwide. The syntax used to grant a system privilege
is as follows:</P>
<H5>SYNTAX:</H5>
<PRE><FONT COLOR="#0066FF">GRANT system_privilege TO {user_name | role | PUBLIC}
[WITH ADMIN OPTION];
</FONT></PRE>
<P><TT>WITH ADMIN OPTION</TT> enables the grantee to grant this privilege to someone
else.
<H3><FONT COLOR="#000077">User Access to Views</FONT></H3>
<P>The following command permits all users of the system to have <TT>CREATE VIEW</TT>
access within their own schema.</P>
<H5>INPUT:</H5>
<PRE><FONT COLOR="#0066FF">SQL&gt; <B>GRANT CREATE VIEW</B>
  2  <B>TO PUBLIC;</B></FONT></PRE>
<H5><FONT COLOR="#000000">OUTPUT:</FONT></H5>
<PRE><FONT COLOR="#0066FF">Grant succeeded.
</FONT></PRE>
<H5>ANALYSIS:</H5>
<P>The <TT>public</TT> keyword means that everyone has <TT>CREATE VIEW</TT> privileges.
Obviously, these system privileges enable the grantee to have a lot of access to
nearly all the system settings. System privileges should be granted only to special
users or to users who have a need to use these privileges. Table 12.1 shows the system
privileges you will find in the help files included with Personal Oracle7.


<BLOCKQUOTE>
	<P>
<HR>
<FONT COLOR="#000077"><B>WARNING:</B></FONT><B> </B>Use caution when granting privileges
	to <TT>public</TT>. Granting <TT>public</TT> gives all users with access to the database
	privileges you may not want them to have. 
<HR>


</BLOCKQUOTE>

<H4><FONT COLOR="#000077">Table 12.1. System privileges in Oracle7.</FONT></H4>
<P>
<TABLE BORDER="1">
	<TR ALIGN="LEFT" rowspan="1">
		<TD ALIGN="LEFT"><B>System Privilege</B></TD>
		<TD ALIGN="LEFT"><B>Operations Permitted</B></TD>
	</TR>
	<TR ALIGN="LEFT" rowspan="1">
		<TD ALIGN="LEFT" VALIGN="TOP"><TT>ALTER ANY INDEX</TT></TD>
		<TD ALIGN="LEFT" VALIGN="TOP">Allows the grantees to alter any index in any schema.</TD>
	</TR>
	<TR ALIGN="LEFT" rowspan="1">
		<TD ALIGN="LEFT" VALIGN="TOP"><TT>ALTER ANY PROCEDURE</TT></TD>
		<TD ALIGN="LEFT" VALIGN="TOP">Allows the grantees to alter any stored procedure, function, or package in any schema.</TD>
	</TR>
	<TR ALIGN="LEFT" rowspan="1">
		<TD ALIGN="LEFT" VALIGN="TOP"><TT>ALTER ANY ROLE</TT></TD>
		<TD ALIGN="LEFT" VALIGN="TOP">Allows the grantees to alter any role in the database.</TD>
	</TR>
	<TR ALIGN="LEFT" rowspan="1">
		<TD ALIGN="LEFT" VALIGN="TOP"><TT>ALTER ANY TABLE</TT></TD>
		<TD ALIGN="LEFT" VALIGN="TOP">Allows the grantees to alter any table or view in the schema.</TD>
	</TR>
	<TR ALIGN="LEFT" rowspan="1">
		<TD ALIGN="LEFT" VALIGN="TOP"><TT>ALTER ANY TRIGGER</TT></TD>
		<TD ALIGN="LEFT" VALIGN="TOP">Allows the grantees to enable, disable, or compile any database trigger in any schema.</TD>
	</TR>
	<TR ALIGN="LEFT" rowspan="1">
		<TD ALIGN="LEFT" VALIGN="TOP"><TT>ALTER DATABASE</TT></TD>
		<TD ALIGN="LEFT" VALIGN="TOP">Allows the grantees to alter the database.</TD>
	</TR>
	<TR ALIGN="LEFT" rowspan="1">
		<TD ALIGN="LEFT" VALIGN="TOP"><TT>ALTER USER</TT></TD>
		<TD ALIGN="LEFT" VALIGN="TOP">Allows the grantees to alter any user. This privilege authorizes the grantee to change
			another user's password or authentication method, assign quotas on any tablespace,
			set default and temporary tablespaces, and assign a profile and default roles.</TD>
	</TR>
	<TR ALIGN="LEFT" rowspan="1">
		<TD ALIGN="LEFT" VALIGN="TOP"><TT>CREATE ANY INDEX</TT></TD>
		<TD ALIGN="LEFT" VALIGN="TOP">Allows the grantees to create an index on any table in any schema.</TD>
	</TR>
	<TR ALIGN="LEFT" rowspan="1">
		<TD ALIGN="LEFT" VALIGN="TOP"><TT>CREATE ANY PROCEDURE</TT></TD>
		<TD ALIGN="LEFT" VALIGN="TOP">Allows the grantees to create stored procedures, functions, and packages in any schema.</TD>
	</TR>
	<TR ALIGN="LEFT" rowspan="1">
		<TD ALIGN="LEFT" VALIGN="TOP"><TT>CREATE ANY TABLE</TT></TD>
		<TD ALIGN="LEFT" VALIGN="TOP">Allows the grantees to create tables in any schema. The owner of the schema containing
			the table must have space quota on the tablespace to contain the table.</TD>
	</TR>
	<TR ALIGN="LEFT" rowspan="1">
		<TD ALIGN="LEFT" VALIGN="TOP"><TT>CREATE ANY TRIGGER</TT></TD>
		<TD ALIGN="LEFT" VALIGN="TOP">Allows the grantees to create a database trigger in any schema associated with a
			table in any schema.</TD>
	</TR>
	<TR ALIGN="LEFT" rowspan="1">
		<TD ALIGN="LEFT" VALIGN="TOP"><TT>CREATE ANY VIEW</TT></TD>
		<TD ALIGN="LEFT" VALIGN="TOP">Allows the grantees to create views in any schema.</TD>
	</TR>
	<TR ALIGN="LEFT" rowspan="1">
		<TD ALIGN="LEFT" VALIGN="TOP"><TT>CREATE PROCEDURE</TT></TD>
		<TD ALIGN="LEFT" VALIGN="TOP">Allows the grantees to create stored procedures, functions, and packages in their
			own schema.</TD>
	</TR>
	<TR ALIGN="LEFT" rowspan="1">
		<TD ALIGN="LEFT" VALIGN="TOP"><TT>CREATE PROFILE</TT></TD>
		<TD ALIGN="LEFT" VALIGN="TOP">Allows the grantees to create profiles.</TD>
	</TR>
	<TR ALIGN="LEFT" rowspan="1">
		<TD ALIGN="LEFT" VALIGN="TOP"><TT>CREATE ROLE</TT></TD>
		<TD ALIGN="LEFT" VALIGN="TOP">Allows the grantees to create roles.</TD>
	</TR>
	<TR ALIGN="LEFT" rowspan="1">
		<TD ALIGN="LEFT" VALIGN="TOP"><TT>CREATE SYNONYM</TT></TD>
		<TD ALIGN="LEFT" VALIGN="TOP">Allows the grantees to create synonyms in their own schemas.</TD>
	</TR>
	<TR ALIGN="LEFT" rowspan="1">
		<TD ALIGN="LEFT" VALIGN="TOP"><TT>CREATE TABLE</TT></TD>
		<TD ALIGN="LEFT" VALIGN="TOP">Allows the grantees to create tables in their own schemas. To create a table, the
			grantees must also have space quota on the tablespace to contain the table.</TD>
	</TR>
	<TR ALIGN="LEFT" rowspan="1">
		<TD ALIGN="LEFT" VALIGN="TOP"><TT>CREATE TRIGGER</TT></TD>
		<TD ALIGN="LEFT" VALIGN="TOP">Allows the grantees to create a database trigger in their own schemas.</TD>
	</TR>
	<TR ALIGN="LEFT" rowspan="1">
		<TD ALIGN="LEFT" VALIGN="TOP"><TT>CREATE USER</TT></TD>
		<TD ALIGN="LEFT" VALIGN="TOP">Allows the grantees to create users. This privilege also allows the creator to assign
			quotas on any tablespace, set default and temporary tablespaces, and assign a profile
			as part of a <TT>CREATE USER</TT> statement.</TD>
	</TR>
	<TR ALIGN="LEFT" rowspan="1">
		<TD ALIGN="LEFT" VALIGN="TOP"><TT>CREATE VIEW</TT></TD>
		<TD ALIGN="LEFT" VALIGN="TOP">Allows the grantees to create views in their own schemas.</TD>
	</TR>
	<TR ALIGN="LEFT" rowspan="1">
		<TD ALIGN="LEFT" VALIGN="TOP"><TT>DELETE ANY TABLE</TT></TD>
		<TD ALIGN="LEFT" VALIGN="TOP">Allows the grantees to delete rows from tables or views in any schema or truncate
			tables in any schema.</TD>
	</TR>
	<TR ALIGN="LEFT" rowspan="1">
		<TD ALIGN="LEFT" VALIGN="TOP"><TT>DROP ANY INDEX</TT></TD>
		<TD ALIGN="LEFT" VALIGN="TOP">Allows the grantees to drop indexes in any schema.</TD>
	</TR>
	<TR ALIGN="LEFT" rowspan="1">
		<TD ALIGN="LEFT" VALIGN="TOP"><TT>DROP ANY PROCEDURE</TT></TD>
		<TD ALIGN="LEFT" VALIGN="TOP">Allows the grantees to drop stored procedures, functions, or packages in any schema.</TD>
	</TR>
	<TR ALIGN="LEFT" rowspan="1">
		<TD ALIGN="LEFT" VALIGN="TOP"><TT>DROP ANY ROLE</TT></TD>
		<TD ALIGN="LEFT" VALIGN="TOP">Allows the grantees to drop roles.</TD>
	</TR>
	<TR ALIGN="LEFT" rowspan="1">
		<TD ALIGN="LEFT" VALIGN="TOP"><TT>DROP ANY SYNONYM</TT></TD>
		<TD ALIGN="LEFT" VALIGN="TOP">Allows the grantees to drop private synonyms in any schema.</TD>
	</TR>
	<TR ALIGN="LEFT" rowspan="1">
		<TD ALIGN="LEFT" VALIGN="TOP"><TT>DROP ANY TABLE</TT></TD>
		<TD ALIGN="LEFT" VALIGN="TOP">Allows the grantees to drop tables in any schema.</TD>
	</TR>
	<TR ALIGN="LEFT" rowspan="1">
		<TD ALIGN="LEFT" VALIGN="TOP"><TT>DROP ANY TRIGGER</TT></TD>
		<TD ALIGN="LEFT" VALIGN="TOP">Allows the grantees to drop database triggers in any schema.</TD>
	</TR>
	<TR ALIGN="LEFT" rowspan="1">
		<TD ALIGN="LEFT" VALIGN="TOP"><TT>DROP ANY VIEW</TT></TD>
		<TD ALIGN="LEFT" VALIGN="TOP">Allows the grantees to drop views in any schema.</TD>
	</TR>
	<TR ALIGN="LEFT" rowspan="1">
		<TD ALIGN="LEFT" VALIGN="TOP"><TT>DROP USER</TT></TD>
		<TD ALIGN="LEFT" VALIGN="TOP">Allows the grantees to drop users.</TD>
	</TR>
	<TR ALIGN="LEFT" rowspan="1">
		<TD ALIGN="LEFT" VALIGN="TOP"><TT>EXECUTE ANY PROCEDURE</TT></TD>
		<TD ALIGN="LEFT" VALIGN="TOP">Allows the grantees to execute procedures or functions (standalone or packaged) or
			reference public package variables in any schema.</TD>
	</TR>
	<TR ALIGN="LEFT" rowspan="1">
		<TD ALIGN="LEFT" VALIGN="TOP"><TT>GRANT ANY PRIVILEGE</TT></TD>
		<TD ALIGN="LEFT" VALIGN="TOP">Allows the grantees to grant any system privilege.</TD>
	</TR>
	<TR ALIGN="LEFT" rowspan="1">
		<TD ALIGN="LEFT" VALIGN="TOP"><TT>GRANT ANY ROLE</TT></TD>
		<TD ALIGN="LEFT" VALIGN="TOP">Allows the grantees to grant any role in the database.</TD>
	</TR>
	<TR ALIGN="LEFT" rowspan="1">
		<TD ALIGN="LEFT" VALIGN="TOP"><TT>INSERT ANY TABLE</TT></TD>
		<TD ALIGN="LEFT" VALIGN="TOP">Allows the grantees to insert rows into tables and views in any schema.</TD>
	</TR>
	<TR ALIGN="LEFT" rowspan="1">
		<TD ALIGN="LEFT" VALIGN="TOP"><TT>LOCK ANY TABLE</TT></TD>
		<TD ALIGN="LEFT" VALIGN="TOP">Allows the grantees to lock tables and views in any schema.</TD>
	</TR>
	<TR ALIGN="LEFT" rowspan="1">
		<TD ALIGN="LEFT" VALIGN="TOP"><TT>SELECT ANY SEQUENCE</TT></TD>
		<TD ALIGN="LEFT" VALIGN="TOP">Allows the grantees to reference sequences in any schema.</TD>
	</TR>
	<TR ALIGN="LEFT" rowspan="1">
		<TD ALIGN="LEFT" VALIGN="TOP"><TT>SELECT ANY TABLE</TT></TD>
		<TD ALIGN="LEFT" VALIGN="TOP">Allows the grantees to query tables, views, or snapshots in any schema.</TD>
	</TR>
	<TR ALIGN="LEFT" rowspan="1">
		<TD ALIGN="LEFT" VALIGN="TOP"><TT>UPDATE ANY ROWS</TT></TD>
		<TD ALIGN="LEFT" VALIGN="TOP">Allows the grantees to update rows in tables.</TD>
	</TR>
</TABLE>
</P>
<P>Object privileges are privileges that can be used against specific database objects.
Table 12.2 lists the object privileges in Oracle7.
<H4><FONT COLOR="#000077">Table 12.2. Object privileges enabled under Oracle7.</FONT></H4>
<P>
<TABLE BORDER="1">
	<TR ALIGN="LEFT" rowspan="1">
		<TD ALIGN="LEFT"><TT>ALL</TT></TD>
	</TR>
	<TR ALIGN="LEFT" rowspan="1">

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -