Vous êtes sur la page 1sur 11

ORACLE

Oracle database company was established on 1974.


Startup, Shutdown.
SQL Commands
o DDL (Create, Alter, Drop, Truncate)
o DML (Select, Insert, Update, Delete)
o DCL (Commit, Rollback, Savepoint, Grant, Revoke)
PL/SQL
OOPS SQL
DBA Concepts
Project Work
SQL Structured Query Language
DDL Data Definition Language
DML Data Manipulation Language
DCL Data Control Language

USERS
When we install oracle few users are automatically create. These are
System, sys, demo, HR
Note: [System is DBA and Demo, Hr are programmer/Learning]
TYPES OF USERS
Broadly we can categorize three types of user
(1) DBA (2) Programmer & (3) Operator
1. DBA User: Such User having almost all privileges. It can access another user
data without granting permission. When we install ORACLE, few DBA users
are automatically created. Eg: system/manager.
2. Programmer User: Such user who create object for developing software. Eg.
Table, View, Procedure etc. Programmer user cannot create user and cannot
access other user data without permission.
3. Operator User: Such user can only connect with ORACLE, but cannot create
table, view, etc. rather later on DBA grant few tables, view to work on.
Operator User: Normal Database Application (Day to day transaction)
http://localhost:8080/apex/
Server
Web Server
Application Server
Database Server
8080
4141
1521
Web Server: A Web server can be either a computer program or a computer
running a program that is responsible for accepting HTTP requests from clients,
serving back HTTP responses along with optional data contents, which usually are
web pages such as HTML documents and linked objects on it.
Application Server: An application server is the kind of software engine that will
deliver various applications to another device. It is the kind of computer found in an

office or university network that allows everyone in the network to run software of
of the same machine.
Database Server: A database server is a computer program that provides
database services to other computer programs or computers, as defined by the
clientserver model.
SQL(Structured Query Language)
1. ANSI command: There is all 13 ANSI command frequently used in all
database software in all over world. These commands requires semicolon to
terminate the command. These commands are:(a) Create (b) Alter (c) Drop (d) Truncate (e) Select (f) Alter (g) Update
(h) Delete (i) Commit (j) Rollback (k) Savepoint (l) Grant (m) Revoke
2. SQL Plus: These commands are developed by oracle for its own database
software to run. Basically, ANSI commands were also developed by ORACLE
and as it is accepted by them which genuinely enough to work in any
database system. But ORACLE had developed some more commands which is
executed in its first four character syntax for some more execution. These
commands do not require semicolon to terminate the line.
sql>conn system/manager
Predefined Constraints
(a) User & (b) Sysdate
Eg.
This command will display the name of current user working with.
SQL> select user from dual;
This command will display the date from the system.
SQL> select sysdate from dual;
STARTUP
When you start up a database, you create an instance of that database and you
determine the state of the database. Normally, you start up an instance by
mounting and opening the database. Doing so makes the database available for any
valid user to connect to and perform typical data access operations. Other options
exist, and these are also discussed in this section.
SQL> startup
Startup mount
Startup nomount
Startup restrict
Startup force
SHUTDOWN
SQL> shutdown
Shutdown normal
Shutdown immediate
SHUTDOWN TRANSACTIONAL: When you want to perform a planned shutdown of an
instance while allowing active transactions to complete first, use
the SHUTDOWN command with the TRANSACTIONAL clause.

SHUTDOWN ABORT: You can shut down a database instantaneously by aborting the
database instance.
Database Administrator (DBA) User
DBA is of two type: 1. SYSDBA: This DBA user has all kind of access in database which allows
database to control such as:(i) Startup (ii) Shutdown (iii) Alter (iv) Drop (v) Recovery
2. SYSOPTR: This DBA user doesnt have the above privilege. By default we
connect to this type of DBA.
Before 9i that means upto 8i oracle version, has two kind of user. (a) internal & (b)
sysdba
Internal has following property to :
(i) Startup (ii) Shutdown (iii) Alter (iv) Drop (v) Recovery
Now from oracle 9i version, these properties contained by sysdba and sys optr of 9i
contains the properties of sysdba of oracle 8i version.
How to connect to the user?
SQL> conn username/password
For eg: SQL> conn system/manager
How to change the user password?
SQL> alter user user_name identified by pass_word;
For eg: SQL> alter user system identified by manager;
OR
SQL Plus comand
SQL> password;
Old password:
New password:
Retype new password:
BASIC WORKING OF ORACLE
After we install the Oracle package, we were provided with a console interface and a
web interface to work in. The console interface that appears is provided to user as
bufer memory to execute their commands. Each time we write a command and
terminate the line, that request is sent to the database where it has to pass through
PL/SQL Engine which checks for the authentication of the command. When it found
correct by all means discussed in it before it forwards the command to database
and then it returns back to our console with message of accessing.
Oracle provides us two interfaces: SQL console interface and the web browser.
SQL console interface signifies the system is server machine and web browser
interface signified as client because it can be opened in other machine through
networking. But that console interface is available in only server machine. We can
connect to sysdba user in only console media and this does not require any
username and password.
eg: conn / as sysdba
That is why a server is required more efficient physical security and kept separately.

But on the other hand, if we are connecting sysoptr user then we must require
accurate username and password.
So, we can connect oracle as client through the browser. This will not allow to
connect as sysdba user in browser because by default browser is understood client
user. To connect as sysdba it can only be possible through oracle console screen.
The console screen always present in server but browser can open in any client
machine.
HR User
Hr user is created by default for learning process by oracle which is locked by
default. We cannot connect to this user till is locked.
To connect we have to unlock this user, through console screen using sql command.
SQL> alter user hr identified by google;
[Note: Here user is hr and password is google]
Q. How to unlock hr user from sql prompt.
SQL> alter user hr account unlock;
How to create user?
Syntax:
create user user_name identified by pass_word;
SQL> create user Heera identified by lal;
Role: Role is defined as set of privileges. There are two types of role:
a) System defined role
i. DBA
ii. Resource
iii. Connect
b) User defined role
These roles are granted to the new users created by sysdba.
Suppose, a user is created:
1
To grant as DBA User:
SQL>grant dba to username;
DBA
2
To grant as Programmer User:
SQL>grant resource, connect to username; Grant
dba
3
To grant as Operator User:
SQL>grant connect to username;
SQL>
SQL>
SQL>
SQL>

User
Programmer

Operator

Grant
resource,
connect

Grant
connect

create user santosh identified by tom;


grant dba to santosh; For dba user
grant resource, connect to santosh; For programmer user
grant connect to santosh; For operator user

How to grant access between users?


Syntax:
grant priviledge_list on object_name to user_name;
You have two users Ajay and Raj
User Ajay having a emp table. Grant User Raj to see the emp table of user ajay.

First user Ajay connected,


SQL> grant select on emp to Raj;
Second user Raj connected,
SQL> select * from Ajay.emp;
[NOTE: Ajay prefix is used to see the table of Ajay user by Raj user.]

USER DEFINED ROLES:

TABLES
Table is a collection of rows and columns. All kind of data are stored in it. All
database in tabular form.
There is three types of tables can be created in the database.
Permanent Table: - Data is stored in oracle database data file permanently.
Temporary Table: - Data is stored for the current session only. So, temporarily
table does not decide Oracle data file rather it exists into memory only.

To use this table, we have to design temporary tablespace also.


External Table: - Data is not stored in Oracle database rather it is stored outside
the Oracle database in data file like notepad kinds file.
Creating Permanent Table
Sql>create table_name(coloumn_name datatype(size)constraint, table level
constraint,------------)tablespace tablespace_name storage(size initial next
pctiincrease...)cluster cluster_id;
DATA TYPES
It is divided into two parts: 1. Scalar Datatype
a. ANSI Specification
i. Integer
ii. Decimal
iii. Char
iv. Varchar
v. Date
b. Oracle Specification

i. Number
ii. Char
iii. Varchar2
iv. Date
2. Composite Datatype
a. LOBS(Large Objects)
b. Varrays
c. Types
Note: Integer: - ANSI Specification.
Decimal: - ANSI Specification for decimal value.
Number: - Oracle Specification accepts both integer and decimal value.
Char: - It is a fixed length datatype. Trilling blank is added automatically if
small data is passed. This datatype has maximum size range is 0-256.
Varchar: - ANSI specification used in all database.
Varchar2: - Oracle Specification no boundation.
Date: - Size is predefined and format of entry can be diferent in diferent
database software.
Question: Importance of char over varchar or varchar2?
Answer: It is suggested to used char data type for unique identity column because it
fasten searching process. Because it knows the next row starts from the specific
location.
GRANT OBJECT PRIVILEGE
SQL>Grant select on emp to ranchi;

Vous aimerez peut-être aussi