- DATA Doctionary Table:
- USER_TAB_COLUMNS: All table names with column names and data types.
- USER_CONSTRAINTS: Table’s constraints name.
- USER_INDEXES: Table’s index name.
- TTTT
- FUNCTION:
- GREATEST(): This function will return the greatest value in a list of expressions.
- LEAST(): This function will return the smallest value in a list of expressions.
- YYYYYYYYYY
- Linewise Total Calculation: Using Analytical Functions, we can achieve this. SELECT EMPLOYEE_ID,SALARY,SUM(SALARY) OVER (ORDER BY EMPLOYEE_ID) LINE_TOTAL FROM EMPLOYEES.
- Modify the order of columns without dropping the table: ALTER TABLE EMPLOYEES_TEST MODIFY MANAGER_ID INVISIBLE; Alter TABLE EMPLOYEES_TEST MODIFY MANAGER_ID VISIBLE;
Suppose we open and start working on a cursor, and in between some records were deleted by another user from the table. Are we still able to see all the selected rows of the cursor? Answer: Yes, we are able to see all the records that are selected in the cursor, because when we open a cursor, then it will load all data into memory, and data will be viewed from memory, not the base table. But if we operate any DML operation using cursor data, then the DML operation will fail because related data will not be available on the base table. We can also prevent DML operations during cursor execution by using the For Update clause within the cursor declaration.
Private Procedure Or Private Function: A private procedure or function is only defined within the package body, and no one will be able to access it. Only other package objects will be able to use this type of procedure or function.
- What is Pragma: Prgama is a precompiler directive to instruct the compiler to compile the program unit differently for a specific functionality at the runtime. List of pragma available in Oracle (based on 18C): AUTONOMOUS_TRANSACTION,COVERAGE,DEPRECATE,EXCEPTION_INIT,INLINE,RESTRICT_REFERENCES,SERIALLY_REUSABLE,UDF.
- Table Level & Column Level Constraints: When we define a constraint in the column definition, then it will be column-level constraints, and when we define a constraint in the table level, then it will be table-level constraints. Composite constraints are now allowed in column-level constraints.
- DELETE command will be fired by DML trigger, but Truncate command will not be fired by DML trigger. The Truncate command will be fired by DDL trigger. DDL trigger will be created on schema level, and we can specify it for specific tables by using the ORA_DICT_OBJ_NAME & ORA_DICT_OBJECT_TYPE function. The syntex will be:
CREATE OR REPLACE TRIGGER T_TRUNCATE_TRG
BEFORE TRUNCATE ON SCHEMA
BEGIN
IF ORA_DICT_OBJ_NAME ='Table_name' and ORA_DICT_OBJECT_TYPE ='TABLE THEN
RAISE_APPLICATION_ERROR(-20001,'Truncation not allowed on Tables');
END IF;
END; - Hierarcial Query:
SELECT FIRST_NAME, LAST_NAME, SYS_CONNECT_BY_PATH(LAST_NAME,'->') PATH, LEVEL,CONNECT_BY_ISLEAF FROM EMPLOYEES START WITH MANAGER_ID IS NULL CONNECT BY PRIOR EMPLOYEE_ID=MANAGER_ID - Different between Delete, Truncate, & Drop.
Delete: Delete is a DML operation, and we can delete partial data by using the where clause. Deleted data can be recovered by using rollback. No impact on dependent object. This command is slower because it uses an undo segment, and triggers will get fired (on delete trigger). Deleted data is temporarily stored in the redo log.
Truncate: Truncate is a DDL (autocommit) operation. All rows will be removed and we cannot use the where clause. Data lost forever and no impact-dependent object. The truncate command is faster, and no trigger will get invoked.
Drop: DDL Command and removes the dependent object. Data can be recovered if the flashback option is on. A dependent object will have to be created. - What is implicit cursor?
Answer: An implicit cursor is a session cursor that is constructed and managed by Oracle. PL/SQL opens an implicit cursor every time when we run a SELECT or DML statement. We cannot control implicit cursor, but we can get information from its attributes.An explicit cursor is a session cursor that is constructed and managed by the user.Cursor Attributes are ISOPEN,FOUND,NOTFOUND,ROWCOUNT
- What is bulk bind?
Answer: The PL/SQL engine executes all the procedural code, and the SQL engine will execute all the SQL statements. Assigning values to PL/SQL variables that appear in SQL statements is called binding.
Bulk binding is a process in which instead of doing the binding one by one because of CONTEXT SWITCHING, the entire information from the SQL statement will be binded back to the PL/SQL variable either with a single switch or with fewer switches, and this concept is called bulk binding.
Bulk binding binds an entire collection of values at once. To implement bulk binding, Oracle provides two statements. One is called a FORALL statement, and another is called a BULK collection clause. - What is sort merge join?
Answer: A sort-merge join is a join algorithm used in Oracle to combine data from two tables based on a common join key. It's a variation of a nested loop join. - What is trigger?
- What is materialised view? can we use materialized view without materialized view log?
- In which case can we use Pragma Autonomous transactions?
- What is a save exception?
Answer: Save Exception used in FORALL statement. Using Save Exception PL/SQL does not raise an exception; instead, it saves information about the failure. After the FORALL statement is complete, PL/SQL raises a single exception for the FORALL statement. - What is Dynamic SQL? Using EXECUTE IMMEDIATE, we can use dynamic SQL.
- When do we use ref Cursor?
- What is the virtual column and syntax for that column?
- What is the difference between a nested array and a V-array?
- Did DML operations allow in materialised view?Answer: Users can perform DML operations on a writeable materialised view, but if we refresh the materialised view, then these changes are not pushed back to the master and the changes are lost in the materialised view itself.