0% found this document useful (0 votes)
39 views

SQL Interview Questions

The document discusses SQL interview questions and answers. It contains 25 questions related to SQL statements, functions, datatypes, constraints and more. Common questions are about JOINs, aggregates, NULL handling and modifying or deleting database records.

Uploaded by

Sre
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views

SQL Interview Questions

The document discusses SQL interview questions and answers. It contains 25 questions related to SQL statements, functions, datatypes, constraints and more. Common questions are about JOINs, aggregates, NULL handling and modifying or deleting database records.

Uploaded by

Sre
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 4

SQL Interview Questions

SQL interview questions


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;

Parag R. Tokase 1
SQL Interview Questions

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.

Parag R. Tokase 2
SQL Interview Questions

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)),

Parag R. Tokase 3
SQL Interview Questions

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 IF-
THEN-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. Names starting with “a”


2. Names starting with “aR
3. or “A”
4. Names containing “aR
5. as second character
6. Names containing “aR
7. as any letter except the first

Parag R. Tokase 4

You might also like