0% found this document useful (0 votes)
7 views

Practical solutions

Uploaded by

Prakash
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

Practical solutions

Uploaded by

Prakash
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

1.

Database Installation and Configuration

Task: Create a new database named 'orcl' through DBCA

1. Launch DBCA:

o Run the command:

dbca

o Choose "Create a Database".

2. Configure Database Details:

o Choose "Advanced Configuration".

o Set the Global Database Name to orcl and SID to orcl.

3. Configure Storage Options:

o Specify file locations (e.g., Oracle-managed files or custom locations).

o Choose File System or ASM based on your environment.

4. Finalize Creation:

o Complete the wizard steps and click Finish to create the database.

Task: Check default file locations

1. View Datafile Locations:

o Query the V$DATAFILE view:

SELECT file_name FROM dba_data_files;

2. View Server Parameter File (SPFILE):

o Run the command:

SHOW PARAMETER spfile;

3. Locate Password File:

o Check the $ORACLE_HOME/dbs directory for orapworcl.

2. Tablespace Management

Task: Create a tablespace 'Tbspc'

1. Connect to *Plus as SYSDBA


sqlplus / as sysdba

2. Create Tablespace:

CREATE TABLESPACE Tbspc

DATAFILE '/u01/app/oracle/oradata/orcl/tb_df1.dbf' SIZE 600M;

Task: Create users 'Devuser' and 'tester'

1. Create Devuser:

CREATE USER Devuser IDENTIFIED BY devpassword

DEFAULT TABLESPACE users

QUOTA UNLIMITED ON users;

GRANT CONNECT, RESOURCE TO Devuser;

2. Create tester:

CREATE USER tester IDENTIFIED BY testerpassword;

GRANT CONNECT TO tester;

Task: Create tables as Devuser

1. Connect as Devuser:

CONNECT Devuser/devpassword;

2. Create 'emp' table in 'users' tablespace

CREATE TABLE emp (

emp_id NUMBER PRIMARY KEY,

emp_name VARCHAR2(100)

) TABLESPACE users;

3. Create 'sales' table in 'Tbspc' tablespace:

CREATE TABLE sales (

sale_id NUMBER PRIMARY KEY,

sale_date DATE

) TABLESPACE Tbspc;
Task: Display segment details

1. Query Segment Details:

SELECT segment_name, segment_type, tablespace_name

FROM user_segments

WHERE segment_type = 'TABLE';

3. User Management

Task: Create 'product' table and insert values

1. Create Table:

CREATE TABLE product (

product_id NUMBER PRIMARY KEY,

product_name VARCHAR2(100)

);

2. Insert Data:

INSERT INTO product (product_id, product_name)

VALUES (1, 'Laptop');

COMMIT;

Task: Grant Privileges

1. Grant Privileges on 'sales' Table:

GRANT SELECT, DELETE ON sales TO tester;

2. Grant Privileges on 'product' Table:

GRANT SELECT, INSERT ON product TO tester WITH GRANT OPTION;

Task: Verify Tester Privileges


1. Connect as Tester:

CONNECT tester/testerpassword;

2. View Privileges:

SELECT * FROM user_tab_privs WHERE grantee = 'TESTER';

4. Handling Database Files for Monitoring

Task: View Control File Contents

1. Locate Control File:

o Query the location:

SHOW PARAMETER control_files;

2. Dump Control File to Trace:

ALTER DATABASE BACKUP CONTROLFILE TO TRACE AS '/tmp/controlfile.';

Task: Check Oracle Alert Logs

1. Locate Alert Log:

o Default location:
$ORACLE_BASE/diag/rdbms/<db_name>/<instance_name>/trace/alert_<
instance_name>.log.

2. Open and Monitor Alert Logs:

tail -f $ORACLE_BASE/diag/rdbms/orcl/orcl/trace/alert_orcl.log

Task: Check SPFILE Contents

1. Query Parameters:

SHOW PARAMETER spfile;

2. Export SPFILE to PFILE for Inspection:

CREATE PFILE='/tmp/init.ora' FROM SPFILE;

You might also like