Sunteți pe pagina 1din 12

Interview Questions for Basic SQL

1. Which SQL function is used to count the number of rows in a SQL query ?
a) COUNT()
b) NUMBER()
c) SUM()
d) COUNT(*)

2. Which SQL keyword is used to retrieve a maximum value ?


a) MOST
b) TOP
c) MAX
d) UPPER

3. Which of the following SQL clauses is used to DELETE tuples from a database table ?
a) DELETE
b) REMOVE
c) DROP
d) CLEAR

4. ___________removes all rows from a table without logging the individual row deletions.
a) DELETE
b) REMOVE
c) DROP
d) TRUNCATE

5. Which of the following is not a DDL command ?


a) UPDATE
b) TRUNCATE
c) ALTER
d) None of the Mentioned

6. Which of the following are TCL commands ?


a) UPDATE and TRUNCATE
b) SELECT and INSERT
c) GRANT and REVOKE
d) ROLLBACK and SAVEPOINT

7. ________________ is not a category of SQL command.


a) TCL
b) SCL
c) DCL
d) DDL

8. If you don’t specify ASC or DESC after a SQL ORDER BY clause, the following is used by default
a) ASC
b) DESC
c) There is no default value
d) None of the mentioned

9. Which of the following statement is true ?


a) DELETE does not free the space containing the table and TRUNCATE free the space containing the
table
b) Both DELETE and TRUNCATE free the space containing the table
c) Both DELETE and TRUNCATE does not free the space containing the table
d) DELETE free the space containing the table and TRUNCATE does not free the space containing the
table

10. What is the purpose of the SQL AS clause ?


a) The AS SQL clause is used change the name of a column in the result set or to assign a name to a
derived column
b) The AS clause is used with the JOIN clause only
c) The AS clause defines a search condition
d) All of the mentioned

11. What does DML stand for ?


a) Different Mode Level
b) Data Model Language
c) Data Mode Lane
d) Data Manipulation language

12. With SQL, how do you select all the records from a table named “Persons” where the value of the
column “FirstName” ends with an “a” ?
a) SELECT * FROM Persons WHERE FirstName=’a’
b) SELECT * FROM Persons WHERE FirstName LIKE ‘a%’
c) SELECT * FROM Persons WHERE FirstName LIKE ‘%a’
d) SELECT * FROM Persons WHERE FirstName=’%a%’

13. With SQL, how can you return all the records from a table named “Persons” sorted descending by
“FirstName” ?
a) SELECT * FROM Persons SORT BY ‘FirstName’ DESC
b) SELECT * FROM Persons ORDER FirstName DESC
c) SELECT * FROM Persons SORT ‘FirstName’ DESC
d) SELECT * FROM Persons ORDER BY FirstName DESC
14. With SQL, how can you return the number of not null records in the “Persons” table ?
a) SELECT COUNT() FROM Persons
b) SELECT COLUMNS() FROM Persons
c) SELECT COLUMNS(*) FROM Persons
d) SELECT COUNT(*) FROM Persons

15. What does the ALTER TABLE clause do ?


a) The SQL ALTER TABLE clause modifies a table definition by altering, adding, or deleting table
columns and/or constraints
b) The SQL ALTER TABLE clause is used to insert data into database table
c) THE SQL ALTER TABLE deletes data from database table
d) The SQL ALTER TABLE clause is used to delete a database table

16. The UPDATE SQL clause can


a) update only one row at a time
b) update more than one row at a time
c) delete more than one row at a time
d) delete only one row at a time

17. The UNION SQL clause can be used with


a) SELECT clause only
b) DELETE and UPDATE clauses
c) UPDATE clause only
d) All oF the mentioned

18. Which SQL statement is used to return only different values ?


a) SELECT DIFFERENT
b) SELECT UNIQUE
c) SELECT DISTINCT
d) SELECT ALL

19. Which SQL keyword is used to sort the result-set ?


a) ORDER BY
b) SORT
c) ORDER
d) SORT BY

20. How can you change “Hansen” into “Nilsen” in the “LastName” column in the Persons table?
a) UPDATE Persons SET LastName=’Hansen’ INTO LastName=’Nilsen’
b) MODIFY Persons SET LastName=’Nilsen’ WHERE LastName=’Hansen’
c) MODIFY Persons SET LastName=’Hansen’ INTO LastName=’Nilsen’
d) UPDATE Persons SET LastName=’Nilsen’ WHERE LastName=’Hansen’

21. Which of the following command makes the updates performed by the transaction permanent in the
database ?
a) ROLLBACK
b) COMMIT
c) TRUNCATE
d) DELETE

22. Which TCL command undo all the updates performed by the SQL in the transaction ?
a) ROLLBACK
b) COMMIT
c) TRUNCATE
d) DELETE

23. SQL query to find all the cities whose humidity is 95 .


a) SELECT city WHERE humidity = 95
b) SELECT city FROM weather WHERE humidity = 95
c) SELECT humidity = 89 FROM weather
d) SELECT city FROM weather

24. SQL query to find the temperature in increasing order of all cities.
a) SELECT city FROM weather ORDER BY temperature
b) SELECT city, temperature FROM weather
c) SELECT city, temperature FROM weather ORDER BY temperature
d) SELECT city, temperature FROM weather ORDER BY city

25. What is the meaning of LIKE ‘%0%0%’ ?


a) Feature begins with two 0’s
b) Feature ends with two 0’s
c) Feature has more than two 0’s
d) Feature has two 0’s in it, at any position

26. Find the names of these cities with temperature and condition whose condition is neither sunny nor
cloudy.
a) SELECT city, temperature, condition FROM weather WHERE condition NOT IN (‘sunny’,
‘cloudy’)
b) SELECT city, temperature, condition FROM weather WHERE condition NOT BETWEEN (‘sunny’,
‘cloudy’)
c) SELECT city, temperature, condition FROM weather WHERE condition IN (‘sunny’, ‘cloudy’)
d) SELECT city, temperature, condition FROM weather WHERE condition BETWEEN (‘sunny’,
‘cloudy’);
27. Find the name of those cities with temperature and condition whose condition is either sunny or
cloudy but temperature must be greater than 70.
a) SELECT city, temperature, condition FROM weather WHERE condition = ‘sunny’ AND condition =
‘cloudy’ OR temperature > 70
b) SELECT city, temperature, condition FROM weather WHERE condition = ‘sunny’ OR condition =
‘cloudy’ OR temperature > 70
c) SELECT city, temperature, condition FROM weather WHERE condition = ‘sunny’ OR condition =
‘cloudy’ AND temperature > 70
d) SELECT city, temperature, condition FROM weather WHERE condition = ‘sunny’ AND condition =
‘cloudy’ AND temperature > 70

28. Find all the tuples having temperature greater than ‘Paris’.
a) SELECT * FROM weather WHERE temperature > (SELECT temperature FROM weather WHERE
city = ‘Paris’
b) SELECT * FROM weather WHERE temperature > (SELECT * FROM weather WHERE city =
‘Paris’)
c) SELECT * FROM weather WHERE temperature > (SELECT city FROM weather WHERE city =
‘Paris’)
d) SELECT * FROM weather WHERE temperature > ‘Paris’ temperature

29. Find all the cities with temperature, condition and humidity whose humidity is in the range of 63 to
79.
a) SELECT * FROM weather WHERE humidity IN (63 to 79)
b) SELECT * FROM weather WHERE humidity NOT IN (63 AND 79)
c) SELECT * FROM weather WHERE humidity BETWEEN 63 AND 79
d) SELECT * FROM weather WHERE humidity NOT BETWEEN 63 AND 79

30. The command to remove rows from a table ‘CUSTOMER’ is


a) DROP FROM CUSTOMER
b) UPDATE FROM CUSTOMER
c) REMOVE FROM CUSTOMER
d) DELETE FROM CUSTOMER WHERE

31. What type of join is needed when you wish to include rows that do not have matching values?
a) Equi-join
b) Natural join
c) Outer join
d) All of the Mentioned

32. What type of join is needed when you wish to return rows that do have matching values?
a) Equi-join
b) Natural join
c) Outer join
d) All of the Mentioned

33. Which of the following is one of the basic approaches for joining tables?
a) Subqueries
b) Union Join
c) Natural join
d) All of the Mentioned

34. The following SQL is which type of join: SELECT CUSTOMER_T. CUSTOMER_ID, ORDER_T.
CUSTOMER_ID, NAME, ORDER_ID FROM CUSTOMER_T,ORDER_T WHERE CUSTOMER_T.
CUSTOMER_ID = ORDER_T. CUSTOMER_ID?
a) Equi-join
b) Natural join
c) Outer join
d) Cartesian join

35. A UNION query is which of the following?


a) Combines the output from no more than two queries and must include the same number of columns
b) Combines the output from no more than two queries and does not include the same number of
columns
c) Combines the output from multiple queries and must include the same number of columns
d) Combines the output from multiple queries and does not include the same number of columns

36. Which of the following statements is true concerning subqueries?


a) Involves the use of an inner and outer query
b) Cannot return the same result as a query that is not a subquery
c) Does not start with the word SELECT
d) All of the mentioned

37. Which of the following is a correlated subquery?


a) Uses the result of an inner query to determine the processing of an outer query
b) Uses the result of an outer query to determine the processing of an inner query
c) Uses the result of an inner query to determine the processing of an inner query
d) Uses the result of an outer query to determine the processing of an outer query

38. How many tables may be included with a join?


a) One
b) Two
c) Three
d) All of the Mentioned
39. The following SQL is which type of join: SELECT CUSTOMER_T. CUSTOMER_ID, ORDER_T.
CUSTOMER_ID, NAME, ORDER_ID FROM CUSTOMER_T,ORDER_T?
a) Equi-join
b) Natural join
c) Outer join
d) Cartesian join

40. Which is not a type of join in T-SQL?


a) Equi-join
b) Natural join
c) Outer join
d) Cartesian join

41. What is a view?


a) A view is a special stored procedure executed when certain event occurs
b) A view is a virtual table which results of executing a pre-compiled query
c) A view is a database diagram
d) None of the Mentioned

42. Which of the following is not a limitation of view?


a) ORDER BY Does Not Work
b) Index Created on View Used Often
c) Cross Database Queries Not Allowed in Indexed View
d) Adding Column is Expensive by Joining Table Outside View

43. Which of the following following statement is true?


a) Views could be looked as an additional layer on the table which enables us to protect intricate or
sensitive data based upon our needs
b) Views are virtual tables that are compiled at run time
c) Creating views can improve query response time
d) All of the Mentioned

44. SQL Server has mainly how many types of views?


a) one
b) two
c) three
d) four

45. Dynamic Management View is a type of


a) System Defined Views
b) User Defined View
c) Simple View
d) Complex View

46. Syntax for creating views is


a) CREATE VIEW AS SELECT
b) CREATE VIEW AS UPDATE
c) DROP VIEW AS SELECT
d) CREATE VIEW AS UPDATE

47. You can delete a view with ___________ command.


a) DROP VIEW
b) DELETE VIEW
c) REMOVE VIEW
d) TRUNCATE VIEW

48. What is SCHEMABINDING a VIEW?


a) Schema binding binds your views to the dependent physical columns of the accessed tables specified
in the contents of the view
b) These are stored only in the Master database
c) These types of view are defined by users on specified schema
d) These are used to show database self describing information

49. Which of the following is not a SQL Server INFORMATION_SCHEMA view?


a) INFORMATION_SCHEMA.CONSTRAINT_TABLE_USAGE
b) INFORMATION_SCHEMA.DOMAIN_CONSTRAINTS
c) INFORMATION_SCHEMA.KEY_COLUMN_USAGE
d) sys.dm_exec_connections

50. ___________ is stored only in the Master database.


a) Database-scoped Dynamic Management View
b) Complex View
c) Catalog View
d) None of the mentioned

51. Select __________ from instructor where dept name= ’Comp. Sci.’;
Which of the following should be used to find the mean of the salary ?
a) Mean(salary)
b) Avg(salary)
c) Sum(salary)
d) Count(salary)
52. The ________ connective tests for set membership, where the set is a collection of values produced
by a select clause. The _________ connective tests for the absence of set membership.
a) Or, in
b) Not in, in
c) In, not in
d) In, or

53. Select ID, GPA from student grades order by GPA ____________
Inorder to give only 10 rank on the whole we should use :
a) Limit 10
b) Upto 10
c) Only 10
d) Max 10

54. Suppose we are given a view tot credits (year, num credits) giving the total number of credits taken
by students in each year.The query that computes averages over the 3 preceding tuples in the specified
sort order is :
a) SELECT YEAR, avg(num credits)
OVER (ORDER BY YEAR ROWS 3 preceding) AS avg total credits
FROM tot credits;
b) SELECT YEAR, avg(num credits)
OVER (ORDER BY YEAR ROWS 3 unbounded preceding) AS avg total credits
FROM tot credits;
c) SELECT YEAR, MIN(num credits)
OVER (ORDER BY YEAR ROWS 3 unbounded preceding) AS avg total credits
FROM tot credits;
d) SELECT YEAR, SUM(num credits)
OVER (ORDER BY YEAR ROWS 3 unbounded preceding) AS avg total credits
FROM tot credits;

55. Which of the following is not the function of client ?


a) Compile queries
b) Query optimization
c) Receive queries
d) Result formatting and presentation

56. Which server can join the indexes when only multiple indexes combined can cover the query ?
a) SQL
b) DBMS
c) RDBMS
d) All of the mentioned
57. Select ________ dept_name from instructor;
Here which of the following displays the unique values of the column ?
a) All
b) From
c) Distinct
d) Name

58. Select ID, name, dept name, salary * 1.1 where instructor;
The query given below will not give an error. Which one of the following has to be replaced to get the
desired output ?
a) Salary*1.1
b) ID
c) Where
d) Instructor

59. Select * from student join takes using (ID);


The above query is equivalent to :
a) Select * from student inner join takes using (ID);
b) Select * from student outer join takes using (ID);
c) Select * from student left outer join takes using (ID);
d) All of the mentioned

60. The ______ clause allows us to select only those rows in the result relation of the ____ clause that
satisfy a specified predicate.
a) Where, from
b) From, select
c) Select, from
d) From, where

61. Which of the following is not a class of constraint in SQL Server ?


a) NOT NULL
b) CHECK
c) NULL
d) UNIQUE

62. Point out the correct statement :


a) CHECK constraints enforce domain integrity
b) UNIQUE constraints enforce the uniqueness of the values in a set of columns
c) In a UNIQUE constraint, no two rows in the table can have the same value for the columns
d) All of the mentioned
63. Which of the following constraint does not enforce uniqueness ?
a) UNIQUE
b) Primary key
c) Foreign key
d) None of the mentioned

64. Constraints can be applied on :


a) Column
b) Table
c) Field
d) All of the mentioned

65. Point out the wrong statement :


a) Table constraints must be used when more than one column must be included in a constraint
b) A column constraint is specified as part of a column definition and applies only to that column
c) A table constraint is declared independently from a column definition and can apply to more than
one column in a table
d) Primary keys allow for NULL as one of the unique values

66. Purpose of foreign key constraint in SQL Server is :


a) FOREIGN KEY constraints identify and enforce the relationships between tables
b) A foreign key in one table points to a candidate key in another table
c) You cannot insert a row with a foreign key value, except NULL, if there is no candidate key with
that value
d) None of the mentioned

67. Which of the following is not a foreign key constraint ?


a) NO ACTION
b) CASCADE
c) SET NULL
d) All of the mentioned

68. Which of the following foreign key constraint specifies that the deletion fails with an error ?
a) NO ACTION
b) CASCADE
c) SET NULL
d) All of the mentioned

69. How many types of constraints are present in SQL Server ?


a) 4
b) 5
c) 6
d) 7

70. Which of the constraint can be enforced one per table ?


a) Primary key constraint
b) Not Null constraint
c) Foreign Key constraint
d) Check constraint

S-ar putea să vă placă și