Professional Documents
Culture Documents
To set pause on, in order to paginate and delay the output display
Set pause on;
To fined sql *plus command
Sql>help index
To fine help on each command :
Sql>help command name eg help define; etc.
To change password for a user:
Sql>Passw
To see the datafile we have in a database
Select file_name bytes/1024/1024 MB from dba_data_files;
Note: byte/1024/1024 is to convert the number to mb
To fined where logfile is:
Select member , status, group# from v$logfile;
Note:redo logfile is use for recovery
To view the logs:
Select group#, sequence#, bytes, archived, status from v$log;
To add more logs into a disk group:
Alter database add logfile member C:\app\oracle\oradata\orcl\redo01b.log to group 1;
Note:u can only change the group and redo number for each.
To make oracle see the group and the logs created:
Sql>Alter system switch logfile;
Note:this will be run depending on the number of groups created.
To drop logfile
Alter database Drop logfile group number(eg 1 or 2 etc)
TO fine trace file:
Show parameter background_dump_dest
This directory: C:\app\oracle\diag\rdbms\orcl\orcl\trace
Backup of database
Backup Script
The provided backup script performs online backups of a database that is in ARCHIVELOG mode
and offline backups of a database that is in NOARCHIVELOG mode. Online backups are backups
that can run while the database is running. Offline backups are backups that run when the database is
in the mounted (but not open) state. For offline backups, the backup script automatically puts the
database in the proper state. During offline backups, the database is unavailable to your applications.
You run the backup script by running the Backup Database command from the desktop.
Restore Script
The provided restore script restores the database differently depending on whether log archiving is on
or off:
Change the size of the flash recovery area to at least 15 gigabytes to allow for the extra space required
for archived log files.
For example, to set the flash recovery area size to 20 gigabytes, enter the following command:
C:\app\nspire_oracle\product\11.2.0\dbhome_1\admin\sample\arch> dir.
So we can now use these archivelog to perform recovery if anything went wronged
To backup and create control file
alter database backup CONTROLFILE to 'C:\Users\nspire_oracle\orcl_log_02022010.trn';
or
Alter database backup controlfile to trace;
Hotbackup
To backup tablespace
Alter tablespace users begin backup;
///////////////
Alter tablespace user end backup;
Or whole database as
Alter database begin backup;
////////
Alter database end backup;
Hot backup for tablespace
Select file_name from dba_data_files where tablespace_name =USERS;
Alter tablespace users begin backup;
Copy the file to admin directory as:
Host
Monitoring users
Create user ayua identified by ayuaPassword default tablespace EXAMPLE temporary tablespace
TEMP quota 10m on EXAMPLE quota unlimited on EXAMPLE password expire account lock;
We can assign sysdba privileges to any user as
Grant sysdba to hr,scott;
Select * from V$pwfile_users;
Revoke sysdba from scott, hr;
How to fined password expiration date or limit for your account
Select * from user_password_limits; or
Select username,account_status, expiry_date from dba_users;
Alter profile default limit password_life_time unlimited; or 180 or 90; etc
Creating profile to control users work in the database
Create profile profile limit session_per_user 2
Idle_time 30
Connect_time 480
Failed_login_time 365
Password_lock_time 1/1440*5;
TO KILL A SESSION THAT IS STARTED BUT DOING NOTHING
Select sid, serial#,osuser,username,logon_time from v$session;
Alter system kill session 144,184;
Sql developer
How to create connection to the oracle database using sql developer
Click on the new connection (+) after you startup the sql developer and follow the steps