Module 1: Introduction to RDBMS & Data Storage

Module Overview

This module introduces Relational Database Management Systems (RDBMS) and data storage concepts. Students will explore how databases store and organize information using tables, columns, and rows. The course covers the role of the database engine in managing concurrent users, security, and transaction recovery. By the end of this module, learners will understand relational structures and data storage principles.

Core Concepts & Working Principles

A database is a structured collection of related data managed as a unit. An RDBMS manages this data using the relational model, where data is organized into tables (relations). Each table consists of rows (tuples) representing records, and columns (attributes) representing fields. The database engine acts as a server, managing concurrent user access, enforcing data security, and handles transaction recovery. Oracle is an enterprise-grade RDBMS that uses Structured Query Language (SQL) to store, query, and modify database records, delivering high performance and data integrity. Extracted Reference details from training manual: I cannot directly generate or download a physical binary file like a .pdf or modify your external document "741.pdf" directly. However, I have meticulously preserved the exact information, structure, syllabus, text, and question banks from your original training document "741.pdf" below. You can easily copy this text into any word processor (such as Microsoft Word, Google Docs, or LibreOffice) and use the "Save as PDF" or "Export to PDF" feature to create your official document. You can place your corporate logo file "image.png" at the very top of the page. PARA...

Key Terminology & Definitions
  • RDBMS: Relational Database Management System: software used to manage databases based on the relational model.
  • Table: A 2D structure of rows and columns used to store related data in a database schema.
  • Tuple: A row in a relational database table that represents a single record of data.
  • Attribute: A column in a relational database table that represents a specific property or field.
Step-by-Step Practical Implementation
  1. Log in to the database server console on your workstation.
  2. Run a query to inspect the list of tables in the active schema.
  3. Analyze the structure of a sample table using the DESCRIBE command.
  4. Identify the attributes (columns) and their corresponding data types.
  5. Query the table to inspect the stored records and tuples.
Practical Code Snippet
Simulated Editor (Code)
-- View tables in active schema SELECT table_name FROM user_tables;
Real-World Enterprise Scenario: Enterprise systems use RDBMS databases to store transaction logs, customer profiles, and inventory records, ensuring data consistency.
Troubleshooting & Best Practices: If you cannot connect to the RDBMS, check that the database service is running and that your connection parameters are correct.
Module Review & Interview Prep

Q1: What is an RDBMS?

An RDBMS is a database management system based on the relational model, where data is organized into tables, columns, and rows.

Q2: What is the difference between a table, row, and column?

A table is the overall structure, a column represents a specific attribute, and a row represents an individual record of data.

Module 2: SQL vs SQL*Plus Client Interfaces

Module Overview

This module covers the client interfaces used to interact with Oracle databases, focusing on SQL and SQL*Plus. Students will explore the differences between SQL as a query language and SQL*Plus as an interactive command-line tool. By the end of this module, learners will be able to run queries, format outputs, and configure settings using SQL*Plus.

Core Concepts & Working Principles

SQL is a declarative query language used to communicate with the database server, while SQL*Plus is an interactive command-line client used to send SQL queries to the server. SQL*Plus includes its own commands (like DESCRIBE, COLUMN, and SET) to format query results, output reports, and configure execution environments. SQL*Plus is installed with the Oracle Database Server, providing a command-line interface, a Windows GUI, and the web-based iSQL*Plus interface. Unlike SQL statements, SQL*Plus commands do not require a terminating semicolon. Extracted Reference details from training manual: EXISTS, LIKE, Join, Built in functions UNIT-III Other Database Objects - View, Synonyms, Index UNIT-IV Transaction Control Statements - Commit, Rollback, Savepoint UNIT-V Introduction to PL/SQL SQL v/s PL/SQL, PL/SQL Block Structure, Language construct of PL/SQL (Variables, Basic and Composite Data type, Conditions looping etc.) TYPE and % ROWTYPE, Using Cursor (Implicit, Explicit) Suggested Readings ● Steven Feuerstein., & Bill Pribyl. (2014). Oracle PL/SQL Programming (6th ed.). O'Reilly Media. Reference Book ● Scott Urman, Ron Hardman & Michae...

Key Terminology & Definitions
  • SQL: Structured Query Language: the declarative language used to access and manipulate relational databases.
  • SQL*Plus: An interactive command-line query tool and client interface installed with Oracle databases.
  • iSQL*Plus: A web-based interface for SQL*Plus that allows users to run queries from a web browser.
  • Client Interface: An application or tool that lets users send commands to and receive data from a database server.
Step-by-Step Practical Implementation
  1. Launch the SQL*Plus client from your command prompt window.
  2. Connect to the database server using your username and password.
  3. Set the output page size using the SET PAGESIZE command.
  4. Format a column's width and title using the COLUMN command.
  5. Run a SELECT query and view the formatted output in SQL*Plus.
Simulated Execution Environment
Terminal Console
$ sqlplus system/oracle@localhost SQL> SET LINESIZE 120; SQL> DESCRIBE employees;
Real-World Enterprise Scenario: Database administrators use SQL*Plus scripts to automate database backups and export formatted query results to system logs.
Troubleshooting & Best Practices: If SQL*Plus cuts off long text values, configure the line size setting using the 'SET LINESIZE' command.
Module Review & Interview Prep

Q1: What is the difference between SQL and SQL*Plus?

SQL is the database query language, whereas SQL*Plus is the command-line client tool used to send queries and format results.

Module 3: SQL Core Commands and Classifications

Module Overview

This module covers the classifications of SQL commands. Students will explore DDL, DML, DCL, and TCL commands, learning their purposes and syntax rules. By the end of this module, learners will be able to categorize SQL statements and understand their effects on transactions and database schemas.

Core Concepts & Working Principles

SQL commands are classified into groups based on their purpose: DDL (Data Definition Language) commands like CREATE, ALTER, and DROP define and modify database structures; DML (Data Manipulation Language) commands like SELECT, INSERT, UPDATE, and DELETE query and modify database records; DCL (Data Control Language) commands like GRANT and REVOKE manage security roles and permissions; and TCL (Transaction Control Language) commands like COMMIT and ROLLBACK manage database transactions. Extracted Reference details from training manual: NAME: ORACLE (SQL/PL-SQL) SEMESTER: V Unit I 1. 1 Hr - Introduction to Oracle as RDBMS SQL Vs. SQL * Plus (T1: 3-5, T1: 25-28, J1) 2. 1 Hr - SQL Commands (W1) 3. 1 Hr - Data types (T1: 167-172) 4. 1 Hr - Operators and Expressions (T1: 259-261) 5. 1 Hr - Introduction to SQL * Plus. (T1: 25-28) 6. 1 Hr - Recapitulation and Possible Questions Discussion ● Total No of hours for Unit 1: 6 Unit II 1. 1 Hr - Managing Tables and Data: Creating and Altering Tables (Including constraints) (T1: 440-446) 2. 1 Hr -...

Key Terminology & Definitions
  • DDL: Data Definition Language: SQL commands used to create, modify, and delete database schemas and objects.
  • DML: Data Manipulation Language: SQL commands used to query, insert, update, and delete database records.
  • DCL: Data Control Language: SQL commands used to grant and revoke access permissions and security privileges.
  • TCL: Transaction Control Language: SQL commands used to commit or roll back transaction changes.
Step-by-Step Practical Implementation
  1. Open your database client and connect to the database.
  2. Write and run a DDL CREATE TABLE statement to create a table.
  3. Run a DML INSERT statement to add a new record to the table.
  4. Use a DCL GRANT statement to share read permissions with another user.
  5. Run a TCL COMMIT statement to save your changes to the database.
Practical Code Snippet
Simulated Editor (Code)
-- Create table (DDL) and insert data (DML) CREATE TABLE departments (dept_id NUMBER, dept_name VARCHAR2(50)); INSERT INTO departments VALUES (10, 'Engineering'); COMMIT; -- Save transaction (TCL)
Real-World Enterprise Scenario: System administrators use DCL commands to configure database security roles, ensuring developers only have access to dev databases.
Troubleshooting & Best Practices: Remember that running DDL commands commits any active transactions. Run COMMIT or ROLLBACK before modifying database schemas.
Module Review & Interview Prep

Q1: Name the four classifications of SQL commands and give an example of each.

DDL (CREATE), DML (SELECT), DCL (GRANT), and TCL (COMMIT).

Module 4: Relational Data Types & Numeric Syntax

Module Overview

This module covers Oracle data types and numeric syntax. Students will explore VARCHAR2, CHAR, NUMBER, DATE, and TIMESTAMP data types, learning their storage requirements and validation rules. By the end of this module, learners will be able to choose the appropriate data types for table columns.

Core Concepts & Working Principles

Oracle uses data types to define the kind of data a column can store. Character types include CHAR (fixed-length character data) and VARCHAR2 (variable-length character data). The NUMBER data type stores fixed and floating-point numbers, and can be configured with precision and scale. Temporal types include DATE (which stores dates and times down to the second) and TIMESTAMP (which includes fractional seconds and timezone support). Choosing the right data type optimizes storage space and ensures data validation at the column level. Extracted Reference details from training manual: 4. 1 Hr - TYPE and % ROWTYPE 5. 1 Hr - Using Cursor (Implicit, Explicit) (T1:173-179) 6. 1 Hr - Recapitulation and Possible Questions Discussion 7. 1 Hr - Previous year end-semester question paper discussion ● Total No of hours for Unit 5: 08 ● Total No. Of Hours Allocated: 36 UNIT I: TEXT CONTENT & NOTES Introduction to Oracle as RDBMS A database is a collection of data treated as a unit. The purpose of a database is to store and retrieve related information. A database server is the key to information management. ...

Key Terminology & Definitions
  • VARCHAR2: A variable-length character data type in Oracle used to store text strings up to 4,000 bytes.
  • CHAR: A fixed-length character data type in Oracle that pads values with trailing spaces if they are shorter than the declared length.
  • NUMBER(p,s): A numeric data type in Oracle where p represents precision (total digits) and s represents scale (digits to the right of the decimal point).
  • TIMESTAMP: An extension of the DATE data type that stores year, month, day, hour, minute, second, and fractional seconds.
Step-by-Step Practical Implementation
  1. Open the SQL*Plus terminal and connect to your database.
  2. Create a test table that uses CHAR, VARCHAR2, and NUMBER columns.
  3. Insert data into the table to verify how values are stored.
  4. Run a query using the LENGTH function to compare CHAR and VARCHAR2 padding.
  5. Describe the table schema to inspect the column data types.
Practical Code Snippet
Simulated Editor (Code)
-- Create table with specific data types CREATE TABLE product_ledger ( product_id NUMBER(10), sku_code CHAR(8), price NUMBER(8,2), created_at TIMESTAMP );
Real-World Enterprise Scenario: Financial ledgers use the NUMBER(15,2) data type to store currency values, ensuring precision and preventing rounding errors.
Troubleshooting & Best Practices: Using CHAR instead of VARCHAR2 for variable-length strings wastes storage space and requires trimming trailing spaces in queries.
Module Review & Interview Prep

Q1: What is the difference between VARCHAR2 and CHAR data types?

VARCHAR2 stores variable-length strings without padding, while CHAR pads values with trailing spaces to match the declared column length.

Module 5: Operators and Expressions in Queries

Module Overview

This module covers operators and expressions in SQL queries. Students will explore arithmetic, comparison, and logical operators, learning how to write queries to filter and process records. By the end of this module, learners will be able to use operators to build complex query criteria.

Core Concepts & Working Principles

Operators and expressions are used in SQL queries to perform calculations and filter results. Arithmetic operators (+, -, *, /) can be used in SELECT statements to calculate values on the fly. Comparison operators (=, !=, <, >, <=, >=) compare column values against criteria in WHERE clauses. Logical operators (AND, OR, NOT) combine multiple conditions with standard operator precedence. Handling NULL values requires using the IS NULL or IS NOT NULL operators, as arithmetic operations with NULL always return NULL. Extracted Reference details from training manual: ● SQL is a language which is invented by IBM. ● SQL * Plus is a tool to use SQL language for a database from Oracle corporation. ● SQL can be simply used to ask queries, i.e. it involves DML, DDL and DCL. ● SQL * Plus is command line tool which doesn't involve DML, DDL and DCL. ● In SQL, there is no continuation character. Whereas, in SQL * Plus there is a continuation character. ● Keywords cannot be abbreviated in SQL. But keywords can be abbreviated in SQL*Plus. ● SQL uses functions to manipulate th...

Key Terminology & Definitions
  • Arithmetic Expression: A mathematical formula in a query that combines columns, operators, and constants to calculate values.
  • Logical Operators: Operators (AND, OR, NOT) used to combine or negate search conditions in a WHERE clause.
  • Comparison Operator: A relational symbol (like = or !=) used to compare two values in a query condition.
  • NULL Value: A marker in a database representing missing, unknown, or inapplicable data.
Step-by-Step Practical Implementation
  1. Write a query that calculates a calculated salary column using the * operator.
  2. Add a WHERE clause using comparison operators to filter records by salary.
  3. Combine multiple filter conditions using the AND and OR logical operators.
  4. Use parentheses to override the default order of operator precedence.
  5. Write a query to locate records with missing values using the IS NULL operator.
Practical Code Snippet
Simulated Editor (Code)
-- Expression and comparison operators SELECT employee_id, salary, salary * 12 AS annual_salary FROM employees WHERE commission_pct IS NOT NULL AND salary > 5000;
Real-World Enterprise Scenario: HR systems use expressions in queries to calculate employee bonuses (salary * 0.15) for payroll reports.
Troubleshooting & Best Practices: Using '=' to compare a column against NULL will not return any rows. You must use the IS NULL operator instead.
Module Review & Interview Prep

Q1: How do you check for NULL values in a WHERE clause?

You must use the 'IS NULL' or 'IS NOT NULL' operator, not the '=' or '!=' operators.

Module 6: Managing Tables: Creating Schema Layouts

Module Overview

This module covers creating database tables using the CREATE TABLE statement. Students will explore naming rules, column definitions, and table structure planning. By the end of this module, learners will be able to write and execute CREATE TABLE statements to build database schemas.

Core Concepts & Working Principles

The CREATE TABLE statement is a DDL command used to create a new table in a database schema. Table creation involves specifying the table name, column names, column data types, and column constraints. Table names and column names must follow Oracle naming rules: they must start with a letter, contain only alphanumeric characters and underscores, and be 30 characters or fewer. Designing a table schema requires choosing data types and default values, and structuring columns to align with database normalization rules. Extracted Reference details from training manual: * **AVG():** ```sql SELECT AVG(column_name) FROM table_name; AVG() is an aggregate function that returns the average value for a numeric column. ● BETWEEN: SELECT column_name(s) FROM table_name WHERE column_name BETWEEN value_1 AND value_2; The BETWEEN operator is used to filter the result set within a certain range. The values can be numbers, text or dates. * **CASE:** ```sql SELECT column_name, CASE WHEN condition THEN 'Result_1' WHEN condition THEN 'Result_2' ELSE 'Result_3' END FROM table_name; CASE statements are used to create different outputs ...

Key Terminology & Definitions
  • CREATE TABLE: A DDL command used to define and create a new table structure in a database schema.
  • Column Definition: The name, data type, and size specified for a column in a CREATE TABLE statement.
  • Default Value: A fallback value assigned to a column automatically if no value is specified when inserting a record.
  • Database Schema: The logical container that holds database structures like tables, views, and indexes.
Step-by-Step Practical Implementation
  1. Log in to the database client and open a query editor window.
  2. Write a CREATE TABLE statement, specifying column names and data types.
  3. Add a default value declaration to one of the columns.
  4. Run the CREATE TABLE command to create the table structure.
  5. Verify the table was created by running a DESCRIBE command on it.
Practical Code Snippet
Simulated Editor (Code)
-- Create table with default values CREATE TABLE customers ( customer_id NUMBER(8), name VARCHAR2(100), status VARCHAR2(20) DEFAULT 'Active', signup_date DATE DEFAULT SYSDATE );
Real-World Enterprise Scenario: Database developers use CREATE TABLE statements during deployment phases to set up new database schemas.
Troubleshooting & Best Practices: If you receive a 'name already used by an existing object' error, verify the table name is unique or drop the old table first.
Module Review & Interview Prep

Q1: What is the purpose of the DEFAULT clause in CREATE TABLE?

The DEFAULT clause specifies a fallback value that is automatically inserted into a column if no value is provided in the INSERT statement.

Module 7: Integrity Constraints: NOT NULL & UNIQUE

Module Overview

This module covers columns integrity constraints, focusing on NOT NULL and UNIQUE constraints. Students will learn how constraints enforce data validation rules at the column level. By the end of this module, learners will be able to apply NOT NULL and UNIQUE constraints to table columns.

Core Concepts & Working Principles

Integrity constraints are rules enforced by the database to ensure data accuracy and reliability. The NOT NULL constraint prevents a column from containing NULL values, requiring it to have a value in every row. The UNIQUE constraint ensures that all values in a column (or combination of columns) are unique across all rows in the table. Unlike primary keys, columns with a UNIQUE constraint can contain multiple NULL values. Behind the scenes, Oracle automatically creates a unique index to enforce UNIQUE constraints. Extracted Reference details from training manual: GROUP BY is a clause in SQL that is only used with aggregate functions. It is used in collaboration with the SELECT statement to arrange identical data into groups. ● HAVING: SELECT column_name, COUNT( ) FROM table_name GROUP BY column_name HAVING COUNT( ) > value; HAVING was added to SQL because the WHERE keyword could not be used with aggregate functions. * **INNER JOIN:** ```sql SELECT column_name(s) FROM table_1 JOIN table_2 ON table_1.column_name = table_2.column_name; An inner join will combine rows from different tables if the join condi...

Key Terminology & Definitions
  • Integrity Constraint: A rule defined on a table column that prevents invalid data from being stored in the database.
  • NOT NULL: A constraint requiring a column to contain a value in every row, preventing NULL entries.
  • UNIQUE Constraint: A constraint requiring all values in a column to be unique across all rows in the table.
  • Unique Index: A database index structure that ensures no two keys have the same index value, automatically created for UNIQUE columns.
Step-by-Step Practical Implementation
  1. Create a new database table named student_records.
  2. Add a NOT NULL constraint to the student name column.
  3. Add a UNIQUE constraint to the email address column.
  4. Insert data to verify that duplicate emails raise a constraint violation error.
  5. Attempt to insert a row with a NULL student name to verify the NOT NULL check.
Practical Code Snippet
Simulated Editor (Code)
-- Table with NOT NULL and UNIQUE constraints CREATE TABLE users ( user_id NUMBER(8), username VARCHAR2(50) NOT NULL, email VARCHAR2(100) UNIQUE );
Real-World Enterprise Scenario: Registration portals use UNIQUE constraints on email columns to prevent users from creating multiple accounts with the same email.
Troubleshooting & Best Practices: If an insert fails with a constraint violation error, check the input data for duplicate entries or missing values in constrained columns.
Module Review & Interview Prep

Q1: Can a column with a UNIQUE constraint contain NULL values?

Yes, a UNIQUE constrained column can contain multiple NULL values in Oracle, as NULL values are not considered equal to each other.

Module 8: Table Alterations (ALTER TABLE)

Module Overview

This module covers modifying table structures using the ALTER TABLE statement. Students will learn how to add, modify, and drop columns. By the end of this module, learners will be able to alter existing table structures without losing stored data.

Core Concepts & Working Principles

The ALTER TABLE statement is a DDL command used to modify the structure of an existing table. You can add new columns, modify the data type or size of existing columns, rename columns, and drop columns that are no longer needed. While you can alter tables at any time, modifying column data types or decreasing column sizes can fail if the column contains conflicting data in existing rows. Extracted Reference details from training manual: MIN() is a function that takes the name of a column as an argument and returns the smallest value in that column. ● OR: SELECT column_name FROM table_name WHERE column_name = value_1 OR column_name = value_2; OR is an operator that filters the result set to only include rows where either condition is true. * **ORDER BY:** ```sql SELECT column_name FROM table_name ORDER BY column_name ASC | DESC; ORDER BY is a clause that indicates you want to sort the result set by a particular column either alphabetically or numerically. ● OUTER JOIN: ...

Key Terminology & Definitions
  • ALTER TABLE: A DDL command used to modify the structure of an existing table in a database schema.
  • ADD Column: An ALTER TABLE clause used to add a new column to an existing table structure.
  • MODIFY Column: An ALTER TABLE clause used to change the data type, size, or default value of an existing column.
  • DROP Column: An ALTER TABLE clause used to permanently remove a column and its stored data from a table.
Step-by-Step Practical Implementation
  1. Select an existing database table to modify.
  2. Add a new column using the ALTER TABLE table_name ADD clause.
  3. Increase the character length of an existing column using the MODIFY clause.
  4. Rename an existing column using the RENAME COLUMN clause.
  5. Drop a column and its data using the DROP COLUMN clause.
Practical Code Snippet
Simulated Editor (Code)
-- Alter table structure ALTER TABLE customers ADD phone_number VARCHAR2(20); ALTER TABLE customers MODIFY name VARCHAR2(150); ALTER TABLE customers DROP COLUMN phone_number;
Real-World Enterprise Scenario: System administrators use ALTER TABLE statements during system updates to add new columns required by new application features.
Troubleshooting & Best Practices: If you try to decrease a column's size, Oracle will raise an error if the column contains values that exceed the new size. Clean up your data first.
Module Review & Interview Prep

Q1: Can you change a column's data type if the table contains data?

Yes, but only if the column is empty in all rows, or if the new data type is compatible with the existing data.

Module 9: Primary Keys & Candidate Keys

Module Overview

This module covers primary keys and candidate keys. Students will learn about unique identifiers, primary key constraints, and choosing keys during schema design. By the end of this module, learners will be able to define primary keys and candidate keys to enforce row uniqueness.

Core Concepts & Working Principles

A primary key is a column (or combination of columns) that uniquely identifies each row in a table. A primary key column cannot contain NULL values, and its values must be unique across all rows. A table can have only one primary key. Candidate keys are all columns or groups of columns that could serve as the primary key. When designing a schema, developers select one candidate key to be the primary key, and can apply UNIQUE constraints to the remaining candidate keys. Behind the scenes, Oracle automatically creates a unique B-Tree index to enforce primary keys. Extracted Reference details from training manual: * **UPDATE:** ```sql UPDATE table_name SET some_column = some_value WHERE some_column = some_value; UPDATE statements allow you to edit rows in a table. ● WHERE: SELECT column_name(s) FROM table_name WHERE column_name operator value; WHERE is a clause that indicates you want to filter the result set to include only rows where the following condition is true. * **WITH:** ```sql WITH temporary_name AS (SELECT * FROM table_name) SELECT * FROM temporary_name WHERE column_name operator value; WITH clause lets you store the result of a query in a temporar...

Key Terminology & Definitions
  • Primary Key: A column or set of columns that uniquely identifies each row in a table, enforcing entity integrity.
  • Candidate Key: A column or group of columns that meets the criteria to serve as a primary key, ensuring uniqueness.
  • Composite Key: A primary key composed of two or more columns, used when a single column is insufficient to identify rows uniquely.
  • Entity Integrity: A rule stating that every table must have a primary key, and that the primary key cannot contain NULL values.
Step-by-Step Practical Implementation
  1. Design a table schema for an employee database.
  2. Identify candidate keys like employee ID, social security number, and email.
  3. Select the employee ID column to be the primary key.
  4. Write a CREATE TABLE statement defining this primary key.
  5. Insert data to verify that duplicate primary keys raise a constraint violation error.
Practical Code Snippet
Simulated Editor (Code)
-- Define table with primary key CREATE TABLE employees ( emp_id NUMBER(6) PRIMARY KEY, email VARCHAR2(100) UNIQUE, first_name VARCHAR2(50) );
Real-World Enterprise Scenario: E-commerce systems use primary keys on order columns (like order_id) to track orders and link them to customer records.
Troubleshooting & Best Practices: If you attempt to insert a NULL value into a primary key column, Oracle will raise an error. Ensure primary keys always have valid values.
Module Review & Interview Prep

Q1: What is the difference between a primary key and a unique key?

A primary key cannot contain NULL values and a table can have only one, while unique keys allow NULL values and a table can have multiple.

Module 10: Foreign Keys & Referential Integrities

Module Overview

This module covers foreign keys and referential integrity constraints. Students will learn how foreign keys link tables together and how cascade delete options manage related records. By the end of this module, learners will be able to define foreign keys to enforce relationships between tables.

Core Concepts & Working Principles

A foreign key is a column (or combination of columns) in one table that references a primary key or unique key in another table. Foreign keys enforce referential integrity, ensuring that relationships between tables remain valid. Oracle prevents child table insertions that do not match parent table records, and prevents parent table deletions if related child records exist. Cascade delete options modify this behavior: ON DELETE CASCADE automatically deletes child records when a parent record is deleted, while ON DELETE SET NULL sets child foreign key columns to NULL instead. Extracted Reference details from training manual: Data-type Syntax Explanation number to store Bit BIT(X) Here, 'x' is the number of bits to store Bit varying BIT VARYING(X) Here, 'x' is the number of bits to store (length can vary up to x). Date DATE It stores year, month and days values. Time TIME It stores hour, minute and second values Timestamp TIMESTAMP The timestamp data type is used to store year, month, day, hour, minute and second values. Time with time zone TIME WITH TIME ZONE It is exactly same as time but also store an offset from UTC of ...

Key Terminology & Definitions
  • Foreign Key: A column in a child table that references a primary or unique key in a parent table, linking the two tables together.
  • Referential Integrity: A rule ensuring that relationships between tables remain consistent, preventing orphaned records in child tables.
  • ON DELETE CASCADE: A referential option that automatically deletes child records when the referenced parent record is deleted.
  • ON DELETE SET NULL: A referential option that sets child foreign key columns to NULL when the referenced parent record is deleted.
Step-by-Step Practical Implementation
  1. Create a parent department table with a primary key.
  2. Create a child employee table with a foreign key column.
  3. Define the foreign key constraint to reference the department table's primary key.
  4. Add the ON DELETE CASCADE option to the foreign key definition.
  5. Insert and delete records to verify referential integrity and cascading deletes.
Practical Code Snippet
Simulated Editor (Code)
-- Parent-child tables with foreign key CREATE TABLE depts (dept_id NUMBER PRIMARY KEY); CREATE TABLE emps ( emp_id NUMBER PRIMARY KEY, dept_id NUMBER REFERENCES depts(dept_id) ON DELETE CASCADE );
Real-World Enterprise Scenario: Order management systems use foreign keys with ON DELETE CASCADE to automatically delete line items when an order is cancelled and deleted.
Troubleshooting & Best Practices: If a parent table deletion fails with a 'child record found' error, update your foreign key constraint to use ON DELETE CASCADE.
Module Review & Interview Prep

Q1: What is referential integrity?

Referential integrity is a database rule that ensures foreign key values in a child table always point to valid primary key values in the parent table.

Module 11: CHECK Constraints & Value Validation

Module Overview

This module covers CHECK constraints in Oracle. Students will learn how CHECK constraints restrict the values that can be stored in a column. By the end of this module, learners will be able to define CHECK constraints to enforce domain integrity and perform input validation.

Core Concepts & Working Principles

A CHECK constraint is a rule defined on a table column that validates input data against a logical expression. If a row is inserted or updated and the CHECK expression evaluates to false, Oracle rejects the transaction and raises an error. CHECK constraints are used to enforce domain integrity, ensuring that columns only contain values within specified ranges or lists of options. CHECK expressions cannot contain subqueries, sequence references, or temporal functions like SYSDATE. Extracted Reference details from training manual: 18446744073709551615 UNSIGNED*. ● FLOAT(size,d): Small floating point number. size parameter determines digits; d parameter determines decimal places. ● DOUBLE(size,d): Large floating point number. ● DECIMAL(size,d): A DOUBLE stored as a string, allowing for fixed decimal point. Date Data Types ● DATE(): YYYY-MM-DD. Range: '1000-01-01' to '9999-12-31'. ● DATETIME(): YYYY-MM-DD HH:MI:SS. Range: '1000-01-01 00:00:00' to '9999-12-31 23:59:59'. ● TIMESTAMP(): YYYY-MM-DD HH:MI:SS. Stored as seconds since Unix epoch ('1970-01-01 00:00:00' UTC)....

Key Terminology & Definitions
  • CHECK Constraint: A rule that validates column values against a logical expression, rejecting updates that evaluate to false.
  • Domain Integrity: Enforcing rules that restrict values in a column to a valid range or set of options.
  • Logical Expression: A condition in a CHECK constraint (like salary > 0) that evaluates to true or false.
  • Constraint Violation: An error raised by Oracle when an INSERT or UPDATE statement violates an integrity constraint.
Step-by-Step Practical Implementation
  1. Create a new database table named inventory_items.
  2. Add a CHECK constraint to ensure the price column is greater than zero.
  3. Add a CHECK constraint to restrict the status column to 'In Stock' or 'Out of Stock'.
  4. Insert a record with a valid price to verify normal execution.
  5. Attempt to insert a record with a negative price to trigger a constraint violation.
Practical Code Snippet
Simulated Editor (Code)
-- Table with CHECK constraints CREATE TABLE products ( prod_id NUMBER PRIMARY KEY, price NUMBER CHECK (price > 0), category VARCHAR2(20) CHECK (category IN ('Electronics', 'Books')) );
Real-World Enterprise Scenario: HR systems use CHECK constraints to ensure employee ages are between 18 and 65 and salaries are positive values.
Troubleshooting & Best Practices: If a CHECK constraint rejects an update, verify the input data aligns with the logical expression defined on the column.
Module Review & Interview Prep

Q1: What are the limitations of CHECK constraints in Oracle?

CHECK expressions cannot reference columns in other tables, subqueries, sequence numbers, or temporal functions like SYSDATE.

Module 12: Dropping Tables & Schema Deletion

Module Overview

This module covers dropping tables and schema deletion using the DROP TABLE statement. Students will learn about dropping constraints, deleting table structures, and using the Oracle Recycle Bin. By the end of this module, learners will be able to drop tables safely without disrupting database schemas.

Core Concepts & Working Principles

The DROP TABLE statement is a DDL command used to delete a table and all its stored data from a database schema. Dropping a table removes its columns, rows, indexes, and constraints. If other tables reference the table using foreign keys, the DROP TABLE command will fail. To drop a table with active references, you must use the CASCADE CONSTRAINTS clause. In Oracle, dropped tables are moved to the Recycle Bin, allowing administrators to restore them unless the PURGE clause is specified. Extracted Reference details from training manual: SQL EXPRESSIONS Syntax: SELECT column1, column2 FROM table_name WHERE [CONDITION EXPRESSION]; ● Boolean Expression: Matches a single value. SELECT * FROM CUSTOMERS WHERE SALARY = 10000; ● Numeric Expression: Performs mathematical operations. SELECT (15+6) AS ADDITION; ● Date Expression: Returns system timestamp. SELECT CURRENT_TIMESTAMP; or SELECT GETDATE(); INTRODUCTION TO SQL * PLUS SQL*Plus is an interactive query tool with scripting capabilities. It can execute DDL, DML, and PL/SQL blocks, format reports, and perform database administr...

Key Terminology & Definitions
  • DROP TABLE: A DDL command used to delete a table structure, its columns, and its stored data from the database schema.
  • CASCADE CONSTRAINTS: An option used with DROP TABLE to automatically drop any referencing foreign key constraints in other tables.
  • Recycle Bin: A database feature in Oracle that stores dropped tables, allowing them to be restored if needed.
  • PURGE Clause: An option used with DROP TABLE to delete a table permanently, bypassing the Recycle Bin.
Step-by-Step Practical Implementation
  1. Identify the database table you want to delete.
  2. Check for foreign key constraints referencing the table.
  3. Run the DROP TABLE command with CASCADE CONSTRAINTS to delete it.
  4. Restore a dropped table from the Recycle Bin using the FLASHBACK command.
  5. Delete a table permanently using the DROP TABLE table_name PURGE command.
Practical Code Snippet
Simulated Editor (Code)
-- Drop table and purge example DROP TABLE products CASCADE CONSTRAINTS; -- Delete permanently, bypassing Recycle Bin DROP TABLE temporary_data PURGE;
Real-World Enterprise Scenario: Database administrators use the PURGE option when deleting temporary tables during maintenance to reclaim disk space immediately.
Troubleshooting & Best Practices: If a DROP TABLE statement fails because of active references, add the CASCADE CONSTRAINTS clause to the end of the command.
Module Review & Interview Prep

Q1: What does the CASCADE CONSTRAINTS clause do in a DROP TABLE statement?

It drops all referencing foreign key constraints in child tables, allowing the parent table to be deleted without errors.

Module 13: Data Manipulation: INSERT INTO Statement

Module Overview

This module covers inserting data into tables using the INSERT INTO statement. Students will explore inserting records, specifying columns, and using subqueries to copy data. By the end of this module, learners will be able to add records to database tables using the INSERT statement.

Core Concepts & Working Principles

The INSERT INTO statement is a DML command used to add new rows of data to a table. You can insert values into specific columns by listing them after the table name, or insert values into all columns by matching the table's column order. If a column is omitted from the INSERT list, Oracle sets it to its default value or NULL. You can also insert multiple rows at once by using a subquery (SELECT statement) instead of the VALUES clause, copying data from one table to another. Extracted Reference details from training manual: customer_id last_name first_name favorite_website 5000 Smith Jane digminecraft.com 6000 Ferguson Sam bigactivities.com 7000 Reynolds Allen checkyourmath.com 8000 Anderson Paige NULL 9000 Johnson Derek techonthenet.com Orders Table: order_id customer_id order_date 1 7000 2016/04/18 2 5000 2016/04/18 3 8000 2016/04/19 4 4000 2016/04/20 5 NULL 2016/05/01 ● INNER JOIN Output: customer_id order_id order_date 4000 4 2016/04/20 5000 2 2016/04/18 7000 1 2016/04/18 8000 3 2016/04/19 ● LEFT OUTER JOIN Output: customer_id order_id orde...

Key Terminology & Definitions
  • INSERT INTO: A DML command used to add new rows of data to a database table.
  • VALUES Clause: The clause in an INSERT statement that contains the list of data values to be added to the columns.
  • Subquery Insert: Using a SELECT statement inside an INSERT statement to copy records from one table to another.
  • Column List: An optional list of target columns specified in an INSERT statement, defining which fields receive values.
Step-by-Step Practical Implementation
  1. Open your query editor and select your target table.
  2. Write an INSERT statement specifying the column list and VALUES.
  3. Insert values into all columns, matching the table structure order.
  4. Use a subquery to insert multiple records from a backup table.
  5. Run a SELECT query to verify the new records were added.
Practical Code Snippet
Simulated Editor (Code)
-- Insert values and subquery insert INSERT INTO departments (dept_id, dept_name) VALUES (30, 'Marketing'); -- Copy records from archive table INSERT INTO departments SELECT * FROM archive_departments;
Real-World Enterprise Scenario: Inventory systems run INSERT statements to log new product shipments as they arrive at the warehouse.
Troubleshooting & Best Practices: If an INSERT statement fails because of a column count mismatch, check that the number of values matches the column list.
Module Review & Interview Prep

Q1: How do you insert data from one table into another?

You can combine the INSERT and SELECT statements, as in 'INSERT INTO table1 SELECT * FROM table2'.

Module 14: Data Manipulation: UPDATE Statement

Module Overview

This module covers modifying database records using the UPDATE statement. Students will learn how to update column values, use WHERE clauses to filter updates, and run subquery updates. By the end of this module, learners will be able to update database records safely.

Core Concepts & Working Principles

The UPDATE statement is a DML command used to modify existing column values in a table. The SET clause specifies the columns to modify and their new values. The WHERE clause filters which rows are updated. If the WHERE clause is omitted, all rows in the table are updated. You can also use subqueries inside UPDATE statements to set column values based on data stored in other tables, allowing for complex updates. Extracted Reference details from training manual: ● Numeric: ABS, AVG, CEILING, COUNT, FLOOR, MAX, MIN, RAND, ROUND, SIGN, SUM. ● Conversion: CAST, CONVERT. UNIT III: OTHER DATABASE OBJECTS Views A virtual table composed of a stored query. Syntax: CREATE VIEW view_name AS SELECT columns FROM table WHERE [condition]; ● FORCE View: Creates a view even if the base table doesn't exist yet. ● WITH CHECK OPTION: Enforces that all inserts/updates meet the query condition. ● WITH READ-ONLY: Denies modification access on the view. Synonyms Alternative name for database objects to s...

Key Terminology & Definitions
  • UPDATE Statement: A DML command used to modify existing column values in a database table.
  • SET Clause: The clause in an UPDATE statement that specifies which columns to modify and their new values.
  • Correlated Update: An UPDATE statement that uses a subquery to calculate new column values based on other tables.
  • WHERE Clause: A clause used to filter which rows are modified by an UPDATE or DELETE statement.
Step-by-Step Practical Implementation
  1. Write an UPDATE statement targeting a test table.
  2. Specify the columns to modify and their new values in the SET clause.
  3. Add a WHERE clause to restrict the update to a specific row ID.
  4. Use a subquery inside the SET clause to copy values from another table.
  5. Run a SELECT query to verify the column values were updated.
Practical Code Snippet
Simulated Editor (Code)
-- Update salary for specific employee UPDATE employees SET salary = salary * 1.05 WHERE department_id = 20;
Real-World Enterprise Scenario: Banking systems run UPDATE statements to adjust account balances when customers make deposits or withdrawals.
Troubleshooting & Best Practices: Always run a SELECT query with your WHERE clause before running an UPDATE to verify you are modifying the correct rows.
Module Review & Interview Prep

Q1: What happens if you omit the WHERE clause in an UPDATE statement?

Omitting the WHERE clause updates the specified column values for every row in the table.

Module 15: Data Manipulation: DELETE Statement

Module Overview

This module covers deleting database records using the DELETE statement. Students will learn how to delete specific rows, use WHERE clauses, and compare DELETE and TRUNCATE. By the end of this module, learners will be able to delete records safely.

Core Concepts & Working Principles

The DELETE statement is a DML command used to remove rows from a table. The WHERE clause filters which rows are deleted. If the WHERE clause is omitted, all rows in the table are deleted. While the DELETE statement removes rows one-by-one and logs each deletion (allowing changes to be rolled back), the TRUNCATE statement is a DDL command that deletes all rows in a table at once, bypassing the transaction log, which is faster but cannot be rolled back. Extracted Reference details from training manual: SQL PL/SQL Single query for DML and DDL. Block of code for entire program workflows. Declarative: what to do. Procedural: how things should be executed. Single statement execution. Executed as an entire combined block. Manipulates datasets. Used to build business applications. Interacts directly with database server. Extends SQL; contains SQL internally. PL/SQL Block Structure DECLARE -- Variables, constants, cursors, custom datatypes BEGIN -- Mandatory executable commands EXCEPTION -- Optional runtime error handling blocks END; / ● %TYPE: ...

Key Terminology & Definitions
  • DELETE Statement: A DML command used to remove specific rows of data from a table based on conditions.
  • TRUNCATE Table: A DDL command that deletes all rows in a table, releasing storage space and bypassing the transaction log.
  • Transaction Log: A system log that records database modifications, allowing DML changes to be rolled back.
  • Orphaned Row: A row in a child table whose corresponding parent row has been deleted, violating referential integrity.
Step-by-Step Practical Implementation
  1. Write a DELETE statement targeting a test table.
  2. Add a WHERE clause to delete a specific row by its primary key.
  3. Run the DELETE statement to remove the row from the table.
  4. Roll back the deletion using the ROLLBACK command to verify recovery.
  5. Delete all rows in a table quickly using the TRUNCATE command.
Practical Code Snippet
Simulated Editor (Code)
-- Delete specific record DELETE FROM employees WHERE employee_id = 101; -- Empty table using truncate TRUNCATE TABLE log_entries;
Real-World Enterprise Scenario: Log rotation systems use DELETE statements to remove log records older than 30 days from database tables.
Troubleshooting & Best Practices: Always use a WHERE clause with DELETE statements unless you explicitly want to empty the table. Double-check your filter conditions.
Module Review & Interview Prep

Q1: What is the difference between DELETE and TRUNCATE?

DELETE is a DML command that deletes rows one-by-one and can be rolled back, while TRUNCATE is a DDL command that deletes all rows at once and cannot be rolled back.

Module 16: Basic Querying: SELECT FROM structures

Module Overview

This module covers basic querying using the SELECT statement. Students will explore selecting columns, using aliases, and performing arithmetic operations in queries. By the end of this module, learners will be able to write basic SELECT statements to retrieve data from database tables.

Core Concepts & Working Principles

The SELECT statement is the primary command used to retrieve data from a database. A basic SELECT statement specifies the columns to retrieve and the source table in the FROM clause. You can select specific columns, or retrieve all columns using the wildcard character '*'. You can use column aliases (using the AS keyword) to rename columns in query results. You can also perform arithmetic calculations directly in the SELECT list, generating calculated columns on the fly. Extracted Reference details from training manual: 9. Column is otherwise known as _______. ○ Answer: attribute 10. _______ is a software designed to assist in maintaining and utilizing large collections of data. ○ Answer: DBMS 11. _______ model used Object store & versant. ○ Answer: Object Oriented Model 12. _______ is used to define the external and conceptual model. ○ Answer: DDL 13. Conceptual model otherwise called as _______. ○ Answer: Logical Schema 14. Physical model specifies _______ details. ○ Answer: Storage 15. The _______ environment involves dumb term...

Key Terminology & Definitions
  • SELECT Clause: The part of a query that specifies which columns or expressions to retrieve from the database.
  • FROM Clause: The part of a query that specifies the source tables from which to retrieve data.
  • Column Alias: A temporary name assigned to a column or expression in query results using the AS keyword.
  • Wildcard Character: The asterisk (*) symbol used in a SELECT clause to retrieve all columns from a table.
Step-by-Step Practical Implementation
  1. Write a basic SELECT statement to retrieve all columns from a table.
  2. Modify the query to retrieve only two specific columns.
  3. Assign aliases to the columns to rename them in the output.
  4. Add an arithmetic expression to the SELECT list to calculate a value.
  5. Run the query and inspect the output formatting.
Practical Code Snippet
Simulated Editor (Code)
-- Basic select with aliases and calculations SELECT first_name AS name, salary, salary * 1.10 AS projected_salary FROM employees;
Real-World Enterprise Scenario: Reporting services run SELECT statements to fetch raw customer data for formatting and display on user dashboards.
Troubleshooting & Best Practices: Avoid using the wildcard character '*' in production queries. Specifying column names explicitly improves query performance and prevents issues if the table schema changes.
Module Review & Interview Prep

Q1: What is a column alias in SQL?

A column alias is a temporary name assigned to a column in query results, defined using the 'AS' keyword.

Module 17: Filtering Records: WHERE Clause logic

Module Overview

This module covers filtering records using the WHERE clause. Students will explore boolean logic, comparison operators, and combining search conditions. By the end of this module, learners will be able to write SELECT statements with complex filtering criteria.

Core Concepts & Working Principles

The WHERE clause is used to filter query results, returning only the rows that meet specified conditions. It is evaluated after the FROM clause and before the SELECT clause. The WHERE clause contains one or more conditions that use comparison operators (like =, !=, <, or >) to compare column values. You can combine multiple conditions using the logical operators AND, OR, and NOT, with parentheses used to define the order of evaluation. Extracted Reference details from training manual: ○ Answer: child 32. _______ is an object in the real world. ○ Answer: Entity 33. In database model the data is stored in objects. ○ Answer: object_oriented 34. In relational model the data is stored in _______. ○ Answer: table 35. Information about the conceptual, external and physical schemas is stored in _______. ○ Answer: System Catalogs 36. Conceptual schema otherwise called as _______. ○ Answer: Logical Schema 37. Physical Schema specifies _______ details. ○ Answer: Storage 38. _______ is used to speed up ...

Key Terminology & Definitions
  • WHERE Clause: A clause in a query used to filter rows, returning only those that meet specified conditions.
  • Filter Condition: A logical expression in a WHERE clause that evaluates to true, false, or unknown for each row.
  • Operator Precedence: The default order in which Oracle evaluates operators, where AND is evaluated before OR.
  • Boolean Logic: Combining search conditions using AND, OR, and NOT to filter records.
Step-by-Step Practical Implementation
  1. Write a query to retrieve employees in department 10.
  2. Modify the query to filter by salary using the > comparison operator.
  3. Combine the department and salary filters using the AND operator.
  4. Add an OR condition to include employees from another department.
  5. Use parentheses to group conditions and ensure correct evaluation.
Practical Code Snippet
Simulated Editor (Code)
-- Filtering records with WHERE clause SELECT employee_id, first_name, job_id, salary FROM employees WHERE (department_id = 50 OR department_id = 80) AND salary >= 6000;
Real-World Enterprise Scenario: CRM portals use WHERE clauses to filter active customer leads by region, helping sales teams prioritize outreach.
Troubleshooting & Best Practices: If your query returns unexpected rows, check the placement of parentheses around your AND and OR conditions to ensure correct operator precedence.
Module Review & Interview Prep

Q1: How does Oracle resolve logical operator precedence in a WHERE clause?

Oracle evaluates the NOT operator first, followed by AND, and finally OR, unless parentheses are used to override this order.

Module 18: Eliminating Duplicates: SELECT DISTINCT

Module Overview

This module covers eliminating duplicate rows from query results using the SELECT DISTINCT clause. Students will learn how DISTINCT processes multiple columns and its impact on query performance. By the end of this module, learners will be able to use DISTINCT to retrieve unique data records.

Core Concepts & Working Principles

The SELECT DISTINCT clause is used to remove duplicate rows from query results, returning only unique rows. When DISTINCT is specified, Oracle sorts the result set and filters out duplicate rows. If you specify multiple columns after DISTINCT, Oracle evaluates the uniqueness of the combination of all columns. Because DISTINCT requires sorting and processing the result set, it can impact query performance on large datasets. Extracted Reference details from training manual: ○ Answer: attends 55. Pick the meaningful relationship between entities: ○ Answer: vendor supplies goods 56. The entity set is a _______. ○ Answer: collection of similar entities 57. Pick entity set from the following: ○ Answer: all vendors supplying to an organization 58. The expansion of E-R diagram is _______. ○ Answer: Entity-Relationship diagram 59. In an E-R diagram entities are represented by _______. ○ Answer: rectangles 60. In an E-R diagram relationship is represented by _______. ○ Answer: diamond shaped...

Key Terminology & Definitions
  • SELECT DISTINCT: A query clause used to filter out duplicate rows, returning only unique records in the result set.
  • Unique Row: A row in a result set that has a unique combination of values across all selected columns.
  • Cardinality: A measure of the uniqueness of data values in a column, where high cardinality means most values are unique.
  • Query Sort: An internal database operation that orders query results, used by DISTINCT to identify duplicate rows.
Step-by-Step Practical Implementation
  1. Write a query to retrieve all department IDs from the employees table.
  2. Add the DISTINCT keyword to the query to filter out duplicate department IDs.
  3. Write a query using DISTINCT on both the department ID and job ID columns.
  4. Verify that the query returns unique combinations of both columns.
  5. Compare the performance of queries with and without the DISTINCT keyword.
Practical Code Snippet
Simulated Editor (Code)
-- Retrieve unique job locations SELECT DISTINCT job_id, department_id FROM employees;
Real-World Enterprise Scenario: Marketing systems use SELECT DISTINCT to extract a unique list of customer emails from transaction logs, preventing duplicate mailings.
Troubleshooting & Best Practices: Do not use DISTINCT if your query already returns a primary key column, as primary keys are already unique and using DISTINCT adds unnecessary sorting overhead.
Module Review & Interview Prep

Q1: How does SELECT DISTINCT evaluate uniqueness when multiple columns are specified?

It evaluates the uniqueness of the combination of all selected columns, returning rows with unique combined values.

Module 19: Sorting Records: ORDER BY parameters

Module Overview

This module covers sorting query results using the ORDER BY clause. Students will explore ascending and descending sort options, multi-column sorting, and null value positioning. By the end of this module, learners will be able to sort query results based on their requirements.

Core Concepts & Working Principles

The ORDER BY clause is used to sort the rows returned by a query. It is evaluated after all other clauses in a query. You can sort results in ascending order (ASC, which is the default) or descending order (DESC). You can sort by multiple columns, with Oracle sorting by the first column first, then by the second column to resolve ties, and so on. You can also sort by column aliases, expressions, or column position index numbers. By default in Oracle, null values are sorted last in ascending order and first in descending order, though you can override this behavior using the NULLS FIRST or NULLS LAST options. Extracted Reference details from training manual: ○ Answer: Decomposition 77. X is a proper subset of some key K. Such a dependency is sometimes called _______. ○ Answer: Partial dependency 78. X is not a proper subset of some key K. Such a dependency is sometimes called _______. ○ Answer: transitive dependency 79. Indicated by using arrow from entities to relationships in the ER diagram. ○ Answer: Arrow 80. Aggregation is indicated by _______ in ER diagram. ○ Answer: Dotted line 81. ISA is indicated by _______ symbol. ○ Answer: Triangle 82. _______ is a se...

Key Terminology & Definitions
  • ORDER BY: A query clause used to sort the rows returned by a query in ascending or descending order.
  • Ascending Sort: Sorting values from lowest to highest (A-Z, 1-10), specified using the ASC keyword.
  • Descending Sort: Sorting values from highest to lowest (Z-A, 10-1), specified using the DESC keyword.
  • NULLS FIRST: An ORDER BY option that forces null values to appear at the beginning of the sorted results.
Step-by-Step Practical Implementation
  1. Write a query to retrieve employee names and salaries.
  2. Sort the results in ascending order by name using the ORDER BY clause.
  3. Sort the results in descending order by salary using the DESC keyword.
  4. Write a multi-column sort query to sort by department ID, then by salary descending.
  5. Use the NULLS FIRST option to position missing commission values at the top.
Practical Code Snippet
Simulated Editor (Code)
-- Multi-column sort with null handling SELECT employee_id, last_name, salary, commission_pct FROM employees ORDER BY department_id ASC, salary DESC NULLS LAST;
Real-World Enterprise Scenario: Leaderboards use ORDER BY score DESC, completion_time ASC to rank players by their performance and resolve ties.
Troubleshooting & Best Practices: If your multi-column sort does not work as expected, verify the order of columns in the ORDER BY clause and ensure they are separated by commas.
Module Review & Interview Prep

Q1: Where does Oracle position NULL values when sorting query results?

Oracle positions NULL values last in ascending sorts (ASC) and first in descending sorts (DESC), unless overridden by NULLS FIRST/LAST clauses.

Module 20: Aggregations: SUM, AVG, COUNT functions

Module Overview

This module covers aggregate functions in SQL, focusing on SUM, AVG, COUNT, MIN, and MAX. Students will learn how aggregate functions calculate summary metrics and how they handle null values. By the end of this module, learners will be able to write queries to summarize data.

Core Concepts & Working Principles

Aggregate functions perform calculations on a set of values, returning a single summary value. Common aggregate functions include SUM (calculates the total), AVG (calculates the average), COUNT (returns the number of values), MIN (finds the minimum value), and MAX (finds the maximum value). Aggregate functions ignore null values in their calculations, except for COUNT(*), which counts all rows in the table. You can combine aggregate functions with the DISTINCT keyword to calculate metrics on unique values only. Extracted Reference details from training manual: ○ Answer: a tuple 100. _______ keyword is used to find the number of values in a column. ○ Answer: COUNT 101. An advantage of the database management approach is _______. ○ Answer: data is integrated and can be accessed by multiple programs 102. The collection of information stored in a database at a particular moment is called as _______. ○ Answer: instance of the database 103. _______ is used to define overall design of the database. ○ Answer: schema 104. Key to represent relationship between tables is call...

Key Terminology & Definitions
  • Aggregate Function: A function that performs calculations on a group of rows, returning a single summary value.
  • COUNT(*): An aggregate function that counts all rows in a table, including rows with null values or duplicates.
  • NULL Exclusion: The behavior of aggregate functions where null values are ignored in calculations like SUM or AVG.
  • DISTINCT Aggregation: Performing aggregate calculations on unique values only, specified by placing DISTINCT inside the function (e.g., COUNT(DISTINCT col)).
Step-by-Step Practical Implementation
  1. Write a query to calculate the total salary of all employees using SUM.
  2. Calculate the average salary of all employees using the AVG function.
  3. Count the number of employees in the table using the COUNT(*) function.
  4. Count the number of unique departments using COUNT(DISTINCT department_id).
  5. Find the minimum and maximum employee salaries using the MIN and MAX functions.
Practical Code Snippet
Simulated Editor (Code)
-- Summary metrics query SELECT COUNT(*) AS total_employees, SUM(salary) AS total_payroll, AVG(salary) AS avg_sal FROM employees;
Real-World Enterprise Scenario: Financial reports use SUM and AVG to calculate total sales and average transaction values for quarterly performance reviews.
Troubleshooting & Best Practices: Remember that AVG calculates the average of non-null values only. To include null values as zero in the average, combine AVG with the NVL function.
Module Review & Interview Prep

Q1: How does the COUNT(*) function differ from COUNT(column_name)?

COUNT(*) counts every row in the table including nulls, whereas COUNT(column_name) only counts rows where the specified column is not null.

Module 21: Grouping Queries: GROUP BY parameters

Module Overview

This module covers grouping query results using the GROUP BY clause. Students will learn how to create groups of data and explore the rules for selecting columns in grouped queries. By the end of this module, learners will be able to write queries to summarize data by category.

Core Concepts & Working Principles

The GROUP BY clause is used to group rows that have the same values in specified columns. It is evaluated after the WHERE clause and before the SELECT clause. When using GROUP BY, all columns in the SELECT list that are not part of an aggregate function must be specified in the GROUP BY clause. Oracle groups rows by the specified columns first, and then calculates the aggregate function values for each group. Extracted Reference details from training manual: ○ Answer: DML 122. Selection Operation is used to _______ from a relation. ○ Answer: Select the rows 123. _______ command is used to remove the table definition information. ○ Answer: Drop 124. _______ is used to modify the structure of an existing table. ○ Answer: Alter 125. View can be dropped using _______ command. ○ Answer: Drop View 126. _______ columns are not allowed to contain null values. ○ Answer: Primary Key 127. _______ are valuable to give the security to our original table. ○ Answer: Views 128...

Key Terminology & Definitions
  • GROUP BY: A query clause used to group rows that have the same values in specified columns, enabling aggregate calculations by category.
  • Grouping Column: A column specified in the GROUP BY clause used to divide rows into separate groups.
  • Aggregate Context: The requirement that all non-aggregate columns in a grouped query's SELECT list must be specified in the GROUP BY clause.
  • Data Redundancy: Duplicate values in a column, which are consolidated into single groups by the GROUP BY clause.
Step-by-Step Practical Implementation
  1. Write a query to retrieve department IDs and calculate average salaries.
  2. Add a GROUP BY clause specifying the department ID column.
  3. Group the results by both department ID and job ID to calculate averages.
  4. Verify that all non-aggregate SELECT columns are present in the GROUP BY clause.
  5. Run the query and inspect the summary results by group.
Practical Code Snippet
Simulated Editor (Code)
-- Grouping data by department and job SELECT department_id, job_id, COUNT(*) AS count, AVG(salary) AS avg_sal FROM employees GROUP BY department_id, job_id;
Real-World Enterprise Scenario: Retail systems use GROUP BY category to calculate total sales and average prices for each product category.
Troubleshooting & Best Practices: If you receive a 'not a GROUP BY expression' error, verify that all columns in your SELECT list are either part of an aggregate function or specified in the GROUP BY clause.
Module Review & Interview Prep

Q1: What is the rule for selecting columns when using the GROUP BY clause?

Any column in the SELECT list that is not part of an aggregate function must be specified in the GROUP BY clause.

Module 22: Group Filtering: HAVING Clause standards

Module Overview

This module covers filtering grouped query results using the HAVING clause. Students will explore the differences between filtering rows with WHERE and filtering groups with HAVING. By the end of this module, learners will be able to write queries that filter aggregated data.

Core Concepts & Working Principles

The HAVING clause is used to filter groups created by the GROUP BY clause, returning only the groups that meet specified aggregate conditions. While the WHERE clause filters individual rows before they are grouped, the HAVING clause filters groups after the GROUP BY clause is evaluated. HAVING clauses can contain aggregate functions (like SUM or AVG) in their logical expressions, which is not allowed in WHERE clauses. Extracted Reference details from training manual: 144. _______ is a query that has another query embedded within it. ○ Answer: Subquery 145. _______ to calculate the number of values in the Column. ○ Answer: Count 146. _______ is used to calculate the sum of all values in the column. ○ Answer: Sum 147. _______ is used to calculate the average of all values in the column. ○ Answer: avg 148. Which function is used to extract the maximum values in the relations? ○ Answer: max 149. Which function is used to extract the minimum values in the relations? ○ A...

Key Terminology & Definitions
  • HAVING Clause: A query clause used to filter groups created by a GROUP BY clause based on aggregate conditions.
  • Group Filter: A logical expression in a HAVING clause that evaluates aggregate metrics to filter grouped rows.
  • Row Filter: A condition in a WHERE clause that evaluates individual column values before grouping occurs.
  • Aggregation Timing: The sequence where WHERE filters rows first, GROUP BY creates groups second, and HAVING filters groups third.
Step-by-Step Practical Implementation
  1. Write a query that groups employees by department ID and calculates average salaries.
  2. Add a HAVING clause to filter out departments with average salaries below 5000.
  3. Add a WHERE clause to exclude employees with low salaries before grouping.
  4. Combine WHERE, GROUP BY, and HAVING clauses in a single query.
  5. Run the query and verify the output matches your filtering criteria.
Practical Code Snippet
Simulated Editor (Code)
-- Filtering groups using HAVING clause SELECT department_id, COUNT(*) AS num_employees, AVG(salary) AS avg_sal FROM employees WHERE manager_id IS NOT NULL GROUP BY department_id HAVING COUNT(*) > 5 AND AVG(salary) >= 5000;
Real-World Enterprise Scenario: Sales reports use HAVING SUM(sales_amount) > 10000 to identify top-performing stores while ignoring stores with low sales.
Troubleshooting & Best Practices: Do not put non-aggregate conditions in the HAVING clause. Filter individual rows in the WHERE clause instead to optimize query performance.
Module Review & Interview Prep

Q1: What is the difference between the WHERE and HAVING clauses?

WHERE filters individual rows before they are grouped, while HAVING filters groups after they are created by the GROUP BY clause.

Module 23: Special Operators: IN & BETWEEN wildcards

Module Overview

This module covers the special SQL operators IN and BETWEEN. Students will learn how to write queries that match values in a list using IN or match values within a range using BETWEEN. By the end of this module, learners will be able to use these operators to filter query results.

Core Concepts & Working Principles

The IN and BETWEEN operators simplify filter conditions in WHERE clauses. The IN operator checks if a column value matches any value in a specified list of options. It is equivalent to multiple OR conditions. The BETWEEN operator checks if a value falls within an inclusive range, defined by start and end values. It is equivalent to a combination of >= and <= conditions. Both operators can be combined with the NOT operator to exclude matching records. Extracted Reference details from training manual: displayed? ○ Answer: 50 and 45.93 166. Select operator is not a unary operator. ○ Answer: FALSE 167. Project operator chooses subset of attributes or columns of a relation. ○ Answer: TRUE 168. _______ database is used as template for all databases created. ○ Answer: Model 169. One aspect that has to be dealt with by the integrity subsystem is to ensure that only valid values can be assigned to each data items. This is referred to as _______. ○ Answer: Domain Integrity 170. _______ operator is basically a join followed b...

Key Terminology & Definitions
  • IN Operator: A comparison operator that checks if a value matches any value in a list or subquery.
  • BETWEEN Operator: A comparison operator that checks if a value falls within an inclusive range (endpoints included).
  • NOT IN: An operator that checks if a value is not present in a list, returning true if there are no matches.
  • Inclusive Range: A range of values that includes both the start and end values, used by the BETWEEN operator.
Step-by-Step Practical Implementation
  1. Write a query to retrieve employees who work in departments 10, 20, or 30 using the IN operator.
  2. Modify the query to exclude these departments using the NOT IN operator.
  3. Write a query to find employees with salaries between 5000 and 10000 using the BETWEEN operator.
  4. Exclude this salary range using the NOT BETWEEN operator.
  5. Run the queries and inspect the filtered results.
Practical Code Snippet
Simulated Editor (Code)
-- IN and BETWEEN examples SELECT employee_id, last_name, salary, department_id FROM employees WHERE department_id IN (10, 20, 80) AND salary BETWEEN 4000 AND 9000;
Real-World Enterprise Scenario: Shipping systems use the IN operator to filter orders by state codes (like 'NY', 'NJ', 'PA') to calculate regional shipping costs.
Troubleshooting & Best Practices: If a list passed to the NOT IN operator contains a NULL value, the query will return zero rows. Ensure the list does not contain NULL values.
Module Review & Interview Prep

Q1: Is the BETWEEN operator inclusive of its boundary values?

Yes, the BETWEEN operator is inclusive, meaning both the start and end values are included in the search range.

Module 24: Special Operators: LIKE & EXISTS lookups

Module Overview

This module covers the pattern matching operators LIKE and EXISTS. Students will explore wildcard characters, correlated subqueries, and pattern filtering. By the end of this module, learners will be able to perform text searches and existence checks in queries.

Core Concepts & Working Principles

The LIKE and EXISTS operators perform pattern matching and existence checks in queries. The LIKE operator is used for pattern matching in text columns, utilizing wildcard characters: '%' matches zero or more characters, and '_' matches a single character. The EXISTS operator checks if a subquery returns any rows. It is evaluated as true as soon as a single matching row is located, making it faster than COUNT checks for existence queries. Extracted Reference details from training manual: 185. The process of normalization _______. ○ Answer: requires one to understand dependency between attributes 186. A relation is said to be in 1NF if _______. ○ Answer: there are no composite attributes in the relation 187. The number of normal forms which has been proposed and discussed in the book are _______. ○ Answer: 6 188. A relation which is in a higher normal form _______. ○ Answer: implies that it also qualifies to be in lower normal form 189. Given an attribute x, another attribute y is dependent ...

Key Terminology & Definitions
  • LIKE Operator: A text operator used in WHERE clauses to search for pattern matches in string columns using wildcards.
  • EXISTS Operator: A logical operator that checks if a subquery returns any rows, returning true if matches are found.
  • Percent Wildcard (%): A wildcard character used with LIKE that matches any sequence of zero or more characters.
  • Underscore Wildcard (_): A wildcard character used with LIKE that matches any single character.
Step-by-Step Practical Implementation
  1. Write a query to find employees whose names start with 'J' using the LIKE operator.
  2. Use the underscore wildcard '_' to find names with 'a' as the second character.
  3. Write a query to check for active orders using the EXISTS operator.
  4. Correlate the subquery with the parent table to match primary keys.
  5. Run the queries and verify the pattern matching results.
Practical Code Snippet
Simulated Editor (Code)
-- LIKE pattern matching and EXISTS check SELECT employee_id, last_name FROM employees e WHERE e.last_name LIKE 'J%' AND EXISTS (SELECT 1 FROM departments d WHERE d.department_id = e.department_id);
Real-World Enterprise Scenario: Customer support search portals use the LIKE operator to search for articles containing search keywords in their titles.
Troubleshooting & Best Practices: The LIKE operator performs a case-sensitive search in Oracle. Use the UPPER function on columns to perform case-insensitive searches.
Module Review & Interview Prep

Q1: How does the EXISTS operator optimize query execution?

EXISTS stops processing as soon as it finds the first matching row in the subquery, avoiding full table scans.

Module 25: Relational Joins: Inner & Outer Joins

Module Overview

This module covers relational joins in SQL. Students will explore Cartesian products, inner joins, left/right outer joins, and full outer joins. By the end of this module, learners will be able to retrieve data from multiple related tables in a single query.

Core Concepts & Working Principles

Relational joins combine columns from two or more tables based on a related column. An INNER JOIN returns only the rows that have matching values in both tables. OUTER JOINS return all rows from one table and the matching rows from the other. A LEFT OUTER JOIN returns all rows from the left table, and matching rows from the right; if there is no match, NULL values are returned for the right table columns. RIGHT and FULL outer joins behave similarly, returning unmatched rows from the right table or both tables, respectively. Extracted Reference details from training manual: ○ Answer: private 205. Global package item are declared in package _______ for external users to use it. ○ Answer: specification 206. Variables declared in package specification are by default initialized to _______. ○ Answer: null 207. Which command is used to invoke a procedure in a package? ○ Answer: execute 208. _______ is the process of taking a normalized database and modifying table structures to allow controlled redundancy for increased database performance. ○ Answer: Denormalization 209. In select statement Duplicat...

Key Terminology & Definitions
  • Inner Join: A join operation that returns only the rows that have matching values in both tables.
  • Outer Join: A join operation (LEFT, RIGHT, or FULL) that returns matching rows, plus unmatched rows from one or both tables.
  • Cartesian Product: A result set containing all possible combinations of rows from joined tables, created if join conditions are omitted.
  • Join Condition: The clause (usually matching primary and foreign keys) that defines how tables are linked in a join query.
Step-by-Step Practical Implementation
  1. Write an inner join query to combine the employees and departments tables.
  2. Define the join condition using the ON clause matching department IDs.
  3. Modify the query to use a LEFT OUTER JOIN to include departments without employees.
  4. Write a RIGHT OUTER JOIN to include employees without assigned departments.
  5. Run the join queries and inspect the combined columns.
Practical Code Snippet
Simulated Editor (Code)
-- Inner and Left Outer Join queries SELECT e.employee_id, e.last_name, d.department_name FROM employees e INNER JOIN departments d ON e.department_id = d.department_id; SELECT d.department_name, e.last_name FROM departments d LEFT OUTER JOIN employees e ON d.department_id = e.department_id;
Real-World Enterprise Scenario: Billing systems run outer join queries to generate invoice reports, including customers who have not placed any orders.
Troubleshooting & Best Practices: Ensure every join in your query has a valid join condition. Omitting join conditions creates a Cartesian product, returning massive, incorrect result sets.
Module Review & Interview Prep

Q1: What is the difference between an INNER JOIN and a LEFT OUTER JOIN?

An INNER JOIN returns only matching rows from both tables, while a LEFT OUTER JOIN returns all rows from the left table and matching rows from the right.

Module 26: Logical Views: CREATE VIEW structures

Module Overview

This module covers logical database views. Students will learn about view creation, view updates, and using views to enforce database security. By the end of this module, learners will be able to create and manage views to simplify access to complex data.

Core Concepts & Working Principles

A view is a virtual table defined by a query. It does not store data itself; instead, it displays data stored in underlying base tables. Views are created using the CREATE VIEW statement. Views simplify access to complex queries, abstract database structures, and enforce security by restricting access to sensitive columns. You can update views (using INSERT or UPDATE) if they reference a single base table and do not contain aggregate functions, group clauses, or DISTINCT keywords. Extracted Reference details from training manual: 227. Primary indexes, secondary indexes and cluster indexes are all types of _______. ○ Answer: ordered indexes 228. In multilevel indexes, primary index created for its first level is classified as _______. ○ Answer: second level of multilevel index 229. Indexes which specifies address of records on disk with a physical pointer are classified as _______. ○ Answer: physical index 230. Example of non dense index is _______. ○ Answer: clustering index 231. The method of access which uses key transformation is known as...

Key Terminology & Definitions
  • Logical View: A virtual table defined by a SQL query that displays data from underlying base tables without storing it itself.
  • Base Table: An underlying physical table that stores the data displayed by a logical view.
  • Updatable View: A view that supports INSERT, UPDATE, or DELETE operations, modifying data in its underlying base table.
  • WITH CHECK OPTION: A view option that prevents updates that would make modified rows invisible to the view's query.
Step-by-Step Practical Implementation
  1. Write a complex select query that joins three tables.
  2. Use the CREATE VIEW statement to define a view based on this query.
  3. Query the view to verify it returns the correct data.
  4. Write an update statement targeting the view to modify data in the base table.
  5. Drop the view using the DROP VIEW command.
Practical Code Snippet
Simulated Editor (Code)
-- Create security view CREATE VIEW dept_summary_view AS SELECT department_id, COUNT(*) AS emp_count, AVG(salary) AS avg_sal FROM employees GROUP BY department_id;
Real-World Enterprise Scenario: Security administrators create views to share database access with external reporting teams, hiding sensitive salary and SSN columns.
Troubleshooting & Best Practices: If your view update fails, verify the view does not contain joins, aggregate functions, or DISTINCT clauses that prevent updates.
Module Review & Interview Prep

Q1: Does a database view consume physical storage space?

No, a view is a virtual table that only stores the query definition, consuming no physical storage space for data.

Module 27: Database Synonyms & Shorthand Naming

Module Overview

This module covers database synonyms. Students will learn about private and public synonyms, shorthand naming, and database abstraction. By the end of this module, learners will be able to create synonyms to simplify access to tables and schema objects.

Core Concepts & Working Principles

A synonym is an alias or alternative name assigned to a database object (like a table, view, or sequence). Synonyms abstract database structures, allowing users to query objects without specifying the schema owner name. Oracle supports two types of synonyms: private synonyms (accessible only to the schema owner) and public synonyms (accessible to all database users). Synonyms simplify query syntax and help maintain code compatibility if underlying database tables are renamed or moved. Extracted Reference details from training manual: _______. ○ Answer: third level of multilevel index 248. The SQL database language includes statements for: ○ Answer: All of the above. (Definition, manipulation, control) 249. A command to remove a relation from an SQL database: ○ Answer: Drop table table name 250. Which SQL Query is use to remove a table and all its data from the database? ○ Answer: Drop Table 251. A type of query that is placed within a WHERE or HAVING clause of another query is called _______. ○ Answer: Sub query 252. Aggregate functions ...

Key Terminology & Definitions
  • Database Synonym: An alias or alternative name assigned to a database object like a table or view, simplifying query access.
  • Private Synonym: A synonym owned by a specific schema and accessible only to that schema owner or authorized users.
  • Public Synonym: A database-wide synonym created by administrators that is accessible to all database users.
  • Schema Abstraction: Hiding the details of schema owner names and locations to simplify database access.
Step-by-Step Practical Implementation
  1. Identify a table with a long schema prefix name.
  2. Create a private synonym for the table using the CREATE SYNONYM statement.
  3. Query the table using the synonym instead of the long table name.
  4. Create a public synonym to share access across all database users.
  5. Drop a synonym using the DROP SYNONYM command.
Practical Code Snippet
Simulated Editor (Code)
-- Create synonym for schema table CREATE SYNONYM emp_short FOR hr.employees_master_table; -- Query using the synonym SELECT * FROM emp_short;
Real-World Enterprise Scenario: Application developers use synonyms to point to local test tables during development, then update the synonyms to point to production tables during deployment.
Troubleshooting & Best Practices: If a query using a synonym throws an 'object does not exist' error, verify the synonym was created correctly and that you have permissions to access the underlying table.
Module Review & Interview Prep

Q1: What is the difference between a private and a public synonym?

Private synonyms are only accessible to the schema owner, while public synonyms are database-wide and accessible to all users.

Module 28: Database Indexes: B-Tree & Bitmap designs

Module Overview

This module covers database indexes, focusing on B-Tree and Bitmap index designs. Students will learn how indexes improve query performance and when to choose B-Tree or Bitmap indexes. By the end of this module, learners will be able to create and manage indexes to optimize query speed.

Core Concepts & Working Principles

Indexes are schema objects used by the database optimizer to speed up data retrieval. A B-Tree index is the default index type in Oracle. It is structured as a balanced search tree and is ideal for columns with high cardinality (many unique values), like primary keys. A Bitmap index uses bit arrays to index columns. It is ideal for columns with low cardinality (few unique values, like gender or status) in data warehousing environments. While indexes speed up queries, they slow down DML operations (INSERT, UPDATE, DELETE) because the indexes must be updated whenever data changes. Extracted Reference details from training manual: 268. If an entity appears in not more than 5 relationships then it is a _______. ○ Answer: 1:5 relationship 269. A relation is _______. ○ Answer: an entity 270. Rows of a relation are called _______. ○ Answer: tuples 271. The database schema is written in _______. ○ Answer: DDL 272. The way a particular application views the data from the database that the application uses is a _______. ○ Answer: sub schema 273. The relational model feature is that there _______. ○ Answer: is much more data independence than ...

Key Terminology & Definitions
  • Database Index: A schema object that improves query speed by providing fast lookup paths to data rows.
  • B-Tree Index: A balanced search tree index structure, ideal for columns with high cardinality.
  • Bitmap Index: An index structure that uses bit arrays, ideal for columns with low cardinality in data warehouses.
  • Cardinality: The measure of unique values in a column, determining which index type is best for performance.
Step-by-Step Practical Implementation
  1. Identify a column that is frequently used in query filter conditions.
  2. Create a B-Tree index on the column using the CREATE INDEX statement.
  3. Create a Bitmap index on a low-cardinality status column.
  4. Analyze query execution plans to verify the database is using the indexes.
  5. Drop an index using the DROP INDEX command.
Practical Code Snippet
Simulated Editor (Code)
-- Create B-Tree and Bitmap indexes CREATE INDEX emp_last_name_idx ON employees(last_name); CREATE BITMAP INDEX emp_gender_idx ON employees(gender);
Real-World Enterprise Scenario: E-commerce portals use B-Tree indexes on SKU columns and Bitmap indexes on inventory category columns to optimize product searches.
Troubleshooting & Best Practices: Avoid indexing columns that are frequently updated, as the index update overhead can slow down DML operations.
Module Review & Interview Prep

Q1: When should you use a Bitmap index instead of a B-Tree index?

Use a Bitmap index on columns with low cardinality in read-heavy environments like data warehouses, and B-Tree indexes on columns with high cardinality.

Module 29: Transaction Control: COMMIT & ROLLBACK

Module Overview

This module covers database transaction control using COMMIT and ROLLBACK. Students will explore transaction boundaries, transaction properties (ACID), and savepoints. By the end of this module, learners will be able to manage transactions to ensure data consistency.

Core Concepts & Working Principles

A database transaction is a logical unit of work containing one or more DML statements. Transaction control commands manage these changes to ensure data consistency. The COMMIT command saves all pending transaction modifications permanently to the database. The ROLLBACK command cancels all pending modifications, restoring the database to its state before the transaction started. The SAVEPOINT command sets a savepoint within a transaction, allowing you to roll back specific changes without cancelling the entire transaction. Transaction control ensures the ACID properties of database transactions. Extracted Reference details from training manual: ○ a. Third b. Fourth c. Fifth d. Second ( Ans: b ) 4. _______ is a procedural language extension to SQL. ○ a. PL/SQL b. DDL c. DML d. DCL ( Ans: a ) 5. iSQL*Plus supports________. ○ a. Windows GUI b. Web based user interface c. LINUX based interface d. UNIX UI ( Ans: b ) 6. SQL is invented by _______. ○ a. IBM b. Microsoft c. Oracle d. Intel ( Ans: a ) 7. _______ is used to retrieve, store, modify data in a database. ○ a. DDL b. TCL c. DCL d. DML ( Ans: d ) 8. _______ is the operator used to combine...

Key Terminology & Definitions
  • Transaction: A logical unit of database work containing one or more DML statements that are executed together.
  • COMMIT: A transaction control command that saves all pending database modifications permanently.
  • ROLLBACK: A transaction control command that cancels pending modifications, restoring the database to its previous state.
  • SAVEPOINT: A marker set within a transaction that allows you to roll back specific changes without cancelling the entire transaction.
Step-by-Step Practical Implementation
  1. Start a new transaction by running a DML INSERT statement.
  2. Set a savepoint in the transaction using the SAVEPOINT command.
  3. Run an UPDATE statement to modify other records.
  4. Roll back the update to the savepoint using the ROLLBACK TO command.
  5. Save all remaining changes permanently by running the COMMIT command.
Practical Code Snippet
Simulated Editor (Code)
-- Transaction control example INSERT INTO accounts VALUES (102, 5000); SAVEPOINT sp1; UPDATE accounts SET balance = balance - 100 WHERE acct_id = 102; ROLLBACK TO sp1; -- Roll back the update only COMMIT; -- Commit the insertion
Real-World Enterprise Scenario: Banking systems use transaction control to manage fund transfers, committing only when both the withdrawal and deposit succeed.
Troubleshooting & Best Practices: If you disconnect from the database without running COMMIT or ROLLBACK, Oracle will automatically roll back any active transactions.
Module Review & Interview Prep

Q1: What is the purpose of a SAVEPOINT?

A SAVEPOINT sets a marker within a transaction, allowing you to roll back specific changes without cancelling the entire transaction.

Module 30: PL/SQL Block Structure & Explicit Cursors

Module Overview

This module covers PL/SQL block structure and explicit cursors. Students will explore block sections, variable declarations, and using explicit cursors to process multiple query rows. By the end of this module, learners will be able to write PL/SQL blocks and manage database cursors.

Core Concepts & Working Principles

PL/SQL is Oracle's procedural language extension to SQL. It organizes code into logical blocks that contain declarative, executable, and exception-handling sections. A BASC PL/SQL block starts with the DECLARE keyword, followed by variable definitions, the BEGIN keyword, executable statements, an optional EXCEPTION block, and the END keyword. While implicit cursors handle single-row queries, explicit cursors must be defined by the developer to process multi-row query results. Explicit cursor operations include DECLARE, OPEN, FETCH, and CLOSE. Extracted Reference details from training manual: 3. (a) Elaborate SQL*Plus. [OR] (b) Explain DDL commands with example.

Key Terminology & Definitions
  • PL/SQL Block: A logical code block containing declarative, executable, and exception-handling sections in PL/SQL.
  • Explicit Cursor: A database cursor defined by the developer to query and process multiple rows of data sequentially.
  • Cursor FETCH: A cursor operation that retrieves the active row from the cursor result set, assigning values to variables.
  • EXCEPTION Block: The section of a PL/SQL block where runtime errors are caught and handled.
Step-by-Step Practical Implementation
  1. Write a basic PL/SQL block structure with DECLARE and BEGIN sections.
  2. Declare variables to hold employee names and salaries.
  3. Define an explicit cursor to query employees in department 20.
  4. Open the cursor, fetch rows in a loop, and close the cursor when done.
  5. Add an exception handler to print error messages if execution fails.
Practical Code Snippet
Simulated Editor (Code)
-- PL/SQL block with explicit cursor DECLARE CURSOR emp_cur IS SELECT last_name, salary FROM employees WHERE department_id = 20; v_name employees.last_name%TYPE; v_sal employees.salary%TYPE; BEGIN OPEN emp_cur; LOOP FETCH emp_cur INTO v_name, v_sal; EXIT WHEN emp_cur%NOTFOUND; dbms_output.put_line(v_name || ' earns ' || v_sal); END LOOP; CLOSE emp_cur; END; /
Real-World Enterprise Scenario: Financial applications run PL/SQL procedures and cursors to process end-of-month payrolls for thousands of employees.
Troubleshooting & Best Practices: Always close explicit cursors when you are finished processing data to release database resources and prevent cursor leaks.
Module Review & Interview Prep

Q1: What are the four steps required to use an explicit cursor?

The four steps are: 1. DECLARE the cursor, 2. OPEN the cursor, 3. FETCH the rows, and 4. CLOSE the cursor.