SQL Multiple Choice Questions

Q1. Which of the following statements contains an error?
A) select * from emp where empid = 493945;
B) select empid from emp where empid = 493945;
C) select empid from emp;
D) select empid where empid = 56949 and lastname = 'SMITH';
Q2. Which of the following correctly describes how to specify a column alias?
A) Place the alias at the beginning of the statement to describe the table
B) Place the alias after each column, seperated by white space, to describe the column
C) Place the alias after each column, seperated by a comma, to describe the column
D) Place the alias at the end of the statement to describe the table
Q3. The NVL function helps to?
A) Assists in the distribution of output across multiple columns
B) Allows the user to specify alternate output for non-null column values
C) Allows the user to specify alternate output for null column values
D) Nullifies the value of the column output
Q4. 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
A) select play_name || author from plays;
B) select play_name, author from plays;
C) select play_name ||', '|| author from plays;
D) select play_name ||', '|| author play_table from plays;
Q5. Issuing the DEFINE_Editor = "emacs" will produce which outcome?
A) The emacs editor will become the SQL * Plus default editor
B) The emacs editor will start running immediately
C) The emacs editor will no longer beused by SQL * Plus as the default text editor
D) The emacs editor will be deleted from the system
Q6. 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;
A) 60494
B) LOA
C) Terminated
D) Active
Q7. Select (TO_CHAR(NVL(SQRT(59483), "INVALID")) FROM DUAL is a valid SQL statement?
A) True
B) False
Q8. The appropriate table to use when performing arithmetic calculations on values defined within the select statement (not pulled from a table column) is
A) EMP
B) The table containing the column values
C) DUAL
D) An Oracle-defined table
Q9. Which of the following is not a group function?
A) avg()
B) sqrt()
C) sum()
D) max()
Q10. Once defined, how long will a variable remain so in SQL * Plus?
A) Until the database is shut down
B) Until the instance is shut down
C) Until the statement completes
D) Until the session completes
Q11. The default character for specifying runtime variables in select statements is
A) Ampersand
B) Ellipses
C) Quotation marks
D) Asterisk
Q12. 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 to returned by the query, but the employees are not assigned to departments yet. Which select statement is most appropriate for this user?
A) select e.empid, d.head from emp e, dept d;
B) select e.empid, d.head from emp e, dept d where e.dept# = d.dept#;
C) select e.empid, d.head from emp e, dept d where e.dept# = d.dept#(+);
D) select e.empid, d.head from emp e, dept d where e.dept#(+) = d.dept#;
Q13. Developer ANJU executes the following statement: Create Table animals as select * from MASTER.ANIMALS; What is the effect of this statement?
A) A table named ANIMALS will be created in the MASTER schema with the same data as the ANIMALS table owned by ANJU
B) A table named ANJU will be created in the ANIMALS schema with the same data as the ANIMALS table owned by MASTER
C) A table named ANIMALS will be created in the ANJU schema with the same data as the ANIMALS table owned by MASTER
D) A table named MASTER will be created in the ANIMALS schema with the same data as the ANJU table owned by ANIMALS
Q14. 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 596694, LASTNAME Harris, but no salary. Which statement would work best?
A) INSERT INTO employee VALUES (59694, 'HARRIS', NULL);
B) INSERT INTO employee VALUES (59694, 'HARRIS');
C) INSERT INTO employee (EMPID, LASTNAME, SALARY) VALUES (59694, 'HARRIS');
D) INSERT INTO employee (SELECT 59694 FROM 'HARRIS');
Q15. Which three of the following are valid database datatypes in Oracle? (Choose three)
A) CHAR
B) VARCHAR2
C) BOOLEAN
D) NUMBER
Q16. Omitting the WHERE clause from a DELETE statement has which of the following effects?
A) The delete statement will fail because there are no recods to delete
B) The delete statement will promt the user to enter criteria for the deletion
C) The delete statement will fail because of syntax error
D) The delete statement will remove all the recods from the table
Q17. Creating a foreign-key constraint between columns of two tables defined with two different datatypes will produce an error?
A) TRUE
B) FALSE
Q18. Dropping a table has which of the following effects on a non unique index created for the table?
A) No effect
B) The index will be dropped
C) The index will be rendered invalid
D) The index will contain NULL values
Q19. To increase the number of nullable columns for a table,
A) Use the alter table statements
B) Ensure that all column values are NULL for all rows
C) First increase the size of adjacent column datatypes, then add the column
D) Add the column, populate the column, then add the NOT NULL constraint
Q20. Which line of the following statement will produce an error?
A) CREATE TABLE goods (good_no NUMBER, good_name VARCHAR2 check (good_name in (SELECT name FROM avail_goods)),
B) CONSTRAINT pk_goods_01
C) PRIMARY KEY (goodno);
D) There are no errors in this statements
Q21. MAXVALUE is a valid parameter for a sequence creation
A) TRUE
B) FALSE
Q22. Which of the following lines in the SELECT below contain an error?
A) SELECT DECODE (empid, 58385, "INACTIVE", "ACTIVE") empid FROM emp WHERE SUBSTR (lastname,1,1) > TO_NUMBER('S') AND empid > 02000 ORDER BY empid DESC, lastname ASC;
B) There are no errors in this statement
Q23. Which function below can best be categorized as similar in function to an IF-THEN_ELSE statement?
A) SQRT
B) DECODE
C) NEW_TIME
D) ROWIDTOCHAR
Q24. Which two of the following orders are used in ORDER BY clauses? (Choose two)
A) ABS
B) ASC
C) DESC
D) DISC
Q25. You query the database with this command
SELECT name
FROM employee
WHERE name LIKE '_a%';
Which names are displayed?
A) Names starting with "a"
B) Names starting with "aR" or "A"
C) Names containing "aR" as second character
D) Names containing "aR" as any letter except the first

No comments:

Post a Comment