PLSQL Developer Interview Questions

Plsql Interview Questions:

1.Difference Between ROWID and ROWNUMBER

ROWIDROW NUMBER
Row id is a static value (always same row has same rowed)Row number is not a static values(row number changes dynamically based on select statement)
Row id is hexadecimal valueRow number is numeric value
Row id is combination of object id, file number, block number, row numberRow number is temporary number based on select statement
Oracle automatically generate row id when user insert new row into tableRow number will be generated based output of select statement
Row id will be stored in databaseRow number won’t be stored in the database

2.Difference between Truncate and Delete

TRUNCATEDELETE
Truncate removes all the rows from the tableDelete removes all rows and selected rows from the table
Truncate won’t support where clauseDelete supports where clause
Truncate is ddl commandDelete is dml command
After truncate we don’t need to give and tcl command as truncate is ddl command and all ddl commands are auto commitAfter delete we need to give tcl command like commit or rollback
Truncate is faster than delete as it doesn’t have undo segmentDelete is slower as it uses undo segment
Truncate clears the memory allocated to rows(internal memory will be cleared )Delete won’t clear the internal memory and internal memory will be still exists
Truncate resets the high level water mark and reclaims the space used by the tableDelete won’t reset the high level water mark and won’t reclaims the space used by the table

3.Difference between Case and Decode

CASEDECODE
Case is statement and it provides if else type logicDecode is function and it provides if else type logic
Case can be used along with sql statements and without sql statements also we can use caseDecode can be used in sql statements only
Case supports operators like <,>,<=,>=,like, in, between, notDecode won’t support any operators
By using case we can assign any value to a variable in the plsql blockDecode can’t be used inside plsql block
Case allows only one data type in single statementDecode allows any no of data types in single statement
Case is easy to understandDecode is difficult to understand

4.Difference between where and having

WHEREHAVING
Where clause is used to get specific data from the tableHaving clause is used to apply conditions on grouped data
Where clause filters row dataHaving clause filters grouped data
Where conditions are applied before group by clauseHaving conditions are applied after group by clause
Where won’t support aggregate functionsHaving clause supports aggregate functions
After where clause we will write normal columns onlyAfter having clause we can write aggregate functions only
By using where clause we can join any number of tablesBy using having clause we can’t join tables

5.Difference between Table and View

TABLEVIEW
Table is combination of rows and columnsView is stored select statement
Table occupy some space in databaseView won’t occupy any space in database
Table stores some data in their selfView is a logical component(it won’t occupy any space and stores only select statement)
Table is the preliminary storage object for storing data and information in RDBMSView won’t contain a set of values in database
Table is collection of related data and it consists of rows and columnsView is virtual table and its content depends on the query
If we apply and dml command on related view, it will impact the viewIf we apply any dml command on related table, it will impact the table
If drop the related view, it won’t impact the tableIf we drop the related table, it will impact the view and view will become invalid
Table can have maximum of 1000 columnsView can have maximum of 999 columns
To see tables in our schema:
Select * from user_tabs
To see views in our schema:
Select * from user_views

6. Difference between Synonym and View

SYNONYMVIEW
Synonym will hide the original name of the object. It is alias name of the object.View is stored select statement
Synonym will be created on only one objectView can be created and any no. of objects
Synonym will be created on tables, views, functions, procedures…Views can be created on tables, views, synonyms
To see synonyms in our schema: Select * from user_synonymsTo see views in our schema: Select * from user_views
If we drop the related table, then synonym will become invalid and if we recreate the tableIf we drop the related table view will become invalid and if we recreate the table then also

7. a) What is group by clause?

  • Group by clause is used to group row based on specific column.
  • If want to write normal column along with aggregate function in select statement, then that normal column should come after group by clause in that select statement.

b) What is order by clause?

  • Order by clause is used to arrange select statement output in ascending order or descending order.
  • By default order by clause has ascending order. If want to arrange select statement output in descending order then after order by clause we need to write desc keyword.
  • We can write any no of columns in order by clause but make sure that the column that is used to sort, that column will exist in the column_list of the select statement.

C) What is having clause?

Oracle Triggers
Understanding Oracle Triggers – A Comprehensive Guide with Examples
  • Having clause is used to apply conditions to grouped data. Having clause filters grouped data.
  • Having conditions are written after group by clause. Having clause always follows group by clause.
  • After having clause we must write aggregate functions only.

8. What is view and what are the advantages of views?

  • View is stored select statement. View won’t store any data physically on it. View won’t occupy any space in the database.
  • Views can be created on tables, views, synonyms.
  • Any dml operation on the view will impact the original object.
  • If we drop the related table, view will be invalid. And if we recreate the table even then also view will be in invalid state only. If we want that view then we need to recreate or recompile it.

Advantages of views:

  • View will hide the complexity of the query.
  • It supports and provides high security while sharing selected rows/information to other users.
  • If we want to share data of more tables then we can do it simply by using as single view.
  • When the frontend resource uses the same select statement multiple times and he needs some time for it to exist in the frontend. So, instead of that, we will create a view on that query.

9. Why sequence is required?

Sequence is required to generate unique and order wise values.Sequence consists of start with, increment by, minimum value, maximum value, cycle, cache. Advantages of sequence:

  • No need to create any table for sequence.
  • If the related table is dropped, it won’t impact the sequence. • Sequence gives unique and order wise values.
  • Sequence won’t belong to any object. Disadvantages of sequence:
  • We cannot rollback sequence (we cannot get the start value again once the sequence is started.
  • Sequence doesn’t belong to any object.
  1. To get the next value of sequence: Select seq_name.nextval from dual;
  2. To get the current value of sequence: Select seq_name.curval from dual;

10. What is synonym & uses of synonym?

  • Synonym is used to share information of an object of one user to other user. And both the users should be connected to same database.
  • Synonyms can be created on tables, views, functions, procedures. One synonym can be used for only one object.
  • Synonym hides the original name of the object.
  • We can create synonym on another synonym.
  • Synonym provides high security while sharing information to other users. Synonyms are of two types.

They are 1) Private synonyms: select * from user_synonyms;

2) Public synonyms: select * from all_synonyms;

Oracle Interview Questions
Master Oracle Interview Questions: Key Concepts & Examples for 2024

If the related table is dropped then synonym will become invalid. And if the table is recreated then the synonym will be in valid state. No need to recompile or recreate it.

A synonym is nothing but alias name of the original object. Whatever changes are done on synonym that will impact on the original object and whatever changes are done on the original object that will impact on the synonym.

An experienced PostgreSQL DBA/SQL developer with years of expertise in designing and implementing robust database solutions. Proficient in writing complex queries, developing stored procedures, and conducting performance tuning to deliver highly efficient data-driven applications that meet business requirements. If any queries feel free to contact us at ganeshpudi12@gmail.com

4 thoughts on “PLSQL Developer Interview Questions”

Leave a Reply

Home
SQL
PLSQL
Interview Q&A