0% found this document useful (0 votes)
8 views5 pages

Lab Report DBA

Lab report Chat file

Uploaded by

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

Lab Report DBA

Lab report Chat file

Uploaded by

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

### Lab Report: Oracle Database Administration

#### Lab 1: Creation and Manipulation of Tablespaces

**Q1.1**: How can you view the name and number of tablespaces in the current database?

**Answer**:
```sql
-- Login with sys as sysdba and execute the following query
SELECT * FROM V$TABLESPACE;
```

**Q1.2**: How do you create a new tablespace named `demo2`?

**Answer**:
```sql
-- Create a new tablespace with an initial size of 5MB and autoextend enabled
CREATE TABLESPACE demo2
DATAFILE 'C:\RMAN\DEMO\DEMO.dbf' SIZE 5M AUTOEXTEND ON;
```

**Q1.3**: How can you add a new datafile to an existing tablespace `demo`?

**Answer**:
```sql
-- Add a new datafile of 15MB to the existing tablespace demo
ALTER TABLESPACE demo
ADD DATAFILE 'c:\rman\demo\datafile.dbf' SIZE 15M AUTOEXTEND ON;
```

**Q1.4**: Describe the steps to resize an existing tablespace datafile.

**Answer**:
```sql
-- Resize the datafile to 10MB
ALTER DATABASE DATAFILE 'c:\rman\demo\datafile.dbf' RESIZE 10M;
```

**Q1.5**: How do you delete the tablespace `demo`?

**Answer**:
```sql
-- Drop the tablespace demo
DROP TABLESPACE demo;
```

#### Lab 2: User Management

**Q2.1**: How do you create a new user `BIT1` with the password `password1`?
**Answer**:
```sql
-- Create a new user BIT1 with the specified password
CREATE USER BIT1 IDENTIFIED BY password1;
```

**Q2.2**: How can you grant `connect` and `resource` privileges to the user `demo`?

**Answer**:
```sql
-- Grant the connect and resource privileges to the user demo
GRANT connect, resource TO demo;
```

**Q2.3**: How do you grant `SELECT` access to the `employees` table in the `HR` schema for the
user `demo`?

**Answer**:
```sql
-- Grant select access on HR.EMPLOYEES to the user demo
GRANT SELECT ON hr.employees TO demo;
```

**Q2.4**: How do you revoke the `SELECT` privilege on the `employees` table from the user
`demo`?

**Answer**:
```sql
-- Revoke select access on HR.EMPLOYEES from the user demo
REVOKE SELECT ON hr.employees FROM demo;
```

**Q2.5**: How do you delete the user `demo` and all its associated objects?

**Answer**:
```sql
-- Drop the user demo along with all its objects
DROP USER demo CASCADE;
```

#### Lab 3: Logical Backup and Restore

**Q3.1**: Describe the steps to create an Oracle logical backup using `expdp`.

**Answer**:
```sql
-- Create a directory for the backup
CREATE DIRECTORY demo AS 'c:\test';

-- Use Data Pump export utility to create the backup


expdp hr/hr DIRECTORY=demo TABLES=jobs DUMPFILE=demo.dmp LOGFILE=demo.log;
```
**Q3.2**: How can you restore the database from the logical backup using `impdp`?

**Answer**:
```sql
-- Use Data Pump import utility to restore the backup
impdp hr/hr DIRECTORY=demo DUMPFILE=demo.dmp LOGFILE=impdemo.log
SQLFILE=impdp.log;
```

#### Lab 4: Physical Backup using RMAN

**Q4.1**: What steps are required to put the database in ARCHIVELOG mode and perform a
backup using RMAN?

**Answer**:
```sql
-- Check the current log mode
SELECT log_mode FROM v$database;

-- If the database is in NOARCHIVELOG mode, shut it down


SHUTDOWN IMMEDIATE;

-- Start the database in mount mode


STARTUP MOUNT;

-- Change the database to ARCHIVELOG mode


ALTER DATABASE ARCHIVELOG;

-- Open the database


ALTER DATABASE OPEN;

-- From a new command window, run RMAN and perform the backup
rman target /
RMAN> BACKUP AS BACKUPSET DATABASE;
```

#### Lab 5: Database Instance Management

**Q5.1**: How do you check the SGA parameters?

**Answer**:
```sql
-- Show the current SGA target parameter
SHOW PARAMETER sga_target;

-- Show various memory parameters


SHOW PARAMETER memory;
```

**Q5.2**: Describe the steps to start and stop the Oracle database instance.
**Answer**:
```sql
-- Start the Oracle instance
sqlplus
-- Login as sysdba
CONNECT sys as sysdba

-- Start the database


STARTUP;

-- Check the Oracle version


SELECT * FROM v$version;

-- To shut down the database normally


SHUTDOWN;

-- To shut down the database immediately


SHUTDOWN IMMEDIATE;
```

#### Lab 6: Tablespace Management

**Q6.1**: How do you take a tablespace offline?

**Answer**:
```sql
-- Take the tablespace demo offline
ALTER TABLESPACE demo OFFLINE;
```

**Q6.2**: How can you bring a tablespace back online?

**Answer**:
```sql
-- Bring the tablespace demo back online
ALTER TABLESPACE demo ONLINE;
```

**Q6.3**: How do you reclaim free space in a tablespace?

**Answer**:
```sql
-- Coalesce free space in the tablespace demo
ALTER TABLESPACE demo COALESCE;
```

#### Lab 7: Index Management

**Q7.1**: How do you create an index on the `LastName` column of the `employees` table?

**Answer**:
```sql
-- Create an index on the LastName column
CREATE INDEX idx_lastname ON employees (LastName);
```

**Q7.2**: How can you rebuild an index?

**Answer**:
```sql
-- Rebuild the index idx_lastname
ALTER INDEX idx_lastname REBUILD;
```

**Q7.3**: How do you drop an index?

**Answer**:
```sql
-- Drop the index idx_lastname
DROP INDEX idx_lastname;
```

#### Lab 8: Performance Monitoring

**Q8.1**: How do you view the current active sessions in the database?

**Answer**:
```sql
-- View current active sessions
SELECT * FROM v$session WHERE status = 'ACTIVE';
```

**Q8.2**: How can you check the current database locks?

**Answer**:
```sql
-- Check current database locks
SELECT * FROM v$lock;
```

**Q8.3**: How do you identify the most resource-intensive queries?

**Answer**:
```sql
-- Identify resource-intensive queries
SELECT sql_text, disk_reads, executions
FROM v$sql
ORDER BY disk_reads DESC;
```

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy