Presentation is loading. Please wait.

Presentation is loading. Please wait.

INTRODUCTION TO ORACLE

Similar presentations


Presentation on theme: "INTRODUCTION TO ORACLE"— Presentation transcript:

1 INTRODUCTION TO ORACLE
Lynnwood Brown President System Managers LLC Database Creation & End User Management – Lecture 3 Copyright System Managers LLC 2003 all rights reserved.

2 MANUAL DATABASE CREATION
Define the administrative user Place the administrative user in the DBA group (UNIX) or the ORA_DBA group (NT/2000) Windows NT/2000 service OracleService<SID> must be created using the ORADIM utility which will create the Oracle service and modify the server's registry Copyright System Managers LLC 2003 all rights reserved.

3 MANUAL DATABASE CREATION
Creating the Instance C:\> ORADIM -NEW  -SID  <YOUR_SID>  -INTPWD  <password>  -STARTMODE <mode> -PFILE  <pfile> <YOUR_SID> - Database SID <password> - Password for database administrative user <mode> - Startup mode for the services, either AUTO or MANUAL <pfile> - Path and name of the INIT<sid>.ORA file

4 MANUAL DATABASE CREATION
Deleting the Instance C:\> ORADIM  -DELETE  -SRVC  <service_name> NOTE: SERVICE_NAME = SID             For Oracle 8.1 and 9.x ORADIM ERRORS ARE IN THE DIRECTORY: <ORACLE_HOME> \DATABASE\ORADIM.LOG Copyright System Managers LLC 2003 all rights reserved.

5 MANUAL DATABASE CREATION
Starting The Instance Ensure that the environmental variables have been set and the services have been started (NT/2000). Log into SQL*PLUS as the system user with administrative privileges C:\> sqlplus “system/manager as sysdba” SQL> startup nomount – Start the Oracle instance but do not mount or open the database. On UNIX this starts the Oracle processes and allocates the SGA          Other startup options include MOUNT and EXCLUSIVE

6 MANUAL DATABASE CREATION
Creating The Database Must have at least one tablespace (SYSTEM) One or more data files is specified for the SYSTEM tablespace Must have at least one log group or two log files Copyright System Managers LLC 2003 all rights reserved.

7 MANUAL DATABASE CREATION
Creating The Database 8i SQL > create database test logfile group 1 (‘c:\oradata\test\redo01.log', ‘c:\oradata\test\redo02.log') size 5M, group 2 (‘c:\oradata\test\redo03.log', ‘c:\oradata\test\redo04.log') size 5M maxlogfiles 9 datafile ‘c:\oradata\test\system01.dbf' size 150M maxdatafiles 255 maxinstances 1 noarchivelog character set WE8ISO8859P1 / Copyright System Managers LLC 2003 all rights reserved.

8 MANUAL DATABASE CREATION
Creating The Database catalog.sql - Script that creates the basic Oracle Data Dictionary objects catproc.sql - Script that creates the Oracle Data Dictionary objects for procedural option (PL/SQL) Create Additional Tablespaces (TEMP, INDEX, DATA) create tablespace DATA datafile ‘c:\oradata\test\data01.dbf' size 50M reuse default storage (initial 1M next 1M minextents 1 maxextents unlimited pctincrease 0)

9 MANUAL DATABASE CREATION
Creating The Database (Rollback Segments) 8i create tablespace RBS datafile 'd:\oradata\test\rbs01.dbf' size 50M reuse default storage (initial 1M next 1M minextents 2 maxextents unlimited pctincrease 0) / create rollback segment RBS01 storage (initial 1M next 1M minextents 2 maxextents unlimited) tablespace RBS alter rollback segment RBS01 online Copyright System Managers LLC 2003 all rights reserved.

10 MANUAL DATABASE CREATION
Creating The Database 9i CREATE DATABASE test MAXLOGFILES 9 MAXINSTANCES 1 MAXDATAFILES 256 MAXLOGHISTORY 256 DATAFILE 'c:\test\system_01.dbf' SIZE 150M UNDO TABLESPACE "UNDOTBS" DATAFILE 'c:\test\undotbs_01.dbf' SIZE 150M AUTOEXTEND ON NEXT 5M MAXSIZE UNLIMITED CHARACTER SET WE8ISO8859P1 LOGFILE GROUP 1 ('c:\test\redo1_01.dbf‘) SIZE 50M, GROUP 2 ('c:\test\redo1_02.dbf') SIZE 50M;

11 MANUAL DATABASE CREATION
UNDO Tablespace New in Oracle 9i Replaces rollback segments RDBMS manages undo segments automatically: New init<SID>.ora parameters: UNDO_MANAGEMENT AUTO or Manual (use roll back segments) UNDO_TABLESPACE = <Undo tablespace name>

12 MANUAL DATABASE CREATION
UNDO Tablespace (cont) Creating an UNDO tablespace after the database has been created: SQL> create undo tablespace UNDO_TS1 datafile ‘c:\oradata\undorbs1.dbf' size 100m; SQL> alter system set undo_tablespace=undo_ts1; Copyright System Managers LLC 2003 all rights reserved.

13 MANUAL DATABASE CREATION
Creating And Enlarging Tablespaces Automatically increase tablespace sizes using “AUTOEXTEND” CREATE TABLESPACE DATA DATAFILE '/u01/oracle/rbdb1/users01.dbf' SIZE 300M REUSE AUTOEXTEND ON NEXT 5M MAXSIZE 1500M; Add another data file if not using AUTOEXTEND SQL > alter tablespace DATA add datafile '/u01/oracle/rbdb1/users02.dbf' size 20M;

14 MANUAL DATABASE CREATION
Shutting Down the Database Must be the administrative user: SQL> shutdown normal             Other SHUTDOWN options include: IMMEDIATE – Allow transactions to complete and then log off all users ABORT – Log off all users (no grace period)

15 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 2003 all rights reserved.

16 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 2003 all rights reserved.

17 END USER MANAGEMENT End User Profiles – Resource Control
SQL > CREATE PROFILE new_user LIMIT 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;

18 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 2003 all rights reserved.

19 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;

20 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 2003 all rights reserved.

21 OBJECT CREATION Create Table: Create View: 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 2003 all rights reserved.

22 OBJECT CREATION Create Index: Create Synonym: Create Sequence:
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 2003 all rights reserved.

23 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 2003 all rights reserved.

24 SOME ORACLE DATA DICTIONARY TABLES/VIEWS FOR MANAGING END USERS:
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 database DBA_TABLES Names of all tables in the database DBA_INDEXES Names of all indexes in the database DBA_SYNONYMS Names of all indexes in the synonyms DBA_SEQUENCES Names of all sequences in the database DBA_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 2003 all rights reserved.

25 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 2003 all rights reserved.


Download ppt "INTRODUCTION TO ORACLE"

Similar presentations


Ads by Google