Java Database Interview Questions

Published on June 2016 | Categories: Documents | Downloads: 48 | Comments: 0 | Views: 356
of 19
Download PDF   Embed   Report

Comments

Content

Java database interview questions
1. How do you call a Stored Procedure from JDBC? - The first step is to create a CallableStatement object. As with Statement and PreparedStatement objects, this is done with an open Connection object. A CallableStatement object contains a call to a stored procedure.
2. 3. 4. CallableStatement cs = con.prepareCall("{call SHOW_SUPPLIERS}"); ResultSet rs = cs.executeQuery();

5. Is the JDBC-ODBC Bridge multi-threaded? - No. The JDBC-ODBC Bridge does not support concurrent access from different threads. The JDBC-ODBC Bridge uses synchronized methods to serialize all of the calls that it makes to ODBC. Multi-threaded Java programs may use the Bridge, but they won’t get the advantages of multi-threading. 6. Does the JDBC-ODBC Bridge support multiple concurrent open statements per connection? - No. You can open only one Statement object per connection when you are using the JDBC-ODBC Bridge. 7. What is cold backup, hot backup, warm backup recovery? - Cold backup (All these files must be backed up at the same time, before the databaseis restarted). Hot backup (official name is ‘online backup’) is a backup taken of each tablespace while the database is running and is being accessed by the users. 8. When we will Denormalize data? - Data denormalization is reverse procedure, carried out purely for reasons of improving performance. It maybe efficient for a high-throughput system to replicate data for certain data. 9. What is the advantage of using PreparedStatement? - If we are using PreparedStatement the execution time will be less. The PreparedStatement object contains not just an SQL statement, but the SQL statement that has been precompiled. This means that when the PreparedStatement is executed,the RDBMS can just run the PreparedStatement’s Sql statement without having to compile it first. 10. What is a “dirty read”? - Quite often in database processing, we come across the situation wherein one transaction can change a value, and a second transaction can read this value before the original change has been committed or rolled back. This is known as a dirty read scenario because there is always the possibility that the first transaction may rollback the change, resulting in the second transaction having read an invalid value. While you can easily command a database to disallow dirty reads, this usually degrades the performance of your application due to the increased locking overhead. Disallowing dirty reads also leads to decreased system concurrency. 11. What is Metadata and why should I use it? - Metadata (’data about data’) is information about one of two things: Database information (java.sql.DatabaseMetaData), or Information about a specific ResultSet (java.sql.ResultSetMetaData). Use DatabaseMetaData to find information about your database, such as its capabilities and structure. Use ResultSetMetaData to find information about the results of an SQL query, such as size and types of columns

12. Different types of Transaction Isolation Levels? - The isolation level describes the degree to which the data being updated is visible to other transactions. This is important when two transactions are trying to read the same row of a table. Imagine two transactions: A and B. Here three types of inconsistencies can occur: o Dirty-read: A has changed a row, but has not committed the changes. B reads the uncommitted data but his view of the data may be wrong if A rolls back his changes and updates his own changes to the database. o Non-repeatable read: B performs a read, but A modifies or deletes that data later. If B reads the same row again, he will get different data. o Phantoms: A does a query on a set of rows to perform an operation. B modifies the table such that a query of A would have given a different result. The table may be inconsistent. TRANSACTION_READ_UNCOMMITTED : DIRTY READS, NONREPEATABLE READ AND PHANTOMS CAN OCCUR. TRANSACTION_READ_COMMITTED : DIRTY READS ARE PREVENTED, NON-REPEATABLE READ AND PHANTOMS CAN OCCUR. TRANSACTION_REPEATABLE_READ : DIRTY READS , NONREPEATABLE READ ARE PREVENTED AND PHANTOMS CAN OCCUR. TRANSACTION_SERIALIZABLE : DIRTY READS, NON-REPEATABLE READ AND PHANTOMS ARE PREVENTED. 13. What is 2 phase commit? - A 2-phase commit is an algorithm used to ensure the integrity of a committing transaction. In Phase 1, the transaction coordinator contacts potential participants in the transaction. The participants all agree to make the results of the transaction permanent but do not do so immediately. The participants log information to disk to ensure they can complete In phase 2 f all the participants agree to commit, the coordinator logs that agreement and the outcome is decided. The recording of this agreement in the log ends in Phase 2, the coordinator informs each participant of the decision, and they permanently update their resources. 14. How do you handle your own transaction ? - Connection Object has a method called setAutocommit(Boolean istrue) - Default is true. Set the Parameter to false , and begin your transaction 15. What is the normal procedure followed by a java client to access the db.? The database connection is created in 3 steps:
1. 2. 3.

Find a proper database URL Load the database driver Ask the Java DriverManager class to open a connection to your database

In java code, the steps are realized in code as follows:

Create a properly formatted JDBR URL for your database. (See FAQ on JDBC URL for more information). A JDBC URL has the form jdbc:someSubProtocol://myDatabaseServer/theDatabaseName 5. Class.forName(”my.database.driver”); 6. Connection conn = DriverManager.getConnection(”a.JDBC.URL”, “databaseLogin”,”databasePassword”); 2. What is a data source? - A DataSource class brings another level of abstraction than directly using a connection object. Data source can be referenced by JNDI. Data Source may point to RDBMS, file System , any DBMS etc. 3. What are collection pools? What are the advantages? - A connection pool is a cache of database connections that is maintained in memory, so that the connections may be reused 4. How do you get Column names only for a table (SQL Server)? Write the Query. 4. 5. 6. 7. select name from syscolumns where id=(select id from sysobjects where name='user_hdr') order by colid --user_hdr is the table name

JDBC interview questions
Thanks to Sachin Rastogi for sending in Java database interview questions. 1. What are the steps involved in establishing a JDBC connection? This action involves two steps: loading the JDBC driver and making the connection. 2. How can you load the drivers? Loading the driver or drivers you want to use is very simple and involves just one line of code. If, for example, you want to use the JDBC-ODBC Bridge driver, the following code will load it: Class.forName(”sun.jdbc.odbc.JdbcOdbcDriver”); Your driver documentation will give you the class name to use. For instance, if the class name is jdbc.DriverXYZ, you would load the driver with the following line of code: Class.forName(”jdbc.DriverXYZ”); 3. What will Class.forName do while loading drivers? It is used to create an instance of a driver and register it with the

DriverManager. When you have loaded a driver, it is available for making a connection with a DBMS. 4. How can you make the connection? To establish a connection you need to have the appropriate driver connect to the DBMS. The following line of code illustrates the general idea: String url = “jdbc:odbc:Fred”; Connection con = DriverManager.getConnection(url, “Fernanda”, “J8?); 5. How can you create JDBC statements and what are they? A Statement object is what sends your SQL statement to the DBMS. You simply create a Statement object and then execute it, supplying the appropriate execute method with the SQL statement you want to send. For a SELECT statement, the method to use is executeQuery. For statements that create or modify tables, the method to use is executeUpdate. It takes an instance of an active connection to create a Statement object. In the following example, we use our Connection object con to create the Statement object Statement stmt = con.createStatement(); 6. How can you retrieve data from the ResultSet? JDBC returns results in a ResultSet object, so we need to declare an instance of the class ResultSet to hold our results. The following code demonstrates declaring the ResultSet object rs. ResultSet rs = stmt.executeQuery(”SELECT COF_NAME, PRICE FROM COFFEES”); String s = rs.getString(”COF_NAME”); The method getString is invoked on the ResultSet object rs, so getString() will retrieve (get) the value stored in the column COF_NAME in the current row of rs. 7. What are the different types of Statements? Regular statement (use createStatement method), prepared statement (use prepareStatement method) and callable statement (use prepareCall) 8. How can you use PreparedStatement? This special type of statement is derived from class Statement.If you need a Statement object to execute many times, it will normally make sense to use a PreparedStatement object instead. The advantage to this is that in most cases, this SQL statement will be sent to the DBMS right away, where it will be compiled. As a result, the PreparedStatement object contains not just an SQL statement, but an SQL statement that has been precompiled. This means that when the PreparedStatement is executed, the DBMS can just run the PreparedStatement’s SQL statement without having to compile it first.

9. PreparedStatement updateSales = 10. con.prepareStatement(\"UPDATE COFFEES SET SALES = ? WHERE COF_NAME LIKE ?\");

11. What does setAutoCommit do? When a connection is created, it is in auto-commit mode. This means that each individual SQL statement is treated as a transaction and will be automatically committed right after it is executed. The way to allow two or more statements to be grouped into a transaction is to disable auto-commit mode: con.setAutoCommit(false); Once auto-commit mode is disabled, no SQL statements will be committed until you call the method commit explicitly.
con.setAutoCommit(false); PreparedStatement updateSales = con.prepareStatement( \"UPDATE COFFEES SET SALES = ? WHERE COF_NAME LIKE ?\"); updateSales.setInt(1, 50); updateSales.setString(2, \"Colombian\"); updateSales.executeUpdate(); PreparedStatement updateTotal = con.prepareStatement(\"UPDATE COFFEES SET TOTAL = TOTAL + ? WHERE COF_NAME LIKE ?\"); updateTotal.setInt(1, 50); updateTotal.setString(2, \"Colombian\"); updateTotal.executeUpdate(); con.commit(); con.setAutoCommit(true);

12. How do you call a stored procedure from JDBC? The first step is to create a CallableStatement object. As with Statement an and PreparedStatement objects, this is done with an open Connection object. A CallableStatement object contains a call to a stored procedure.
13. CallableStatement cs = con.prepareCall(\"{call SHOW_SUPPLIERS}\"); 14. ResultSet rs = cs.executeQuery();

15. How do I retrieve warnings? SQLWarning objects are a subclass of SQLException that deal with database access warnings. Warnings do not stop the execution of an application, as exceptions do; they simply alert the user that something did not happen as planned. A warning can be reported on a Connection object, a Statement object (including PreparedStatement and CallableStatement objects), or a ResultSet object. Each of these classes has a getWarnings method, which you must invoke in order to see the first warning reported on the calling object:
16. SQLWarning warning = stmt.getWarnings(); 17. if (warning != null) 18. { 19. System.out.println(\"n---Warning---n\");

20. while (warning != null) 21. { 22. System.out.println(\"Message: \" + warning.getMessage()); 23. System.out.println(\"SQLState: \" + warning.getSQLState()); 24. System.out.print(\"Vendor error code: \"); 25. System.out.println(warning.getErrorCode()); 26. System.out.println(\"\"); 27. warning = warning.getNextWarning(); 28. } 29. }

30. How can you move the cursor in scrollable result sets? One of the new features in the JDBC 2.0 API is the ability to move a result set’s cursor backward as well as forward. There are also methods that let you move the cursor to a particular row and check the position of the cursor. Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_SENSI TIVE, ResultSet.CONCUR_READ_ONLY); ResultSet srs = stmt.executeQuery(”SELECT COF_NAME, PRICE FROM COFFEES”); The first argument is one of three constants added to the ResultSet API to indicate the type of a ResultSet object: TYPE_FORWARD_ONLY, TYPE_SCROLL_INSENSITIVE , and TYPE_SCROLL_SENSITIVE. The second argument is one of two ResultSet constants for specifying whether a result set is readonly or updatable: CONCUR_READ_ONLY and CONCUR_UPDATABLE. The point to remember here is that if you specify a type, you must also specify whether it is read-only or updatable. Also, you must specify the type first, and because both parameters are of type int , the compiler will not complain if you switch the order. Specifying the constant TYPE_FORWARD_ONLY creates a nonscrollable result set, that is, one in which the cursor moves only forward. If you do not specify any constants for the type and updatability of a ResultSet object, you will automatically get one that is TYPE_FORWARD_ONLY and CONCUR_READ_ONLY. 31. What’s the difference between TYPE_SCROLL_INSENSITIVE , and TYPE_SCROLL_SENSITIVE? You will get a scrollable ResultSet object if you specify one of these ResultSet constants.The difference between the two has to do with whether a result set reflects changes that are made to it while it is open and whether certain methods can be called to detect these changes. Generally speaking, a result set that is TYPE_SCROLL_INSENSITIVE does not reflect changes made while it is still

open and one that is TYPE_SCROLL_SENSITIVE does. All three types of result sets will make changes visible if they are closed and then reopened:
32. Statement stmt = 33. con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); 34. ResultSet srs = 35. stmt.executeQuery(\"SELECT COF_NAME, PRICE FROM COFFEES\"); 36. srs.afterLast(); 37. while (srs.previous()) 38. { 39. String name = srs.getString(\"COF_NAME\"); 40. float price = srs.getFloat(\"PRICE\"); 41. System.out.println(name + \" \" + price); 42. }

43. How to Make Updates to Updatable Result Sets? Another new feature in the JDBC 2.0 API is the ability to update rows in a result set using methods in the Java programming language rather than having to send an SQL command. But before you can take advantage of this capability, you need to create a ResultSet object that is updatable. In order to do this, you supply the ResultSet constant CONCUR_UPDATABLE to the createStatement method.
44. Connection con = 45. DriverManager.getConnection(\"jdbc:mySubprotocol:mySubNa me\"); 46. Statement stmt = 47. con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE); 48. ResultSet uprs = 49. stmt.executeQuery(\"SELECT COF_NAME, PRICE FROM COFFEES\");

Oracle interview questions
1. What’s the command to see the current user name? Sql> show user; 2. What’s the command to change the SQL prompt name? SQL> set sqlprompt “database-1 > ” database-1 > database-1 > 3. How do you switch to DOS prompt from SQL prompt? SQL> host

4. How do I eliminate duplicate rows in an Oracle database? SQL> delete from table_name where rowid not in (select max(rowid) from table group by duplicate_values_field_name); or SQL> delete duplicate_values_field_name dv from table_name ta where rowid < (select min(rowid) from table_name tb where ta.dv=tb.dv); 5. How do I display row number with records? Use the row-num pseudocolumn with query, like SQL> select rownum, ename from emp; 6. How do you display the records within a given range? select rownum, empno, ename from emp where rowid in (select rowid from emp where rownum < =&rangeend minus select rowid from emp where rownum<&rangebegin); 7. The NVL function only allows the same data type. But here’s the task: if the commission field is null, then the text “Not Applicable” should be displayed, instead of blank space. How do you write the query? SQL> select nvl(to_char(comm.),’Not Applicable’) from emp; 8. Explain explicit cursor attributes. There are four cursor attributes used in Oracle: cursor_name%Found, cursor_name%NOTFOUND, cursor_name %ROWCOUNT, cursor_name%ISOPEN 9. Explain implicit cursor attributes. Same as explicit cursor but prefixed by the word SQL: SQL%Found, SQL%NOTFOUND, SQL%ROWCOUNT, SQL %ISOPEN 10. How do you view version information in Oracle? SQL> select banner from $version;

1. we can find the second highest sal in the following way: select level,max(sal) from emp where level=2 connect by prior sal>sal group by level; here connect by is special construction in Oracle to view data in tree manner and can take the values any values from any level..

PL/SQL interview qiuestions
1. Which of the following statements is true about implicit cursors? 1. Implicit cursors are used for SQL statements that are not named. 2. Developers should use implicit cursors with great care. 3. Implicit cursors are used in cursor for loops to handle data processing. 4. Implicit cursors are no longer a feature in Oracle. 2. Which of the following is not a feature of a cursor FOR loop? 1. Record type declaration. 2. Opening and parsing of SQL statements. 3. Fetches records from cursor. 4. Requires exit condition to be defined. 3. A developer would like to use referential datatype declaration on a variable. The variable name is EMPLOYEE_LASTNAME, and the corresponding table and column is EMPLOYEE, and LNAME, respectively. How would the developer define this variable using referential datatypes? 1. Use employee.lname%type. 2. Use employee.lname%rowtype. 3. Look up datatype for EMPLOYEE column on LASTNAME table and use that. 4. Declare it to be type LONG. 4. Which three of the following are implicit cursor attributes? 1. %found 2. %too_many_rows 3. %notfound 4. %rowcount 5. %rowtype

5. If left out, which of the following would cause an infinite loop to occur in a simple loop? 1. LOOP 2. END LOOP 3. IF-THEN 4. EXIT 6. Which line in the following statement will produce an error? 1. cursor action_cursor is 2. select name, rate, action 3. into action_record 4. from action_table; 5. There are no errors in this statement. 7. The command used to open a CURSOR FOR loop is 1. open 2. fetch 3. parse 4. None, cursor for loops handle cursor opening implicitly. 8. What happens when rows are found using a FETCH statement 1. It causes the cursor to close 2. It causes the cursor to open 3. It loads the current row values into variables 4. It creates the variables to hold the current row values 9. Read the following code:
10. CREATE OR REPLACE PROCEDURE find_cpt 11. (v_movie_id {Argument Mode} NUMBER, v_cost_per_ticket {argument mode} NUMBER) 12. IS 13. BEGIN 14. IF v_cost_per_ticket > 8.5 THEN 15. SELECT cost_per_ticket 16. INTO v_cost_per_ticket 17. FROM gross_receipt 18. WHERE movie_id = v_movie_id; 19. END IF; 20. END;

Which mode should be used for V_COST_PER_TICKET? 1. IN 2. OUT 3. RETURN 4. IN OUT 21. Read the following code:
22. CREATE OR REPLACE TRIGGER update_show_gross 23. {trigger information} 24. BEGIN 25. {additional code} 26. END;

The trigger code should only execute when the column, COST_PER_TICKET, is greater than $3. Which trigger information will you add? 1. WHEN (new.cost_per_ticket > 3.75) 2. WHEN (:new.cost_per_ticket > 3.75 3. WHERE (new.cost_per_ticket > 3.75) 4. WHERE (:new.cost_per_ticket > 3.75) 27. What is the maximum number of handlers processed before the PL/SQL block is exited when an exception occurs? 1. Only one 2. All that apply 3. All referenced 4. None 28. For which trigger timing can you reference the NEW and OLD qualifiers? 1. Statement and Row 2. Statement only 3. Row only 4. Oracle Forms trigger 29. Read the following code:
30. CREATE OR REPLACE FUNCTION get_budget(v_studio_id IN NUMBER) 31. RETURN number IS 32. 33. v_yearly_budget NUMBER; 34. 35. BEGIN 36. SELECT yearly_budget 37. INTO v_yearly_budget 38. FROM studio 39. WHERE id = v_studio_id; 40. 41. RETURN v_yearly_budget; 42. END;

Which set of statements will successfully invoke this function within SQL*Plus? 1. VARIABLE g_yearly_budget NUMBER EXECUTE g_yearly_budget := GET_BUDGET(11); 2. VARIABLE g_yearly_budget NUMBER EXECUTE :g_yearly_budget := GET_BUDGET(11); 3. VARIABLE :g_yearly_budget NUMBER EXECUTE :g_yearly_budget := GET_BUDGET(11); 4. VARIABLE g_yearly_budget NUMBER :g_yearly_budget := GET_BUDGET(11);
43. CREATE OR REPLACE PROCEDURE update_theater 44. (v_name IN VARCHAR v_theater_id IN NUMBER) IS 45. BEGIN 46. UPDATE theater

47. SET name = v_name 48. WHERE id = v_theater_id; 49. END update_theater;

50. When invoking this procedure, you encounter the error:
ORA-000: Unique constraint(SCOTT.THEATER_NAME_UK) violated.

How should you modify the function to handle this error? 1. An user defined exception must be declared and associated with the error code and handled in the EXCEPTION section. 2. Handle the error in EXCEPTION section by referencing the error code directly. 3. Handle the error in the EXCEPTION section by referencing the UNIQUE_ERROR predefined exception. 4. Check for success by checking the value of SQL%FOUND immediately after the UPDATE statement. 51. Read the following code:
52. 53. 54. 55. 56. 57. 58. 59. 60. CREATE OR REPLACE PROCEDURE calculate_budget IS v_budget studio.yearly_budget%TYPE; BEGIN v_budget := get_budget(11); IF v_budget < 30000 THEN set_budget(11,30000000); END IF; END;

You are about to add an argument to CALCULATE_BUDGET. What effect will this have? 1. The GET_BUDGET function will be marked invalid and must be recompiled before the next execution. 2. The SET_BUDGET function will be marked invalid and must be recompiled before the next execution. 3. Only the CALCULATE_BUDGET procedure needs to be recompiled. 4. All three procedures are marked invalid and must be recompiled. 61. Which procedure can be used to create a customized error message? 1. RAISE_ERROR 2. SQLERRM 3. RAISE_APPLICATION_ERROR 4. RAISE_SERVER_ERROR 62. The CHECK_THEATER trigger of the THEATER table has been disabled. Which command can you issue to enable this trigger? 1. ALTER TRIGGER check_theater ENABLE; 2. ENABLE TRIGGER check_theater; 3. ALTER TABLE check_theater ENABLE check_theater; 4. ENABLE check_theater; 63. Examine this database trigger
64. CREATE OR REPLACE TRIGGER prevent_gross_modification

65. {additional trigger information} 66. BEGIN 67. IF TO_CHAR(sysdate, DY) = MON 68. THEN 69. RAISE_APPLICATION_ERROR(-20000,Gross receipts cannot be deleted on Monday); 70. END IF; 71. END;

This trigger must fire before each DELETE of the GROSS_RECEIPT table. It should fire only once for the entire DELETE statement. What additional information must you add? 1. BEFORE DELETE ON gross_receipt 2. AFTER DELETE ON gross_receipt 3. BEFORE (gross_receipt DELETE) 4. FOR EACH ROW DELETED FROM gross_receipt 72. Examine this function:
73. 74. 75. 76. 77. 78. 79. 80. 81. 82. 83. 84. 85. 86. 87. CREATE OR REPLACE FUNCTION set_budget (v_studio_id IN NUMBER, v_new_budget IN NUMBER) IS BEGIN UPDATE studio SET yearly_budget = v_new_budget WHERE id = v_studio_id; IF SQL%FOUND THEN RETURN TRUEl; ELSE RETURN FALSE; END IF; COMMIT; END;

Which code must be added to successfully compile this function? 1. Add RETURN right before the IS keyword. 2. Add RETURN number right before the IS keyword. 3. Add RETURN boolean right after the IS keyword. 4. Add RETURN boolean right before the IS keyword. 88. Under which circumstance must you recompile the package body after recompiling the package specification? 1. Altering the argument list of one of the package constructs 2. Any change made to one of the package constructs 3. Any SQL statement change made to one of the package constructs 4. Removing a local variable from the DECLARE section of one of the package constructs 89. Procedure and Functions are explicitly executed. This is different from a database trigger. When is a database trigger executed? 1. When the transaction is committed

2. During the data manipulation statement 3. When an Oracle supplied package references the trigger 4. During a data manipulation statement and when the transaction is committed 90. Which Oracle supplied package can you use to output values and messages from database triggers, stored procedures and functions within SQL*Plus? 1. DBMS_DISPLAY 2. DBMS_OUTPUT 3. DBMS_LIST 4. DBMS_DESCRIBE 91. What occurs if a procedure or function terminates with failure without being handled? 1. Any DML statements issued by the construct are still pending and can be committed or rolled back. 2. Any DML statements issued by the construct are committed 3. Unless a GOTO statement is used to continue processing within the BEGIN section, the construct terminates. 4. The construct rolls back any DML statements issued and returns the unhandled exception to the calling environment. 92. Examine this code
93. BEGIN 94. theater_pck.v_total_seats_sold_overall := theater_pck.get_total_for_year; 95. END;

For this code to be successful, what must be true? 1. Both the V_TOTAL_SEATS_SOLD_OVERALL variable and the GET_TOTAL_FOR_YEAR function must exist only in the body of the THEATER_PCK package. 2. Only the GET_TOTAL_FOR_YEAR variable must exist in the specification of the THEATER_PCK package. 3. Only the V_TOTAL_SEATS_SOLD_OVERALL variable must exist in the specification of the THEATER_PCK package. 4. Both the V_TOTAL_SEATS_SOLD_OVERALL variable and the GET_TOTAL_FOR_YEAR function must exist in the specification of the THEATER_PCK package. 96. A stored function must return a value based on conditions that are determined at runtime. Therefore, the SELECT statement cannot be hardcoded and must be created dynamically when the function is executed. Which Oracle supplied package will enable this feature? 1. DBMS_DDL 2. DBMS_DML 3. DBMS_SYN 4. DBMS_SQL

SQL interview questions
Thanks to Sachin Rastogi for posting these. 1. Which of the following statements contains an error? 1. SELECT * FROM emp WHERE empid = 493945; 2. SELECT empid FROM emp WHERE empid= 493945; 3. SELECT empid FROM emp; 4. SELECT empid WHERE empid = 56949 AND lastname = ‘SMITH’; 2. Which of the following correctly describes how to specify a column alias? 1. Place the alias at the beginning of the statement to describe the table. 2. Place the alias after each column, separated by white space, to describe the column. 3. Place the alias after each column, separated by a comma, to describe the column. 4. Place the alias at the end of the statement to describe the table. 3. The NVL function 1. Assists in the distribution of output across multiple columns. 2. Allows the user to specify alternate output for non-null column values. 3. Allows the user to specify alternate output for null column values. 4. Nullifies the value of the column output. 4. Output from a table called PLAYS with two columns, PLAY_NAME and AUTHOR, is shown below. Which of the following SQL statements produced it? PLAY_TABLE ————————————“Midsummer Night’s Dream”, SHAKESPEARE “Waiting For Godot”, BECKETT “The Glass Menagerie”, WILLIAMS 1. SELECT play_name || author FROM plays; 2. SELECT play_name, author FROM plays; 3. SELECT play_name||’, ‘ || author FROM plays; 4. SELECT play_name||’, ‘ || author PLAY_TABLE FROM plays; 5. Issuing the DEFINE_EDITOR=”emacs” will produce which outcome? 1. The emacs editor will become the SQL*Plus default text editor. 2. The emacs editor will start running immediately. 3. The emacs editor will no longer be used by SQL*Plus as the default text editor. 4. The emacs editor will be deleted from the system.

6. The user issues the following statement. What will be displayed if the EMPID selected is 60494? SELECT DECODE(empid,38475, “Terminated”,60494, “LOA”, “ACTIVE”) FROM emp; 1. 60494 2. LOA 3. Terminated 4. ACTIVE 7. SELECT (TO_CHAR(NVL(SQRT(59483), “INVALID”)) FROM DUAL is a valid SQL statement. 1. TRUE 2. FALSE 8. The appropriate table to use when performing arithmetic calculations on values defined within the SELECT statement (not pulled from a table column) is 1. EMP 2. The table containing the column values 3. DUAL 4. An Oracle-defined table 9. Which of the following is not a group function? 1. avg( ) 2. sqrt( ) 3. sum( ) 4. max( ) 10. Once defined, how long will a variable remain so in SQL*Plus? 1. Until the database is shut down 2. Until the instance is shut down 3. Until the statement completes 4. Until the session completes 11. The default character for specifying runtime variables in SELECT statements is 1. Ampersand 2. Ellipses 3. Quotation marks 4. Asterisk 12. A user is setting up a join operation between tables EMP and DEPT. There are some employees in the EMP table that the user wants returned by the query, but the employees are not assigned to departments yet. Which SELECT statement is most appropriate for this user? 1. select e.empid, d.head from emp e, dept d; 2. select e.empid, d.head from emp e, dept d where e.dept# = d.dept#; 3. select e.empid, d.head from emp e, dept d where e.dept# = d.dept# (+); 4. select e.empid, d.head from emp e, dept d where e.dept# (+) = d.dept#;

13. Developer ANJU executes the following statement: CREATE TABLE animals AS SELECT * from MASTER.ANIMALS; What is the effect of this statement? 1. A table named ANIMALS will be created in the MASTER schema with the same data as the ANIMALS table owned by ANJU. 2. A table named ANJU will be created in the ANIMALS schema with the same data as the ANIMALS table owned by MASTER. 3. A table named ANIMALS will be created in the ANJU schema with the same data as the ANIMALS table owned by MASTER. 4. A table named MASTER will be created in the ANIMALS schema with the same data as the ANJU table owned by ANIMALS. 14. User JANKO would like to insert a row into the EMPLOYEE table, which has three columns: EMPID, LASTNAME, and SALARY. The user would like to enter data for EMPID 59694, LASTNAME Harris, but no salary. Which statement would work best? 1. INSERT INTO employee VALUES (59694,’HARRIS’, NULL); 2. INSERT INTO employee VALUES (59694,’HARRIS’); 3. INSERT INTO employee (EMPID, LASTNAME, SALARY) VALUES (59694,’HARRIS’); 4. INSERT INTO employee (SELECT 59694 FROM ‘HARRIS’); 15. Which three of the following are valid database datatypes in Oracle? (Choose three.) 1. CHAR 2. VARCHAR2 3. BOOLEAN 4. NUMBER 16. Omitting the WHERE clause from a DELETE statement has which of the following effects? 1. The delete statement will fail because there are no records to delete. 2. The delete statement will prompt the user to enter criteria for the deletion 3. The delete statement will fail because of syntax error. 4. The delete statement will remove all records from the table. 17. Creating a foreign-key constraint between columns of two tables defined with two different datatypes will produce an error. 1. TRUE 2. FALSE 18. Dropping a table has which of the following effects on a nonunique index created for the table? 1. No effect. 2. The index will be dropped. 3. The index will be rendered invalid. 4. The index will contain NULL values. 19. To increase the number of nullable columns for a table, 1. Use the alter table statement. 2. Ensure that all column values are NULL for all rows. 3. First increase the size of adjacent column datatypes, then add the column.

4. Add the column, populate the column, then add the NOT NULL constraint. 20. Which line of the following statement will produce an error? 1. CREATE TABLE goods 2. (good_no NUMBER, 3. good_name VARCHAR2 check(good_name in (SELECT name FROM avail_goods)), 4. CONSTRAINT pk_goods_01 5. PRIMARY KEY (goodno)); 6. There are no errors in this statement. 21. MAXVALUE is a valid parameter for sequence creation. 1. TRUE 2. FALSE 22. Which of the following lines in the SELECT statement below contain an error? 1. SELECT DECODE(empid, 58385, “INACTIVE”, “ACTIVE”) empid 2. FROM emp 3. WHERE SUBSTR(lastname,1,1) > TO_NUMBER(’S') 4. AND empid > 02000 5. ORDER BY empid DESC, lastname ASC; 6. There are no errors in this statement. 23. Which function below can best be categorized as similar in function to an IFTHEN-ELSE statement? 1. SQRT 2. DECODE 3. NEW_TIME 4. ROWIDTOCHAR 24. Which two of the following orders are used in ORDER BY clauses? (choose two) 1. ABS 2. ASC 3. DESC 4. DISC 25. You query the database with this command SELECT name FROM employee WHERE name LIKE ‘_a%’; Which names are displayed? 1. 2. 3. 4. 5. Names starting with “a” Names starting with “aR or “A” Names containing “aR as second character

6. Names containing “aR 7. as any letter except the first first pan thisukoni 2 spoons oil vayse dhantlo peanuts(verusanga pappu) ,enddu mirapakayalu 4 avi ne quantity butti,jilakara konchem,dhaniyalu konchem,chini vulipaye 1 r 2 as u like,coconut konchem taste ki anniti baga oil lo fry chey last lo konchem chinthapandu vey pan dhinche mundhu taste saripada vey.....anni aaraka mixe vey lite ga water posi malli mixe vaye mari akkuva poyaku water,konchem mudhaga vunde tattlu chusuko k na.....mix ayna tharvatha salt vayse mudha la kalupu ko...next gutthi vankaya 4 parts ga cut cheysthamu ....avi oil lo defry cheyali oil lo ala vayse thiyali(30 seconds) akkuva saypu vunchavadhu oil lo defry cheysetappudu...ave ayepoyaka cheysi vunchina powder ni stuff chey okkaka guthi vankaya lo jagratha ga ...oo speed ga ayepovali ani gattiga dhurchavadhu chinna dhurchu vankaya lo baga patte tatlu dhurchu chinnaga dhurchu ...anni stuff cheyattum ayepoyaka malli pan thiskoni 2 spoons oil, onions ,chillies fry,kariveypaku cheysi tharvatha e vankaya anni arrange chey pan lo,plate petti 2 min okasari thipputhu vundhu vankayani change cheysthu vundu anni sides vudakali kadha,spoon tho chinnaga atu etu change cheysthu vundu....5 min ayyaka anni stuff cheysaka inka powder migilthe vankayalu fry cheysthunanu panlo vaysi 1/2 cup water posi vudi ki nuntha say pu chusthu vundu last vunte corriader leaves vaye,,,baguntadhi....OVER

Sponsor Documents

Or use your account on DocShare.tips

Hide

Forgot your password?

Or register your new account on DocShare.tips

Hide

Lost your password? Please enter your email address. You will receive a link to create a new password.

Back to log-in

Close