Oracle 1
Oracle 1
Oracle 1
No Need to declare implicit cursors, oracle creates, process and closes automatically. In explicit cursor it should be declared and closed by the user.
Every record in a database is uniquely identified by system generated value called Rowid. It Is a 18 character hexma decimal value. These Rowid's are physically existence. It is a pseduocolumn which generates the sequence of numeric values based on the position of the records in the output. These ROWNUM'S logically generated.
Cursors are used for storing, managing and retrieving data. Each time we fetch a row from the cursor, it result a network round trip, where as a normal select statement query make only one round trip.
How we can create a table in PL/SQL block. insert records into it???
l_stmt VARCHAR2(200); BEGIN l_stmt := 'create table '|| p_table_name || ' as (select * from emp )'; execute IMMEDIATE l_stmt; END;
Name the tables where characteristics of Package, procedure and functions are stored ?
User_objects, User_Source and User_error.
Can Commit,Rollback ,Savepoint be used in Database Triggers?If yes than HOW? If no Why?With Reasons
No, Once trigger execution is complete then only a transaction can be said as complete and then only commit should take place. Otherwise deadlock situation occur as a result we will get a error in the transaction.
In pl/sql functions what is use of out parameter even though we have return statement.
With out parameters you can get the more than one out values in the calling program. It is recommended not to use out parameters in functions. If you need more than one out values then use procedures instead of functions.
How to avoid using cursors? What to use instead of cursor and in what cases to do so?
loop dbms_output.put_line(emprec.empno); end loop; no exit statement needed implicit open,fetch,close occurs
When the number of rows returned by query is small (around 100) then explicit cursor can be avoided for emprec in (select * from emp)
% ROWTYPE is to be used whenever query returns a entire row of a table or view. TYPE rec RECORD is to be used whenever query returns columns of different table or views and variables. E.g. TYPE r_emp is RECORD (eno emp.empno% type,ename emp ename %type ); e_rec emp% ROWTYPE cursor c1 is select empno,deptno from emp; e_rec c1 %ROWTYPE.
A table can have only one PRIMARY KEY whereas there can be any number of UNIQUE keys. The columns that compose PK are automatically define NOT NULL, whereas a column that compose a UNIQUE is not automatically defined to be mandatory must also specify the column is NOT NULL.
SELECT DISTINCT (a.sal) FROM EMP A WHERE 3 = (SELECT COUNT (DISTINCT (b.sal)) FROM EMP B WHERE a.sal<=b.sal);
What is Raise_application_error ?
The RAISE_APPLICATION_ERROR is a procedure defined by Oracle that allows the developer to raise an exception and associate an error number and message with the procedure other than just Oracle errors. EXCEPTION when NO_DATA_FOUND then RAISE_APPLICATION_ERROR(-20201,'manager is not a valid employee');
SELECT * FROM (SELECT ENAME,ROWNUM RN FROM EMP WHERE ROWNUM < 101) WHERE RN between 91 and 100; SELECT * FROM tableX WHERE rowid in (SELECT rowid FROM tableX WHERE rownum <= 7 MINUS SELECT rowid FROM tableX WHERE rownum < 5);
SELECT ename, CASE WHEN sal>1000 THEN 'Over paid' ELSE 'Under paid' END FROM emp;
? Indexing ? ? Query ?
Indexing is a technique for determining how quickly specific data can be found.
Query is the commands used to communicate with data base. The query language can be classified into data
? Correlated subquery ?
Query that is executed for every row of the parent is correlated subquery. And it is used to bring back a set of rows to be used by the parent query. Nt:- Columns from the subquery cannot be referenced anywhere else in the parent query
? Trigger?
It is an PL/SQL block that can be created to automatically execute for insert, update, and delete statements against a table.
? Stored-procedures? Advantages ?.
It is a set of SQL Statements that perform a user defined operation and returns the result to the client. It reduce network traffic
? Normalization ?
It is a process of analysing the given relation schemas based on their Functional Dependencies (FDs) and primary key to achieve the properties Minimizing redundancy Minimizing insertion, deletion and update anomalies.
If any Error occurs, than exception handler allows to continue further execution, if no critical issue that can terminate the process. Enables in the declarations area of subprogram specifications. There is an exception named OTHERS that catch all other exceptions which is not defined internally/user defined
FROM WHERE
TRUNCATE is DDL command and DELETE is DML. DELETE can be rolled back. We can use WHERE in delete
? DESC in SQL?
Describe schema and select rows from table in descending order. SELECT * FROM EMP ORDER BY ENAME DESC
? CASCADE CONSTRAINTS?
Is used with the DROP command, to drop a parent table even when a child table exists.
DBA
29. When a user process fails, what background process cleans up after it? PMON 31. How would you determine what sessions are connected and what resources they are waiting for? Use of V$SESSION and V$SESSION_WAIT 32. Describe what redo logs are. Redo logs are logical and physical structures that are designed to hold all the changes made to a database and are intended to aid in the recovery of a database. 33. How would you force a log switch? ALTER SYSTEM SWITCH LOGFILE; 37. Name a tablespace automatically created when you create a database. The SYSTEM tablespace. 38. When creating a user, what permissions must you grant to allow them to connect to the database? Grant the CONNECT to the user. 43. How would you determine who has added a row to a table? Turn on fine grain auditing for the table. 44. How can you rebuild an index? ALTER INDEX <index_name> REBUILD; 47. How can you gather statistics on a table? The ANALYZE command. 48. How can you enable a trace for a session? Use the DBMS_SESSION.SET_SQL_TRACE or Use ALTER SESSION SET SQL_TRACE = TRUE; 50. Name two files used for network connection to a database. TNSNAMES.ORA and SQLNET.ORA ============ DB_LINK====================== drop public database link GBMTOFINACLE; Database link dropped. create public database link GBMTOFINACLE connect to GBM identified by gbm using 'GBMMIG1'; ============ DB_LINK======================