When creating and altering usernames, you need to be aware of three areas:
Tablespaces
If a user’s default and temporary tablespaces are not set, then the database will default to the SYSTEM tablespace. This is not good because you do not want to store user and temporary objects within the SYSTEM tablespace. The SYSTEM tablespace is used to store the Data Dictionary information.
Resource Settings
Resource limits are important because they control how much space and processor usage is allocated to a user. User profiles are used to limit resources. "To use resource limits within your database, you must first turn them on, by setting the initialization parameter resource_limit to TRUE within the init.ora file for the database." (Fieldhouse)
To check which profile has been assigned to each user, use the command:
SQL> select username, profile
from dba_users
where username not in (‘SYS’, ‘SYSTEM’);
To check the resource settings for a certain profile, such as sam_user,
use the command:
SQL> select resource_name, resource_type, limit
from dba_profiles
where profile = ‘sam_user’;
To check the setting for the initialization parameter resource_limits,
We will query a system table, as shown below:
SQL> select name, value
from v_$parameter
where name = ‘resource limit’;
This example shows that the resource limiting is not turned on.
Auditing is used to track what user changed a piece of data and when the data was changed. Auditing is important to use in a multi user environment.
To enable or disable auditing you must first set the audit_trail parameter in the init.ora file. This parameter has 3 possible values:
NONE – Auditing is turned off. This is the default.
DB – "Auditing is logged to the SYS.AUD$ table within the database."
OS – "Auditing is logged to an operating system file. This is not possible on Personal Oracle8 running Windows 95." (Fieldhouse)
If the audit_trail parameter is set to DB, then it is a good idea to store the audit table in a separate tablespace because it can get very large.
To enable auditing:
To turn auditing off:
A user must have the AUDIT_ANY privilege to use audit commands.
There are three types of auditing:
Access Auditing
You can see how many successful and unsuccessful log in attempts a user has made. If you choose to set the audit_trail parameter to DB, then the auditing data is stored in the SYS.AUD$ table, which is in the SYS schema.
To view the SYS.AUD$ table:
SQL> desc sys.aud$
To begin auditing sessions:
SQL> audit session;
Audit succeeded.
Log in to the database as Sam, Sally, and System.
SQL> connect
Enter user-name: sam
Enter password: ***
Connected.
SQL> connect
Enter user-name: sally
Enter password: ****
Connected.
SQL> connect
Enter user-name: system
Enter password: *******
Connected.
To query the sys.aud$ table for auditing information:
SQL> connect
Enter user-name: system
Enter password: *******
Connected.
SQL> select userid,
to_char(timestamp#, ‘DD/MM/YY HH:MI:SS’) time_on,
to_char(logoff$time, ‘DD/MM/YY HH:MI:SS’) time_off
from sys.aud$;
This table will show you all successful and unsuccessful log in attempts to the database.
Object Auditing
You can audit any changes made to a table, such as inserts, updates, and deletes, by using the AUDIT INSERT, UPDATE, DELETE command. To audit all actions performed on an object, use the AUDIT ALL command.
Example of auditing changes made to a table:
Enter user-name: system
Enter password: *******
Connected.
SQL> audit insert, update, delete on sam.coach;
Audit succeeded.
SQL> connect
Enter user-name: sam
Enter password: ***
Connected.
SQL> insert into player
values (15, ‘Sara’, ‘12/01/99’, 1, 01);
1 row created.
SQL> connect
Enter user-name: system
Enter password: *******
Connected.
SQL> select username, obj_name, owner
From dba_audit_object;
USERNAME OBJ_NAME OWNER
SAM COACH SAM
Database Auditing
You can audit "a set of actions" (Fieldhouse). For example, you can audit the ROLE command, which would audit the following commands:
CREATE ROLE, ALTER ROLE, SET ROLE, DROP ROLE
This would show you what use has done something to ROLES.
Return to the top
You should perform regular backups of your data. Backups are essential to recover your data if the database crashes or becomes corrupted. There are two ways to backup your data: the Backup Manager and the export utility.
Export utility
"Export is a utility that extracts data and object definitions from your database." (Fieldhouse) You can then import (copy) the data and object definitions to another database. The export utility only should be used with the import utility. Using the export utility you can decide to export the entire database or just certain parts of the database. There are two ways to use the export utility: through the Navigator or from the DOS command line.
The Navigator
To export data from your database:
After you have clicked Save, Oracle "initiates a DOS session in the background that exports all of your data to the specified file." (Fieldhouse)
Using the Navigator your entire database is automatically exported, you do not have a choice which data to export. Once Oracle is finished exporting your data, it will ask you if you want to view the log file. It is a good to view the log file to check whether the export was successful or not.
DOS command line
This method allows you to specify which data you want to export. For example, you can choose to export:
There are three modes in which you can export data from your database:
To export data from your database using the full database mode:
To get help at any time, use the command EXP80 help = y
EXP80 system/manager FILE=fulldb.dmp FULL=Y
This command would export the entire database "to a file called fulldb.dmp in the current directory." (Fieldhouse)
There are several parameters that can be used following the EXP80 command. I have listed a few important ones below. Additional information about the export utility commands can be found in Personal Oracle8 Explorer, written by Richard Fieldhouse.
Common parameters:
log – You can set the log parameter to log the output of the export utility. Use the log parameter with the file name and directory to log the output to.
owner – When you want to export the data in user mode, use the owner parameter. "This parameter can be supplied as a comma-separated list if more than one user is to be exported." (Fieldhouse)
tables – When you want to export specific tables from the database, use the tables parameter. "This parameter can be followed by a list of tables in parentheses and separated by commas." (Fieldhouse)
Return to the top
A recovery is performed to recover your data after your database has crashed.
There are two ways to perform recovery: through the Recovery Manager or the import utility.
Import utility
The import utility uses a previously created backup file made by the export utility. Using this method, you can specify if you want to import the entire database or just parts of it. There are two methods available when performing export or import: The Navigator or the DOS command line.
The Navigator
To export data from your database:
After you have clicked Open, Oracle "initiates a DOS session in the background, importing all of your data to the database." (Fieldhouse)
When using the Navigator, you do not get choice of what data to import. After the import has finished, you will prompted to view the log file. It is a good idea to view the log file, to check whether the import was successful or not.
DOS command line
This method allows you to specify which data you want to export. For example, you can choose to export:
There are three modes in which you can import data into your database:
3. Full Database mode: "Imports all of the database information for all users. This also imports all of the system definitions, including tablespaces, which were exported from the database using the export utility." (Fieldhouse)
To import data from your database using the full database mode:
To get help at any time, use the command EXP80 help = y
IMP80 system/manager FILE=fulldb.dmp FULL=Y
This command would import the entire database to your local database.
There are several parameters that can be used following the IMP80 command. I have listed a few important ones below. For additional information about the import utility commands refer to Richard Fieldhouse’s Personal Oracle8 Explorer.
Explanations of a few im