|
SQL Interview Questions and Answers for IBM i developer |
Q1: What are the different events in Triggers?
- Drop, Comment, Delete
- Define, Create, Comment
- Select, Commit, Define
- Insert, Update, Delete
Answer 1:
4. Insert, Update, Delete
Q2: Which query is used for sorting data that retrieves all the fields from the CUSTOMER table and listed them in ascending order?
- SELECT * FROM CUSTOMER SORT BY age
- SELECT * FROM CUSTOMER ORDER BY COLUMN age
- SELECT * FROM CUSTOMER ORDER BY age
- SELECT * FROM CUSTOMER ORDER age
Answer 2:
3. FROM CUSTOMER ORDER BY age
Q3:Which function can be used to return a specified portion of a character string?
- STRIP
- SUBSTR
- TRIM
- POS
Answer 3:
2. SUBSTR
Q4:You need to filter return data from your query on the STUDENT table according to the CLASS column. Which of the following clauses in your SQL query will contain a reference to the appropriate filter criteria?
- WHERE
- SELECT
- FROM
- HAVING
Answer 4:
1. WHERE
Q5:Which of the following SQL command can be used to modify existing data in a database table?
- INSERT
- MODIFY
- CHANGE
- UPDATE
Answer 5:
4. UPDATE
Q6:which of the following SQL Statements is right?
- SELECT FROM Sales WHERE Date BETWEEN '10/12/2005' AND '01/01/2006'
- SELECT FROM Sales WHERE Date BETWEEN ('10/12/2005', '01/01/2006')
- SELECT * FROM Sales WHERE Date BETWEEN '10/12/2005' AND '01/01/2006'
- SELECT * FROM Sales WHERE Date BETWEEN '10/12/2005' AND Date BETWEEN '01/01/2006'
Answer 6:
3. SELECT * FROM Sales WHERE Date BETWEEN '10/12/2005' AND '01/01/2006'
Q7:What is the difference between the WHERE and HAVING SQL clauses?
- The having clause is the same as the where clause
- The HAVING SQL clause is applied to all rows in the result. The WHERE clause is used only with SELECT SQL statements and specifies a search condition for an aggregate or a group
- The WHERE SQL clause is applied to all rows in the result set. The HAVING clause is used only with SELECT SQL statements and specifies a search condition for an aggregate or a group.
- None of the above
Answer 7:
3. The WHERE SQL clause is applied to all rows in the result set. The HAVING clause is used only with SELECT SQL statements and specifies a search condition for an aggregate or a group.
Q8:A field whose value uniquely identifies every row in a table?
- keys
- data type
- foreign key
- primary key
Answer 8:
4. primary key
Q9:When you COMMIT, is the cursor closed?
- yes
- no
Answer 9:
1. yes
Q10:Which of the following are the five built-in functions provided by SQL?
- SUM, AVG1, MIN, MAX, NAME
- COUNT, SUM, AVG, MIN, MAX
- SUM, AVG, MULT, DIV1, MIN
- SUM, AVG, MIN, MAX, MULT
Answer 10:
2. COUNT, SUM, AVG, MIN, MAX
Q11:Is DECLARE CURSOR executable?
- yes
- no
Answer 11:
2.no
Q12:How many indexes will be created by the following statement?
Create table TABLE1
{ Column1 integer not null primary key,
Column2 integer not null,
Column3 char (20),
Column4 char (10),
Constraint Const_4 unique (Column1,Column2)
}
- 0
- 3
- 1
- 2
Answer 12:
4.2
Q13:.Can you have more than one cursor open at any one time in a program?
- yes
- no
Answer 13:
1. yes
Q14:What does a positive value of SQL code mean?
- successful execution
- no rows found
- warning
- error
Answer 14:
3. warning
Q15:What are the aggregate functions supported by DB2?
- SUM and AVG
- SUM, MAX, MIN, AVG, and COUNT
- Both of the above
- none of the above
Answer 15:
2. SUM, MAX, MIN, AVG, and COUNT
Q16:Which of the following DB2 data types cannot be used to create an identity column?
- NUMERIC
- SMALLINT
- DOUBLE
- INTEGER
Answer 16:
3. double
Q17:which of the following query is correct for using the comparison operator in SQL
- SELECT CUTSNAME FROM CUSTOMER where age >50 and where age <80
- SELECT CUTSNAME FROM CUSTOMER where age >50 and <80
- SELECT CUTSNAME FROM CUSTOMER where age >50 and age <80
- none of the above
Answer 17:
3. SELECT CUTSNAME FROM CUSTOMER where age >50 and age <80