20 October 2024
Oracle Technical Interview Questions. Most important questions part 2.
- Oracle Technical Interview Previous Year Questions/ Oracle Technical Interview PYQS for beginners/Oracle Technical Interview Questions:
- Note- Codes are written in blue colour.
- Q)State the usage of the GRANT option in the IMP command.
- Solution: The GRANT option in the IMP (Import) command is used to include object privileges (grants) during the import process, allowing the database users to retain the permissions they had in the exported schema.
- Q)How many memory layers are in the Oracle shared pool?
- Solution:
- The Oracle shared pool consists of two primary memory layers:
- Library Cache: Stores shared SQL, PL/SQL code, and parsed execution plans.
- Data Dictionary Cache (Row Cache): Holds metadata information such as user account data, object definitions, and privileges.
- These two caches work together to optimize SQL parsing, reduce redundant memory use, and improve overall database performance.
- Q)What is save point in Oracle database?
- Solution: A savepoint in Oracle marks a specific point in a transaction, allowing partial rollback to that point without affecting the entire transaction.
- Q)Illustrate the use of the TRANSLATE function with an example.
- Solution:
- The TRANSLATE function in Oracle replaces characters in a string with other characters based on their position. It substitutes each occurrence of a character in a source string with the corresponding character from a second string.
- Example:
- SELECT TRANSLATE(‘ORACLE’, ‘ORC’, ‘ABC’) AS result FROM dual;
- Explanation:
- The first argument is 'ORACLE', the string to be transformed.
- The second argument 'ORC' specifies the characters to be replaced.
- The third argument 'ABC' provides the corresponding replacements.
- Result:
- ABAALE
- In this case:
- O is replaced with A,
- R is replaced with B,
- C is replaced with C (unchanged because it’s mapped to itself).
- Q)What are the various Oracle database objects?
- Solution:
- Oracle database objects are structures used to store, manage, and retrieve data. The various types include:
- Tables: Store data in rows and columns.
- Views: Virtual tables based on the result of a SQL query.
- Indexes: Improve the speed of data retrieval.
- Sequences: Generate unique numeric values.
- Synonyms: Aliases for database objects.
- Schemas: Logical containers for objects.
- Stored Procedures and Functions: PL/SQL code that can be executed.
- Triggers: Execute PL/SQL code automatically when a specified event occurs.
- Packages: Group related procedures, functions, variables, and cursors.
- Materialized Views: Store precomputed query results for faster access.
- Clusters: Group tables that share common columns for faster joins.
- Types: Define custom data types.
- Database Links: Establish a connection between different databases.
- Q)Write a query to list the duplicate values in an Oracle table.
- Solution: SELECT column_name, COUNT(*) FROM table_name GROUP BY column_name HAVING COUNT(*) > 1;
- Q)What is the difference between pre-select and pre-query?
- Solution:
- Here are 5 key differences between Pre-Select and Pre-Query in Oracle Forms:
- Triggering Event:
- Pre-Select: Fires just before the SELECT statement is issued to retrieve data.
- Pre-Query: Fires before the query is executed, allowing modification of the query’s logic.
- Purpose:
- Pre-Select: Mainly used to perform actions or validations before any rows are fetched from the database.
- Pre-Query: Used to alter the query conditions (e.g., modifying the WHERE clause) before executing the query.
- Scope:
- Pre-Select: Affects data retrieval after the query is built, but before execution.
- Pre-Query: Influences query-building itself, changing how the query is structured.
- Flexibility:
- Pre-Select: Limited in altering the query logic itself, more focused on pre-fetch actions.
- Pre-Query: Provides greater flexibility to modify the query’s structure, such as adding conditions or setting default values.
- Common Usage:
- Pre-Select: Used for final checks or setup tasks before fetching data.
- Pre-Query: Used for query customization based on user inputs or form conditions.
- Q)Illustrate the use of the REPLACE function with an example.
- Solution: The REPLACE function in Oracle replaces occurrences of a specified substring within a string with another substring.
- Example:
- SELECT REPLACE(‘Hello World’, ‘World’, ‘Oracle’) AS result FROM dual;
- Explanation:
- The first argument 'Hello World' is the original string.
- The second argument 'World' is the substring to be replaced.
- The third argument 'Oracle' is the new substring to replace 'World'.
- Result:
- Hello Oracle
- In this case, 'World' is replaced with 'Oracle'.
- Q)What is hash cluster in Oracle?
- Solution:
- A hash cluster in Oracle is a type of table clustering mechanism that stores table data based on a hash key, allowing for faster data retrieval. Instead of using traditional indexing, Oracle uses a hash function to determine the physical location of rows in a cluster based on the hash key.
- Key Points:
- Hash Key: A column or combination of columns that Oracle uses to apply a hash function.
- Faster Retrieval: If a query includes the hash key in the WHERE clause, the hash function is applied, allowing direct access to the data, which speeds up lookups.
- Predefined Storage: You define the size of the hash table when creating the cluster, so Oracle allocates space for the data based on the expected number of rows.
- Efficient for Fixed Queries: Hash clusters are ideal for tables where queries consistently use the hash key for lookup, but they are less efficient for range scans or queries that do not include the hash key.
- Example of Hash Cluster Creation:
- CREATE CLUSTER emp_dept_cluster (dept_id NUMBER) HASHKEYS 500 SIZE 1024;
- Q)The Oracle database has been developed using which language?
- Solution:
- The Oracle database has primarily been developed using the C programming language. Additionally, other languages such as Assembly and Java are also used for specific components and functionalities within the Oracle database system.
- Q)What is the usage of ANALYZE command in Oracle?
- Solution:
- The ANALYZE command in Oracle is used to gather statistics about database objects, such as tables, indexes, and clusters. These statistics help the Oracle optimizer make informed decisions about the most efficient execution plans for SQL queries. The command can also be used to validate the structure of an object or to compute statistics for the data distribution within it.
- Key Uses:
- Gathering Statistics: Provides information on row counts, data distribution, and index statistics.
- Validating Structure: Checks for errors in object definitions.
- Improving Query Performance: Helps optimize the execution plan for queries by providing accurate statistics to the optimizer.
- Q)What is the logical storage structure of Oracle? List the main components of the logical database structure in the Oracle database.
- Solution:
- The logical storage structure of Oracle is designed to manage data efficiently and provides a way to organize and access data independently of the physical storage. The main components of the logical database structure in an Oracle database include:
- Tablespaces:
- Logical storage units that group related logical structures. Each tablespace can contain one or more data files, which store the actual data.
- Segments:
- Allocated space within a tablespace for a specific type of data structure, such as a table or an index. Each segment consists of one or more extents.
- Extents:
- Continuous blocks of storage space within a segment. When a segment grows, it acquires additional extents.
- Blocks:
- The smallest unit of data storage in Oracle, typically 8 KB by default. Blocks contain the actual data.
- Schemas:
- A collection of database objects (tables, views, indexes, etc.) that are owned by a specific user. Each user can have their own schema.
- Tables:
- Structures that store data in rows and columns, where each row represents a record and each column represents an attribute of the record.
- Indexes:
- Special data structures that improve the speed of data retrieval operations on a table.
- Views:
- Virtual tables based on the result of a SQL query, providing a way to present data from one or more tables.
- Q) What are the different types of modules in Oracle forms?
- Solution:
- In Oracle Forms, there are several types of modules that help in developing and managing forms applications. The different types of modules include:
- Forms Modules:
- The main modules that define the user interface and interact with the database. These include the visual layout, data blocks, and triggers.
- Library Modules:
- Contain reusable PL/SQL code and objects (like procedures, functions, and packages) that can be shared across multiple forms. This promotes code reusability and maintainability.
- Menu Modules:
- Define the application menus that provide navigation and access to different forms and functionalities within the application.
- Object Libraries:
- Similar to library modules, object libraries contain reusable visual objects and properties (like buttons, text items, etc.) that can be used across multiple forms.
- Report Modules:
- Used for defining and generating reports that can be called from forms. They allow integration of reporting features into the Oracle Forms application.
- Trigger Modules:
- These modules define specific events and actions that should occur in response to user interactions or system events. Triggers can be associated with different forms and modules.
- Q)List the various components of the physical database structure of an Oracle database.
- Solution:
- The physical database structure of an Oracle database consists of the following components:
- Data Files: Physical files that store database data, including tables and indexes.
- Control Files: Small binary files that store the database’s metadata, including its structure and state.
- Redo Log Files: Files that store all changes made to the database, enabling recovery in case of failure.
- Parameter Files: Files that contain configuration settings for the database instance.
- Temporary Files: Files used for sorting and joining operations, temporary data storage, and managing session data.
- Q)What is the usage of control file in Oracle?
- Solution:
- The control file in Oracle is a crucial component that tracks the structure of the database. Its primary uses include:
- Database Metadata: Stores important information about the database, such as its name, the timestamp of the last backup, and the current log sequence numbers.
- File Locations: Keeps the physical locations of data files, redo log files, and parameter files.
- Recovery Information: Facilitates database recovery by providing information needed to restore the database to a consistent state after a failure.
- Database Status: Maintains information about the database’s current status, including whether it is open or closed.
- Q)Define a tablespace in context with the Oracle database.
- Solution: A tablespace in Oracle is a logical storage unit that groups related database objects, such as tables and indexes. It serves as a container for these objects and can consist of one or more physical data files. Tablespaces help manage data allocation, organization, and storage, allowing for efficient data retrieval and management within the Oracle database.
- Q)Can you create a synonym without having a table?
- Solution:
- Yes, you can create a synonym in Oracle without having an underlying table. A synonym can point to various database objects, including:
- Views: You can create a synonym for a view even if the underlying table does not exist.
- Sequences: Synonyms can be created for sequences to simplify access to them.
- Procedures and Functions: You can create synonyms for stored procedures or functions.
- However, for a synonym to be valid, the referenced object must exist at the time you attempt to use it. Creating a synonym for a non-existing table will result in an error, but it’s possible to create synonyms for other objects without them being present initially.
- Q)List the default tablespaces of Oracle.
- Solution:
- The default tablespaces of Oracle include:
- SYSTEM
- SYSAUX
- TEMP
- UNDOTBS1
- Q)What types of joins are used in writing SUBQUERIES?
- Solution:
- Inner Join
- Outer Join (Left, Right, and Full Outer Joins)
- Cross Join
- Self Join
Oracle Technical Interview Previous Year Questions/ Oracle Technical Interview PYQS for beginners/Oracle Technical Interview Questions:
Note- Codes are written in blue colour.
Q)State the usage of the GRANT option in the IMP command.
Solution: The GRANT option in the IMP (Import) command is used to include object privileges (grants) during the import process, allowing the database users to retain the permissions they had in the exported schema.
Q)How many memory layers are in the Oracle shared pool?
Solution:
The Oracle shared pool consists of two primary memory layers:
-
Library Cache: Stores shared SQL, PL/SQL code, and parsed execution plans.
-
Data Dictionary Cache (Row Cache): Holds metadata information such as user account data, object definitions, and privileges.
These two caches work together to optimize SQL parsing, reduce redundant memory use, and improve overall database performance.
Oracle Technical Interview Questions/Oracle Technical Interview Previous Year Questions/ Oracle Technical Interview PYQS for beginners
Q)What is save point in Oracle database?
Solution: A savepoint in Oracle marks a specific point in a transaction, allowing partial rollback to that point without affecting the entire transaction.
Oracle Technical Interview Questions/Oracle Technical Interview Previous Year Questions/ Oracle Technical Interview PYQS for beginners
Q)Illustrate the use of the TRANSLATE function with an example.
Solution:
The TRANSLATE
function in Oracle replaces characters in a string with other characters based on their position. It substitutes each occurrence of a character in a source string with the corresponding character from a second string.
Example:
SELECT TRANSLATE(‘ORACLE’, ‘ORC’, ‘ABC’) AS result FROM dual;
Explanation:
-
The first argument is
'ORACLE'
, the string to be transformed. -
The second argument
'ORC'
specifies the characters to be replaced. -
The third argument
'ABC'
provides the corresponding replacements.