Upload
margery-fleming
View
214
Download
0
Embed Size (px)
Citation preview
INTRODUCTION TO ORACLE
Lynnwood BrownSystem Managers LLC
End User Management – Lecture 3
Copyright System Managers LLC 2007 all rights reserved.
END USER MANAGEMENT
• Create database users by using the CREATE/ALTER USER commands.
• Create database objects (tables, views, synonyms and indexes).
• Control database access/security by granting access privileges: grant update on emp to scott;
• Grant database access so that users can/cannot pass the privilege on to other users: grant update on emp to scott with admin option;
Copyright System Managers LLC 2007 all rights reserved.
END USER MANAGEMENT
To create a user named SCOTT with password TIGER:
SQL > Create user scott identified by tiger
SQL > Default tablespace users
SQL > Temporary tablespace temp
SQL > Quota 15m on users;
Give SCOTT the privilege to connect to the database and create objects.
SQL > Grant connect, resource to scott;
Copyright System Managers LLC 2007 all rights reserved.
END USER MANAGEMENT
End User Profiles – Resource Control
SQL > CREATE PROFILE new_userLIMIT sessions_per_user 10 connect_time 30 idle_time 10;
Altering User Access To Resources
SQL > ALTER USER <userID> IDENTIFIED BY <pw>profile new_user;
END USER MANAGEMENT
• Create roles to automate the security/access process:
SQL > create role manager;SQL > grant update on emp to manager;SQL > grant manager to scott;
• Oracle has several pre-defined roles. One of the pre-defined roles is called DBA.
Copyright System Managers LLC 2007 all rights reserved.
END USER MANAGEMENT
• How to determine the privileges a user or role has:
SQL > select grantee, privilege from sys.dba_sys_privs;
• How to determine which users are in which roles:
SQL > select grantee, granted_role from sys.dba_role_privs;
OBJECT CREATION
Database objects include:
Tables – Used to store records (rows of data)
Views – Like a table but takes up no disk space. Is based on an underlying table.
Indexes – Use to speed retrieval of data from a table.
Synonyms – Used to reference objects owned by another user without having to reference the object owners name/schema.
Sequence – Used to generate a unique number
Database links – Used to access data in one database from another database.
Copyright System Managers LLC 2007all rights reserved.
OBJECT CREATION
Create Table:
Create table dept(deptno number,Creation date,Dname varchar2(10)Dloc varchar2(20);
Create View:
Create view DVIEW as select deptno, dname, dloc from dept;
Copyright System Managers LLC 2007 all rights reserved.
OBJECT CREATION
Create Index:
Create index i_dept on dept(deptno);
Create Synonym:
Create public synonym dept on dept;
Create Sequence:
Create sequence dept_num start with 1 increment by 1;
Copyright System Managers LLC 2007 all rights reserved.
OBJECT MANAGEMENT
System and Object Management
ALTER TABLE EMP ADD (COLx NUMBER(7,2)…..);
ALTER TABLE EMP MODIFY (COLx NUMBER(8,2));
ALTER SESSION <userID> IDENTIFIED BY <pw>;
ALTER SYSTEM SET LICENSE_MAX_SESSIONS/USERS
LICENSE_SYSTEMS_WARNINGS;
Copyright System Managers LLC 2007 all rights reserved.
THE DATA DICTIONARY
SOME ORACLE DATA DICTIONARY TABLES/VIEWS FOR MANAGING END USERS:
Table/View Name Description DBA_USERS Names of all users of the databaseDBA_TABLES Names of all tables in the databaseDBA_INDEXES Names of all indexes in the databaseDBA_SYNONYMS Names of all indexes in the synonymsDBA_SEQUENCES Names of all sequences in the databaseDBA_VIEWS Names of all views in the database
There are many other tables/views in the Oracle data dictionary. Refer to the Oracle Administrators Guide for a complete list/description
Copyright System Managers LLC 2007 all rights reserved.
THE DATA DICTIONARY
DATA DICTIONARY VIEWS ACCESSIBLE TO END USERS:
• DBA_<name> - End users must be granted the privilege to access the DBA views
• ALL_<name> - Objects that the end user has access to but did not create
• USER_<name> - Objects created by the end user
Copyright System Managers LLC 2007 all rights reserved.