SQL Interview Questions and Answers Guide
SQL Interview Questions and Answers Guide
SQL Interview Questions and Answers Guide
Answers Guide.
Global Guideline.
https://www.globalguideline.com/
SQL Interview Questions And Answers
G
SQL Job Interview Preparation Guide.
lo
ba
lG
Question # 1
What is SQL (Structured Query Language)?
ui
Answer:-
SQL is an English like language consisting of commands to store, retrieve, maintain & regulate access to your database.
Read More Answers.
de
Question # 2
What is the SQL*Plus?
lin
Answer:-
SQL*Plus is an application that recognizes & executes SQL commands & specialized SQL*Plus commands that can customize reports, provide help & edit facility &
maintain system variables.
Read More Answers.
e
Question # 3
What is NVL?
.C
Answer:-
NVL : Null value function converts a null value to a non-null value for the purpose of evaluating an expression. Numeric Functions accept numeric I/P & return
numeric values. They are MOD, SQRT, ROUND, TRUNC & POWER.
O
Read More Answers.
Question # 4
M
What is a Character Functions?
Answer:-
Character Functions are INITCAP, UPPER, LOWER, SUBSTR & LENGTH. Additional functions are GREATEST & LEAST. Group Functions returns results based
upon groups of rows rather than one result per row, use group functions. They are AVG, COUNT, MAX, MIN & SUM.
Read More Answers.
Question # 5
What is SET?
Answer:-
SET command changes the system variables affecting the report environment.
Read More Answers.
Question # 6
What is a TTITLE & BTITLE?
Answer:-
TTITLE & BTITLE are commands to control report headings & footers.
Read More Answers.
Question # 7
What is sql BREAK?
Answer:-
BREAK command clarify reports by suppressing repeated values, skipping lines & allowing for controlled break points.
Read More Answers.
Question # 8
What is sql JOIN?
Answer:-
JOIN is the form of SELECT command that combines info from two or more tables.
Types of Joins are Simple (Equijoin & Non-Equijoin), Outer & Self join.
Equijoin returns rows from two or more tables joined together based upon a equality condition in the WHERE clause.
Non-Equijoin returns rows from two or more tables based upon a relationship other than the equality condition in the WHERE clause.
G
Outer Join combines two or more tables returning those rows from one table that have no direct match in the other table.
Self Join joins a table to itself as though it were two separate tables.
Read More Answers.
lo
Question # 9
ba
What is sql COMPUTE?
Answer:-
command control computations on subsets created by the BREAK command.
Read More Answers.
lG
Question # 10
What is SQL*Loader?
Answer:-
ui
SQL*Loader is a product for moving data in external files into tables in an Oracle database. To load data from external files into an Oracle database, two types of
input must be provided to SQL*Loader : the data itself and the control file. The control file describes the data to be loaded. It describes the Names and format of the
data files, Specifications for loading data and the Data to be loaded (optional). Invoking the loader sqlload username/password controlfilename <options>.
de
Read More Answers.
Question # 11
What is sql Consistency?
lin
Answer:-
Consistency : Assures users that the data they are changing or viewing is not changed until the are thro' with it.
Read More Answers.
e
Question # 12
What is sql Set Transaction?
.C
Answer:-
Set Transaction is to establish properties for the current transaction.
Read More Answers.
O
Question # 13
What is sql Posting?
M
Answer:-
Posting is an event that writes Inserts, Updates & Deletes in the forms to the database but not committing these transactions to the database.
Read More Answers.
Question # 14
Explain Order of SQL statement execution?
Answer:-
Where clause, Group By clause, Having clause, Order By clause & Select.
Read More Answers.
Question # 15
What is sql Synonyms?
Answer:-
Synonyms is the alias name for table, views, sequences & procedures and are created for reasons of Security and Convenience.
Two levels are Public - created by DBA & accessible to all the users. Private - Accessible to creator only. Advantages are referencing without specifying the owner
and Flexibility to customize a more meaningful naming convention.
Read More Answers.
Question # 16
What is sql Multiple columns?
Answer:-
Multiple columns can be returned from a Nested Subquery.
Read More Answers.
Question # 17
What is sql Minus?
Answer:-
Minus is the product of two tables listing only the non-matching rows.
Read More Answers.
G
Question # 18
What is sql Union?
lo
Answer:-
Union is the product of two or more tables.
Read More Answers.
ba
Question # 19
What is sql Transaction?
lG
Answer:-
Transaction is defined as all changes made to the database between successive commits.
Read More Answers.
ui
Question # 20
What is sql Locking?
Answer:-
de
Locking are mechanisms intended to prevent destructive interaction between users accessing data. Locks are used to achieve.
Read More Answers.
Question # 21
lin
What is sql Savepoint?
Answer:-
Savepoint is a point within a particular transaction to which you may rollback without rolling back the entire transaction.
e
Read More Answers.
Question # 22
.C
What is sql Commit?
Answer:-
Commit is an event that attempts to make data in the database identical to the data in the form. It involves writing or posting data to the database and committing data
to the database. Forms check the validity of the data in fields and records during a commit. Validity check are uniqueness, consistency and db restrictions.
O
Read More Answers.
M
Question # 23
What is sql Sequences?
Answer:-
Sequences are used for generating sequence numbers without any overhead of locking. Drawback is that after generating a sequence number if the transaction is
rolled back, then that sequence number is lost.
Read More Answers.
Question # 24
What is sql Correlated Subquery?
Answer:-
Correlated Subquery is a subquery that is evaluated once for each row processed by the parent statement. Parent statement can be Select, Update or Delete. Use
CRSQ to answer multipart questions whose answer depends on the value in each row processed by parent statement.
Read More Answers.
Question # 25
What is sql Intersect?
Answer:-
Intersect is the product of two tables listing only the matching rows.
Read More Answers.
Question # 26
What is SQL Indexes?
Answer:-
Indexes are optional structures associated with tables used to speed query execution and/or guarantee uniqueness. Create an index if there are frequent retrieval of
fewer than 10-15% of the rows in a large table and columns are referenced frequently in the WHERE clause. Implied tradeoff is query speed vs. update speed. Oracle
automatically update indexes. Concatenated index max. is 16 columns.
Read More Answers.
Question # 27
What are SQL Data types?
G
Answer:-
Max. columns in a table is 255. Max. Char size is 255, Long is 64K & Number is 38 digits.
lo
Cannot Query on a long column.
Char, Varchar2 Max. size is 2000 & default is 1 byte.
Number(p,s) p is precision range 1 to 38, s is scale -84 to 127.
Long Character data of variable length upto 2GB.
ba
Date Range from Jan 4712 BC to Dec 4712 AD.
Raw Stores Binary data (Graphics Image & Digitized Sound). Max. is 255 bytes.
Mslabel Binary format of an OS label. Used primarily with Trusted Oracle.
Read More Answers.
lG
Question # 28
What is SQL Rollback?
Answer:-
ui
Rollback causes work in the current transaction to be undone.
Read More Answers.
de
Question # 29
What is SQL Mutating Table?
Answer:-
lin
Mutating Table is a table that is currently being modified by an Insert, Update or Delete statement. Constraining Table is a table that a triggering statement might
need to read either directly for a SQL statement or indirectly for a declarative Referential Integrity constraints. Pseudo Columns behaves like a column in a table but
are not actually stored in the table. E.g. Currval, Nextval, Rowid, Rownum, Level etc.
Read More Answers.
e
Question # 30
Operators used in SELECT statements.
.C
Answer:-
= Equal
<> or != Not equal
> Greater than
O
< Less than
>= Greater than or equal
<= Less than or equal
M
BETWEEN Between an inclusive range
LIKE Search for a pattern
Read More Answers.
Question # 31
The Update Statement:
Answer:-
UPDATE table_name SET column_name = new_value WHERE column_name = some_value
Read More Answers.
Question # 32
Sort the Rows:
Answer:-
Sort the Rows:
SELECT column1, column2, ... FROM table_name ORDER BY columnX, columnY, ..
SELECT column1, column2, ... FROM table_name ORDER BY columnX DESC
SELECT column1, column2, ... FROM table_name ORDER BY columnX DESC, columnY ASC
Read More Answers.
Question # 33
BETWEEN ... AND
Answer:-
SELECT column_name FROM table_name WHERE column_name BETWEEN value1 AND value2 The values can be numbers, text, or dates.
Read More Answers.
Question # 34
Why does the following command give a compilation error?
Answer:-
DROP TABLE &TABLE_NAME; Variable names should start with an alphabet. Here the table name starts with an '&' symbol.
Read More Answers.
G
Question # 35
Which system table contains information on constraints on all the tables created? obtained?
lo
Answer:-
USER_CONSTRAINTS.
Read More Answers.
ba
Question # 36
State true or false. !=, <>, ^= all denote the same operation?
lG
Answer:-
True.
Read More Answers.
ui
Question # 37
What will be the output of the following query?
Answer:-
de
SELECT REPLACE(TRANSLATE(LTRIM(RTRIM('!! ATHEN !!','!'), '!'), 'AN', '**'),'*','TROUBLE') FROM DUAL;?
TROUBLETHETROUBLE.
Read More Answers.
lin
Question # 38
What is the advantage of specifying WITH GRANT OPTION in the GRANT command?
Answer:-
e
The privilege receiver can further grant the privileges he/she has obtained from the owner to any other user.
Read More Answers.
.C
Question # 39
What is the value of comm and sal after executing the following query if the initial value of ‘sal' is 10000 UPDATE EMP SET SAL = SAL + 1000, COMM =
SAL*0.1;?
Answer:-
O
sal = 11000, comm = 1000.
Read More Answers.
M
Question # 40
What command is used to get back the privileges offered by the GRANT command?
Answer:-
REVOKE.
Read More Answers.
Question # 41
What is the use of the DROP option in the ALTER TABLE command?
Answer:-
It is used to drop constraints specified on the table.
Read More Answers.
Question # 42
What are privileges that can be granted on a table by a user to others?
Answer:-
Insert,
update,
delete,
select,
references,
index,
execute,
alter,
all.
Question # 43
Which is the subset of SQL commands used to manipulate Oracle Database structures, including tables?
Answer:-
Data Definition Language (DDL).
G
Read More Answers.
lo
Question # 44
What command is used to create a table by copying the structure of another table?
Answer:-
ba
CREATE TABLE .. AS SELECT command
Explanation:
To copy only the structure, the WHERE clause of the SELECT command should contain a FALSE statement as in the following.
CREATE TABLE NEWTABLE AS SELECT * FROM EXISTINGTABLE WHERE 1=2;
lG
If the WHERE condition is true, then all the rows or rows satisfying the condition will be copied to the new table.
Read More Answers.
Question # 45
ui
What is the output of the following query SELECT TRUNC(1234.5678,-2) FROM DUAL;?
Answer:-
1200.
de
Read More Answers.
Question # 46
What is the parameter substitution symbol used with INSERT INTO command?
lin
Answer:-
&
Read More Answers.
e
Question # 47
What is difference between TRUNCATE & DELETE?
.C
Answer:-
TRUNCATE commits after deleting entire table i.e., cannot be rolled back. Database triggers do not fire on TRUNCATE
DELETE allows the filtered deletion. Deleted records can be rolled back or committed. Database triggers fire on DELETE.
O
Read More Answers.
Question # 48
M
What is SQL sub-query?
Answer:-
Sub-query is a query whose return values are used in filtering conditions of the main query.
Read More Answers.
Question # 49
Explain CONNECT BY PRIOR?
Answer:-
Retrieves rows in hierarchical order eg.
select empno, ename from emp where.
Read More Answers.
Question # 50
Explain UNION, MINUS, UNION ALL and INTERSECT?
Answer:-
INTERSECT - returns all distinct rows selected by both queries. MINUS - returns all distinct rows selected by the first query but not by the second. UNION - returns
all distinct rows selected by either query UNION ALL - returns all rows selected by either query, including all duplicates.
Read More Answers.
Question # 51
What is the fastest way of accessing a row in a table?
Answer:-
Using ROWID.
CONSTRAINTS
Copyright © https://www.GlobalGuideline.COM Page 7/25
SQL Interview Questions And Answers
Question # 52
What is referential integrity constraint?
Answer:-
Maintaining data integrity through a set of rules that restrict the values of one or more columns of the tables based on the values of primary key or unique key of the
G
referenced table.
Read More Answers.
lo
Question # 53
What is correlated sub-query?
ba
Answer:-
Correlated sub-query is a sub-query, which has reference to the main query.
Read More Answers.
lG
Question # 54
What is SQL ROWID?
Answer:-
ui
ROWID is a pseudo column attached to each row of a table. It is 18 characters long, blockno, rownumber are the components of ROWID.
Read More Answers.
de
Question # 55
What is ON DELETE CASCADE?
Answer:-
When ON DELETE CASCADE is specified Oracle maintains referential integrity by automatically removing dependent foreign key values if a referenced primary or
lin
unique key value is removed.
Read More Answers.
e
Question # 56
What is difference between CHAR and VARCHAR2? What is the maximum SIZE allowed for each type?
Answer:-
.C
CHAR pads blank spaces to the maximum length.
VARCHAR2 does not pad blank spaces.
For CHAR the maximum length is 255 and 2000 for VARCHAR2.
Read More Answers.
O
Question # 57
What are the pre-requisites to modify datatype of a column and to add a column with NOT NULL constraint?
M
Answer:-
- To modify the datatype of a column the column must be empty.
- To add a column with NOT NULL constrain, the table must be empty.
Read More Answers.
Question # 58
If unique key constraint on DATE column is created, will it validate the rows that are inserted with SYSDATE?
Answer:-
It won't, Because SYSDATE format contains time attached with it.
Read More Answers.
Question # 59
How to access the current value and next value from a sequence? Is it possible to access the current value in a session before accessing next value?
Answer:-
Sequence name CURRVAL, sequence name NEXTVAL. It is not possible. Only if you access next value in the session, current value can be accessed.
Read More Answers.
Question # 60
Can a view be updated/inserted/deleted? If Yes - under what conditions?
Answer:-
A View can be updated/deleted/inserted if it has only one base table if the view is based on columns from one or more tables then insert, update and delete is not
possible.
Read More Answers.
Question # 61
Which of the following statements is true about implicit cursors?
Answer:-
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.
G
Read More Answers.
lo
Question # 62
How would the developer define this variable using referential datatypes?
Answer:-
ba
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.
lG
3. Look up datatype for EMPLOYEE column on LASTNAME table and use that.
4. Declare it to be type LONG.
Read More Answers.
Question # 63
ui
If left out, which of the following would cause an infinite loop to occur in a simple loop?
Answer:-
de
1. LOOP
2. END LOOP
3. IF-THEN
4. EXIT
lin
Read More Answers.
Question # 64
The command used to open a CURSOR FOR loop is?
e
Answer:-
1. open
2. fetch
.C
3. parse
4. None, cursor for loops handle cursor opening implicitly.
Read More Answers.
O
Question # 65
Read the following code:
M
Answer:-
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
Read More Answers.
Question # 66
For which trigger timing can you reference the NEW and OLD qualifiers?
Answer:-
1. Statement and Row
2. Statement only
3. Row only
4. Oracle Forms trigger
Read More Answers.
Question # 67
Copyright © https://www.GlobalGuideline.COM Page 9/25
SQL Interview Questions And Answers
Question # 71
Which Oracle supplied package can you use to output values and messages from database triggers, stored procedures and functions within SQL*Plus?
Answer:-
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
Read More Answers.
Question # 72
Which Oracle supplied package will enable this feature?
Answer:-
A stored function must return a value based on conditions that are determined at runtime. Therefore, the SELECT statement cannot be hard-coded 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
Read More Answers.
Question # 73
How to implement ISNUMERIC function in SQL *Plus ?
G
Answer:-
Method 1:
Select length (translate (trim (column_name),' +-.0123456789',' ')) from dual ;
lo
Will give you a zero if it is a number or greater than zero if not numeric (actually gives the count of non numeric characters)
Method 2:
select instr(translate('wwww',
'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',
ba
'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'),'X')
FROM dual;
It returns 0 if it is a number, 1 if it is not.
Read More Answers.
lG
Question # 74
What is the difference between Truncate and Delete interms of Referential Integrity?
Answer:-
ui
DELETE removes one or more records in a table, checking referential Constraints (to see if there are dependent child records) and firing any DELETE triggers. In the
order you are deleting (child first then parent) There will be no problems.
TRUNCATE removes ALL records in a table. It does not execute any triggers. Also, it only checks for the existence (and status) of another foreign key Pointing to
de
the table. If one exists and is enabled, then you will get The following error. This is true even if you do the child tables first.
ORA-02266: unique/primary keys in table referenced by enabled foreign keys
You should disable the foreign key constraints in the child tables before issuing the TRUNCATE command, then re-enable them afterwards.
Read More Answers.
lin
Question # 75
What does the OLTP stands for ?
Answer:-
e
OLTP stands for On Line Transaction Processing
Read More Answers.
.C
Question # 76
In a client server environment, what would be the major work that the client deals with?
Answer:-
O
The client deals with the user interface part of the system.
Read More Answers.
M
Question # 77
What does teh term upsizing refer to?
Answer:-
Applications that have outgrown their environment are re-engineered to run in a larger environment. This is upsizing.
Read More Answers.
Question # 78
What does the term downsizing refer to?
Answer:-
A host based application is re-engineered to run in smaller or LAN based environment.
Read More Answers.
Question # 79
Why do stored procedures reduce network traffic?
Answer:-
When a stored procedure is called, only the procedure call is sent to the server and not the statements that the procedure contains.
Read More Answers.
Question # 80
What is a event handler in sql?
Answer:-
An event handler is a routine that is written to respond to a particular event.
Question # 81
What are the various uses of database triggers?
Answer:-
Database triggers can be used to enforce business rules, to maintain derived values and perform value-based auditing.
G
Read More Answers.
lo
Question # 82
Why are the integrity constraints preferred to database triggers?
Answer:-
ba
Because it is easier to define an integrity constraint than a database trigger.
Read More Answers.
lG
Question # 83
What are the three components of a client server model?
Answer:-
A Client,
ui
A Server and
A Network/Communication software.
Read More Answers.
de
Question # 84
What are the disadvantages of the client/server model?
Answer:-
lin
Heterogeneity of the system results in reduced reliablity. May not be suitable for all applications. Managing and tuning networks becomes difficult.
Read More Answers.
e
Question # 85
What is the first work of Client process?
Answer:-
.C
A client process at first establishes connection with the Server.
Read More Answers.
Question # 86
O
In a Client/Server context, what does API (Application Programming Interface) refer to?
Answer:-
M
An API, in a Client/Server context, is a specification of a set of functions for communication between the client and the server.
Read More Answers.
Question # 87
What is the main advantage of developing an application using an API?
Answer:-
The application can be connected to any back end server that is supported by the API.
Read More Answers.
Question # 88
Why is an event driven program referred to a passive program?
Answer:-
Because an event driven program is always waiting for something to happen before processing.
Read More Answers.
Question # 89
What is the difference between file server and a database server?
Answer:-
A file server just transfers all the data requested by all its client and the client processes the data while a database server runs the query and sends only the query
output.
Read More Answers.
Question # 90
Question # 93
ui
Most important DDL statements in SQL are:
Answer:-
de
CREATE TABLE - creates a new database table
Question # 95
The INSERT INTO Statements:
Answer:-
INSERT INTO table_name VALUES (value1, value2,....)
INSERT INTO table_name (column1, column2,...) VALUES (value1, value2,....)
Read More Answers.
Question # 96
The Delete Statements:
Answer:-
DELETE FROM table_name WHERE column_name = some_value
Delete All Rows:
DELETE FROM table_name or DELETE * FROM table_name
Read More Answers.
Question # 97
What is use of CASCADE CONSTRAINTS?
Answer:-
When this clause is used with the DROP command, a parent table can be dropped even when a child table exists.
Read More Answers.
Question # 98
Which system tables contain information on privileges granted and privileges obtained?
Answer:-
USER_TAB_PRIVS_MADE,
USER_TAB_PRIVS_RECD
Read More Answers.
G
Question # 99
What is the difference between TRUNCATE and DELETE commands?
lo
Answer:-
TRUNCATE is a DDL command whereas DELETE is a DML command. Hence DELETE operation can be rolled back, but TRUNCATE operation cannot be rolled
back. WHERE clause can be used with DELETE and not with TRUNCATE.
ba
Read More Answers.
Question # 100
State true or false. EXISTS, SOME, ANY are operators in SQL?
lG
Answer:-
True.
Read More Answers.
ui
Question # 101
What does the following query do?
de
Answer:-
SELECT SAL + NVL(COMM,0) FROM EMP;?
This displays the total salary of all employees. The null values in the commission column will be replaced by 0 and added to salary.
Read More Answers.
lin
Question # 102
Which command executes the contents of a specified file?
Answer:-
e
START or @.
Read More Answers.
.C
Question # 103
Which command displays the SQL command in the SQL buffer, and then executes it?
Answer:-
O
RUN.
Read More Answers.
M
Question # 104
What will be the output of following query?
Answer:-
What will be the output of the following query?
SELECT DECODE(TRANSLATE('A','1234567890','1111111111'), '1','YES', 'NO' );?
NO. Explanation :
The query checks whether a given string is a numerical digit.
Read More Answers.
Question # 105
What operator tests column for absence of data?
Answer:-
IS NULL operator.
Read More Answers.
Question # 106
Which function is used to find the largest integer less than or equal to a specific value?
Answer:-
FLOOR.
Read More Answers.
Question # 107
What is the use of DESC in SQL?
Answer:-
DESC has two purposes. It is used to describe a schema as well as to retrieve rows from table in descending order.
Explanation :
The query SELECT * FROM EMP ORDER BY ENAME DESC will display the output sorted on ENAME in descending order.
Read More Answers.
Question # 108
G
TRUNCATE TABLE EMP; DELETE FROM EMP; Will the outputs of the above two commands differ?
Answer:-
lo
Both will result in deleting all the rows in the table EMP..
Read More Answers.
ba
Question # 109
What are the wildcards used for pattern matching.?
Answer:-
lG
_ for single character substitution and % for multi-character substitution.
Read More Answers.
Question # 110
ui
What is SQL injection?
Answer:-
SQL Injection is when form data contains an SQL escape sequence and injects a new SQL query to be run.
de
Read More Answers.
Question # 111
lin
What is a join? Explain the different types of sql joins?
Answer:-
Join is a query, which retrieves related columns or rows from multiple tables.
Self Join - Joining the table with itself.
e
Equi Join - Joining two tables by equating two common columns.
Non-Equi Join - Joining two tables by equating two common columns.
Outer Join - Joining two tables in such a way that query can also retrieve rows that do not have corresponding join value in the other table.
.C
Read More Answers.
Question # 112
Difference between SUBSTR and INSTR?
O
Answer:-
INSTR (String1, String2 (n, (m)),
INSTR returns the position of the m-th occurrence of the string 2 in string1. The search begins from nth position of string1.
M
SUBSTR (String1 n, m)
SUBSTR returns a character string of size m in string1, starting from n-th position of string1.
Read More Answers.
Question # 113
What is an integrity constraint?
Answer:-
Integrity constraint is a rule that restricts values to a column in a table.
Read More Answers.
Question # 114
What is the usage of SAVEPOINTS?
Answer:-
SAVEPOINTS are used to subdivide a transaction into smaller parts. It enables rolling back part of a transaction. Maximum of five save points are allowed.
Read More Answers.
Question # 115
What are the data types allowed in a table?
Answer:-
CHAR,
VARCHAR2,
NUMBER,
DATE,
RAW,
LONG and
Copyright © https://www.GlobalGuideline.COM Page 15/25
SQL Interview Questions And Answers
LONG RAW.
Read More Answers.
Question # 116
How many LONG columns are allowed in a table? Is it possible to use LONG columns in WHERE clause or ORDER BY?
Answer:-
G
Only one LONG column is allowed. It is not possible to use LONG column in WHERE or ORDER BY clause.
Read More Answers.
lo
Question # 117
Where the integrity constraints are stored in data dictionary?
ba
Answer:-
The integrity constraints are stored in USER_CONSTRAINTS.
Read More Answers.
lG
Question # 118
What is CYCLE/NO CYCLE in a Sequence?
Answer:-
ui
CYCLE specifies that the sequence continue to generate values after reaching either maximum or minimum value. After pan-ascending sequence reaches its
maximum value, it generates its minimum value. After a descending sequence reaches its minimum, it generates its maximum.
NO CYCLE specifies that the sequence cannot generate more values after reaching its maximum or minimum value.
Read More Answers.
de
Question # 119
How will you activate/deactivate integrity constraints?
lin
Answer:-
The integrity constraints can be enabled or disabled by ALTER TABLE ENABLE CONSTRAINT / DISABLE CONSTRAINT.
Read More Answers.
e
Question # 120
What is a database link?
.C
Answer:-
Database link is a named path through which a remote database can be accessed.
Read More Answers.
O
Question # 121
What are the advantages of VIEW?
M
Answer:-
- To protect some of the columns of a table from other users.
- To hide complexity of a query.
- To hide complexity of calculations.
Read More Answers.
Question # 122
If a view on a single base table is manipulated will the changes be reflected on the base table?
Answer:-
Changes on the view will be reflected on the base table under certain conditions.
But if changes are made to the tables and these tables are the base tables of a view, then the changes will be reference on the view.
Read More Answers.
Question # 123
Which of the following is not a feature of a cursor FOR loop?
Answer:-
1. Record type declaration.
2. Opening and parsing of SQL statements.
3. Fetches records from cursor.
4. Requires exit condition to be defined.
Read More Answers.
Question # 124
Which three of the following are implicit cursor attributes?
Answer:-
1. %found
2. %too_many_rows
3. %notfound
4. %rowcount
5. %rowtype
Read More Answers.
G
Question # 125
Which line in the following statement will produce an error?
lo
Answer:-
1. cursor action_cursor is
2. select name, rate, action
3. into action_record
ba
4. from action_table;
5. There are no errors in this statement.
Read More Answers.
lG
Question # 126
What is the maximum number of handlers processed before the PL/SQL block is exited when an exception occurs?
Answer:-
1. Only one
ui
2. All that apply
3. All referenced
4. None
de
Read More Answers.
Question # 127
What happens when rows are found using a FETCH statement?
lin
Answer:-
1. It causes the cursor to close
2. It causes the cursor to open
3. It loads the current row values into variables
e
4. It creates the variables to hold the current row values
Read More Answers.
.C
Question # 128
Read the following code and explain:
Answer:-
O
Read the following code:
22. CREATE OR REPLACE TRIGGER update_show_gross
23. {trigger information}
M
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)
Read More Answers.
Question # 129
Read the following code 2:
Answer:-
CREATE OR REPLACE FUNCTION get_budget(v_studio_id IN NUMBER)
RETURN number IS
v_yearly_budget NUMBER;
BEGIN
SELECT yearly_budget
INTO v_yearly_budget
FROM studio
WHERE id = v_studio_id;
RETURN v_yearly_budget;
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);
Question # 131
lin
Which procedure can be used to create a customized error message?
Answer:-
1. RAISE_ERROR
e
2. SQLERRM
3. RAISE_APPLICATION_ERROR
4. RAISE_SERVER_ERROR
.C
Read More Answers.
Question # 132
Examine this database trigger?
O
Answer:-
52. CREATE OR REPLACE TRIGGER prevent_gross_modification
53. {additional trigger information}
M
54. BEGIN
55. IF TO_CHAR(sysdate, DY) = MON
56. THEN
57. RAISE_APPLICATION_ERROR(-20000,Gross receipts cannot be deleted on Monday);
58. END IF;
59. 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
Read More Answers.
Question # 133
Procedure and Functions are explicitly executed. This is different from a database trigger. When is a database trigger executed?
Answer:-
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
Read More Answers.
Question # 134
What occurs if a procedure or function terminates with failure without being handled?
Answer:-
1. Any DML statements issued by the construct are still pending and can be committed or rolled back.
Question # 135
Examine this below sql code
G
Answer:-
71. BEGIN
lo
72. theater_pck.v_total_seats_sold_overall := theater_pck.get_total_for_year;
73. 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
ba
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
lG
package.
Read More Answers.
Question # 136
How to Select last N records from a Table?
ui
Answer:-
select * from (select rownum a, CLASS_CODE,CLASS_DESC from clm)
de
where a > ( select (max(rownum)-10) from clm)
Here N = 10
The following query has a Problem of performance in the execution of the following query where the table ter.ter_master have 22231 records. So the results are
obtained after hours.
Cursor rem_master(brepno VARCHAR2) IS
lin
select a.* from ter.ter_master a
where NOT a.repno in (select repno from ermast) and
(brepno = 'ALL' or a.repno > brepno)
Order by a.repno
What are steps required tuning this query to improve its performance?
e
-Have an index on TER_MASTER.REPNO and one on ERMAST.REPNO
-Be sure to get familiar with EXPLAIN PLAN. This can help you determine the execution path that Oracle takes. If you are using Cost Based Optimizer mode, then
be sure that your statistics on TER_MASTER are up-to-date. -Also, you can change your SQL to:
SELECT a.*
.C
FROM ter.ter_master a
WHERE NOT EXISTS (SELECT b.repno FROM ermast b
WHERE a.repno=b.repno) AND
(a.brepno = 'ALL' or a.repno > a.brepno)
ORDER BY a.repno;
O
Read More Answers.
M
Question # 137
Which of the Oracle supplied package will enable this feature?
Answer:-
A stored function must return a value based on conditions that are determined at runtime. Therefore, the SELECT statement cannot be hard-coded 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
Read More Answers.
Question # 138
What does preemptive in preemptive multitasking mean?
Answer:-
Preemptive refers to the fact that each task is alloted fixed time slots and at the end of that time slot the next task is started.
Read More Answers.
Question # 139
What is the most important requirement for OLTP?
Answer:-
OLTP requires real time response.
Read More Answers.
Question # 140
Why is the most of the processing done at the sever?
Copyright © https://www.GlobalGuideline.COM Page 19/25
SQL Interview Questions And Answers
Answer:-
To reduce the network traffic and for application sharing and implementing business rules.
Read More Answers.
Question # 141
What does one do when one is rightsizing?
G
Answer:-
With rightsizing, one would move applications to the most appropriate server platforms.
lo
Read More Answers.
Question # 142
ba
What is sql event trigger?
Answer:-
An event trigger, a segment of code which is associated with each event and is fired when the event occurs.
lG
Read More Answers.
Question # 143
What are the types of processes that a server runs?
ui
Answer:-
Foreground process and Background process.
Read More Answers.
de
Question # 144
What is an sql integrity constraint?
Answer:-
lin
An integrity constraint allows the definition of certain restrictions, at the table level, on the data that is entered into a table.
Read More Answers.
e
Question # 145
Why is it better to use an integrity constraint to validate data in a table than to use a stored procedure?
Answer:-
.C
Because an integrity constraint is automatically checked while data is inserted into a table. A stored has to be specifically invoked.
Read More Answers.
Question # 146
O
What are the advantages of client/server model?
Answer:-
M
Flexibility of the system, scalability, cost saving, centralised control and implementation of business rules, increase of developers productivity, portability, improved
network and resource utilization.
Read More Answers.
Question # 147
What are the different topologies available for network?
Answer:-
Star,
Bus,
Ring.
Read More Answers.
Question # 148
What are the responsibilities of a Server?
Answer:-
1. Manage resources optimally across multiple clients.
2. Controlling database access and security.
3. Protecting the databse and recovering it from crashes.
4. Enforcing integrity rules globally.
Read More Answers.
Question # 149
Give some examples of standard APIs?
Answer:-
Question # 150
G
What is the main disadvantage of developing an application using an API?
Answer:-
lo
The application cannot use any special features of the backend server.
Read More Answers.
ba
Question # 151
What are the four types of events?
Answer:-
lG
1. System Events.
2. Control Events
3. User Events
4. Other Events.
Read More Answers.
ui
Question # 152
What is sql inheritance?
de
Answer:-
Inheritance is a method by which properties and methods of an existing object are automatically passed to any object derived from it.
Read More Answers.
lin
Question # 153
What is the function of a ODBC manager?
Answer:-
e
The ODBC Manager manages all the data sources that exists in the system.
Read More Answers.
.C
Question # 154
What description of a data source is required for ODBC?
Answer:-
O
The name of the DBMS, the location of the source and the database dependent information.
Read More Answers.
M
Question # 155
How can variables be passed to a SQL routine?
Answer:-
Level: Low
Expected answer: By use of the & symbol. For passing in variables the numbers 1-8 can be used (&1, &2,...,&8) to pass the values after the command into the
SQLPLUS session. To be prompted for a specific variable, place the ampersanded variable in the code itself:
"select * from dba_tables where owner=&owner_name;" . Use of double ampersands tells SQLPLUS to resubstitute the value for each subsequent use of the variable,
a single ampersand will cause a reprompt for the value unless an ACCEPT statement is used to get the value from the user.
Read More Answers.
Question # 156
You want to include a carriage return/linefeed in your output from a SQL script, how can you do this?
Answer:-
Expected answer: The best method is to use the CHR() function (CHR(10) is a return/linefeed) and the concatenation function "||". Another method, although it is
hard to document and isn?t always portable is to use the return/linefeed as a part of a quoted string.
Read More Answers.
Question # 157
How can you call a PL/SQL procedure from SQL?
Answer:-
Expected answer: By use of the EXECUTE (short form EXEC) command.
Read More Answers.
Question # 158
How do you execute a host operating system command from within SQL?
Answer:-
Expected answer: By use of the exclamation point "!" (in UNIX and some other OS) or the HOST (HO) command.
Read More Answers.
Question # 159
G
You want to use SQL to build SQL, what is this called and give an example?
Answer:-
lo
This is called dynamic SQL. An example would be:
set lines 90 pages 0 termout off feedback off verify off
spool drop_all.sql
select ?drop user ?||username||? cascade;? from dba_users
ba
where username not in ("SYS?,?SYSTEM?);
spool off
Essentially you are looking to see that they know to include a command (in this case DROP USER...CASCADE;) and that you need to concatenate using the ?||? the
values selected from the database.
lG
Read More Answers.
Question # 160
What SQLPlus command is used to format output from a select?
ui
Answer:-
This is best done with the COLUMN command.
Read More Answers.
de
Question # 161
ou want to group the following set of select returns, what can you group on? Max(sum_of_cost), min(sum_of_cost), count(item_no), item_no?
lin
Answer:-
The only column that can be grouped on is the "item_no" column, the rest have aggregate functions associated with them.
Read More Answers.
e
Question # 162
What special Oracle feature allows you to specify how the cost based system treats a SQL statement?
.C
Answer:-
The COST based system allows the use of HINTs to control the optimizer path selection. If they can give some example hints such as FIRST ROWS, ALL ROWS,
USING INDEX, STAR, even better.
Read More Answers.
O
Question # 163
You want to determine the location of identical rows in a table before attempting to place a unique index on the table, how can this be done?
M
Answer:-
Oracle tables always have one guaranteed unique column, the rowid column. If you use a min/max function against your rowid and then select against the proposed
primary key you can squeeze out the rowids of the duplicate rows pretty quick. For example:
select rowid from emp e
where e.rowid > (select min(x.rowid)
from emp x
where x.emp_no = e.emp_no);
In the situation where multiple columns make up the proposed key, they must all be used in the where clause.
Read More Answers.
Question # 164
What is a Cartesian product?
Answer:-
A Cartesian product is the result of an unrestricted join of two or more tables. The result set of a three table Cartesian product will have x * y * z number of rows
where x, y, z correspond to the number of rows in each table involved in the join.
Read More Answers.
Question # 165
You are joining a local and a remote table, the network manager complains about the traffic involved, how can you reduce the network traffic?
Answer:-
Push the processing of the remote data to the remote instance by using a view to pre-select the information for the join. This will result in only the data required for
the join being sent across.
Read More Answers.
Question # 166
Question # 167
G
What is tkprof and how is it used?
Answer:-
lo
The tkprof tool is a tuning tool used to determine cpu and execution times for SQL statements. You use it by first setting timed_statistics to true in the initialization
file and then turning on tracing for either the entire database via the sql_trace parameter or for the session using the ALTER SESSION command. Once the trace file
is generated you run the tkprof tool against the trace file and then look at the output from the tkprof tool. This can also be used to generate explain plan output.
ba
Read More Answers.
Question # 168
What is explain plan and how is it used?
lG
Answer:-
The EXPLAIN PLAN command is a tool to tune SQL statements. To use it you must have an explain_table generated in the user you are running the explain plan for.
This is created using the utlxplan.sql script. Once the explain plan table exists you run the explain plan command giving as its argument the SQL statement to be
explained. The explain_plan table is then queried to see the execution plan of the statement. Explain plans can also be run using tkprof.
ui
Read More Answers.
Question # 169
de
How do you set the number of lines on a page of output? The width?
Answer:-
The SET command in SQLPLUS is used to control the number of lines generated per page and the width of those lines, for example SET PAGESIZE 60 LINESIZE
80 will generate reports that are 60 lines long with a line width of 80 characters. The PAGESIZE and LINESIZE options can be shortened to PAGES and LINES.
lin
Read More Answers.
Question # 170
e
How do you prevent output from coming to the screen?
Answer:-
The SET option TERMOUT controls output to the screen. Setting TERMOUT OFF turns off screen output. This option can be shortened to TERM.
.C
Read More Answers.
Question # 171
How do you prevent Oracle from giving you informational messages during and after a SQL statement execution?
O
Answer:-
The SET options FEEDBACK and VERIFY can be set to OFF.
M
Read More Answers.
Question # 172
How do you generate file output from SQL?
Answer:-
By use of the SPOOL command
Read More Answers.
1 : SQL and PL/SQL Frequently Asked Interview Questions and Answers Guide.
4 : Database Administrator (DBA) Frequently Asked Interview Questions and Answers Guide.
Global Guideline is a platform to develop your own skills with thousands of job interview questions
and web tutorials for fresher's and experienced candidates. These interview questions and web
tutorials will help you strengthen your technical skills, prepare for the interviews and quickly revise
the concepts. Global Guideline invite you to unlock your potentials with thousands of Interview
Questions with Answers or begin a tutorial right away, such as HTML, XML, XSLT, Cascading
Style Sheet (CSS), Search Engine Optimization (SEO), JavaScript, Structure Query Language (SQL),
Database Articles, Web Hosting Guide and much more. Learn the most common technologies
Interview Questions and Answers. We will help you to explore the resources of the World Wide Web
and develop your own skills from the basics to the advanced. Here you will learn anything quite
easily and you will really enjoy while learning. Global Guideline will help you to become a
professional and Expert, well prepared for the future.
* If any answer or question is incorrect or inappropriate or you have correct answer or you found any
problem in this document then don't hesitate feel free and e-mail us we will fix it.
You can follow us on FaceBook for latest Jobs, Updates and other interviews material.
www.facebook.com/InterviewQuestionsAnswers
Best Of Luck.