Online Test SQL
- Inner join
- Left outer join
- Right outer join
- Self join
Answer: Answer is c
Further Reading:
Useful resources, Join, Types of Joins
- Alter table t add primary key(c1);
- Alter table t add constraint pk primary key(c1);
- Alter table t add (constraint pk primary key(c1));
- Alter table t add pk constraint primary key(c1);
Answer: Answer is a
Further Reading:
Useful resources,ALTER TABLE, SQL PRIMARY KEY Constraint
- primary query -> sub query -> sub sub query and so on
- sub sub query -> sub query -> prime query
- the whole query is interpreted at one time
- there is no fixed sequence of interpretation, the query parser takes a decision on the fly
Answer: Answer is b
Further Reading:
Primary query results depend on the sub query results, so sub query my execute first then primary query will execute. Useful resources, Subquery Fundamentals
- Data Description Language
- Dynamic Data Language
- Data Definition Language
- Data Derived Language
- Descriptive Data Language
Answer: Answer is c
Further Reading:
Useful resources, DDL
Books
------
BookId
BookName
AuthorId
SubjectId
PopularityRating (the popularity of the book on a scale of 1 to 10)
Language (such as French, English, German etc)
Subjects
---------
SubjectId
Subject (such as History, Geography, Mathematics etc)
Authors
--------
AuthorId
AuthorName
Country
What is the query to determine the names of the Authors who have written more than 1 book?
- select AuthorName from Authors where AuthorId in(select AuthorId from Books group by AuthorId having count(*)>1)
- select AuthorName from Authors, Bookswhere Authors.AuthorId=Books.AuthorId and count(BookId)>1
- select AuthorName from Authors, Bookswhere Authors.AuthorId=Books.AuthorIdgroup by AuthorName having count(*)>1
- select AuthorName from Authors where AuthorId in(select AuthorId from Books having count(BookId)>1)
Answer: Answer is a, c
Further Reading:
select (2/2/4) from tab1; where tab1 is a table with one row.
This would give a result of:
- 4
- 2
- 1
- 5
- 25
- 0
- 8
- 24
Answer: Answer is f
- Conceptual level
- View level
- Procedural level
- None of the above
Answer: Answer is b
Further Reading:
Useful resources,data abstraction
- A simple view is one which derives data from only one table
- A simple view is one which contains no functions or groups of data
- A complex view is one which derives data from many tables
- A complex view is one which may contain functions
- A complex view cannot contain groups of data
- A complex view is a combination of more than one simple view
- A table can either have a simple or complex view, not both
Answer: Answer is a, b, c, d
select (age + 3 * 4 / 2 - 8) from emp
- +
- -
- /
- *
Answer: Answer is d
Further Reading:
Useful resources, Operator Precedence
- Recover from the transaction failure
- Update the transaction
- Retrieve old records
- None of the above
Answer: Answer is a
Further Reading:
Useful resources,ROLLBACK TRANSACTION
- Logical
- Arithmetic
- Assignment
- Ternary
- Relational
- Numeric
- Comparison
- None of the above
Answer: Answer is g
Further Reading:
Useful resources,Comparison Operators
- Drop
- Create
- Alter
- Revoke
- Explain plan
- Insert
- Update
- Delete
Answer: Answer is d, e, f, g, h
Further Reading:
Useful resources, DDL Statements
Marketing, Designing, production, Packing
What will be the result of the following query?
select * from table where department < 'marketing';
- The query will return "Designing, Packing"
- The query will return "Designing, production, Packing"
- The query will return "packing"
- Strings cannot be compared using < operator
- The query will return "Designing"
Answer: Answer is e
Books
------
BookId
BookName
AuthorId
SubjectId
PopularityRating (the popularity of the book on a scale of 1 to 10)
Language (such as French, English, German etc)
Subjects
---------
SubjectId
Subject (such as History, Geography, Mathematics etc)
Authors
--------
AuthorId
AuthorName
Country
What is the query to determine how many books, with a popularity rating of more than 7, have been written on each subject?
- select subject,count(*) as Books from books,subjectswhere books.popularityrating > 7group by subjects.subject
- select subject,count(*) as Books from books,subjectswhere books.authorid=subjects.authorid and books.popularityrating > 7group by subjects.subject
- select subject,count(*) as Books from books,subjectswhere books.subjectid=subjects.subjectid and books.popularityrating = 7group by subjects.subject
- select subject,count(*) as Books from books,subjectswhere books.subjectid=subjects.subjectid and books.popularityrating > 7group by subjects.subject
Answer: Answer is a
- Tables once created cannot be modified to add columns
- Constraints can only be given while table creation
- One can easily create a table from a given table
- When a table is created from another table, all the constraints are copied as well
- The width of the columns cannot be modified
- Columns cannot be removed from a table
Answer: Answer is c
- Data Flow Chart
- Flow Chart
- Directed Chart
- Entity-Relationship Diagram
- None of the above
Answer: Answer is d
- A primary key constraint can be disabled
- Information about the constraints on a table can be retrieved from the data dictionary
- Information about the columns on which the constraints have been applied can be retrieved from the data dictionary
- There can be only one unique key in a table
- If a column has null values then the not null constraint cannot be applied to that column
- There can be more than one primary key
Answer: Answer is d, f
- Schema
- Instance
- Table
- Cluster
- View
- Index
- None of the above
Answer: Answer is b
1 Create table Pers
2 (EmpNo Number(4) not null,
3 EName Char not null,
4 Join_dt Date not null,
5 Pay Number)
Which line contains an error?
- 1
- 2
- 3
- 4
- 5
Answer: Answer is b
- Select
- order by
- where
- having
- group by
- 1,2,3,4,5
- 1,3,5,4,2
- 1,3,5,2,4
- 1,3,2,5,4
- 1,3,2,4,5
- 1,5,2,3,4
- 1,4,2,3,5
- 1,4,3,2,5
Answer: Answer is b
Further Reading:
The order should be like this select>where>group by>having>order by. Useful resources, SQL basic queries, query fundamental, HAVING Clause
- A table is a multiset of rows
- A table is a two-dimensional array of rows and columns
- A table is always dependent on other tables
- A third normal form table is a table free of redundant data
- A table must have a primary key
Answer: Answer is b, d
- Returns the remainder after division
- Modifies the column definition
- Modifies the definition of a table
- None of the above
Answer: Answer is a
Further Reading:
Useful resources,Mod
LAST_NAME DEPARTMENT_ID SALARY ALLEN 10 3000 MILLER 20 1500 King 20 2200 Davis 30 5000
Which of the following Subqueries will execute without any error?
- SELECT distinct department_id FROM employees Where salary = (SELECT AVG(salary) FROM employees GROUP BY department_id);
- SELECT distinct department_id FROM employees Where salary > (SELECT AVG(salary) FROM employees GROUP BY department_id);
- SELECT distinct department_id FROM employees Where salary > ANY (SELECT AVG(salary) FROM employees GROUP BY department_id);
- SELECT distinct department_id FROM employees Where salary > ALL (SELECT AVG(salary) FROM employees GROUP BY department_id);
- SELECT distinct department_id FROM employees Where salary < (SELECT AVG(salary) FROM employees GROUP BY department_id);
Answer: Answer is c, d
STUDENT_ID INT SEMESTER_END DATETIME GPA FLOAT
Which of the following statements finds the highest Grade Point Average (GPA) per semester?
- SELECT MAX(gpa) FROM student_grades WHERE gpa IS NOT NULL
- SELECT (gpa) FROM student_grades GROUP BY semester_end WHERE gpa IS NOT NULL
- SELECT MAX(gpa) FROM student_grades WHERE gpa IS NOT NULL GROUP BY semester_end
- SELECT MAX(gpa) GROUP BY semester_end WHERE gpa IS NOT NULL FROM student_grades
- SELECT MAX(gpa) FROM student_grades GROUP BY semester_end WHERE gpa IS NOT NULL
Answer: Answer is c
Update OrderTable set OrderDiscount=OrderDiscount*1.10
- Increases OrderDiscount of first row by 10%
- Increases OrderDiscount of all rows by 10%
- Does nothing without where clause
- Gives an error due to lack of where clause
Answer: Answer is b
- Union
- Union all
- Intersect
- Minus
- Minus all
Answer: Answer is e
Further Reading:
Useful resources,Set Operations
What clause should be used to display the rows of a table in ascending order of a particular column?
- Where
- Order By
- Group By
- Having
- First Group By and then Having
- Like
- Between
Answer: Answer is b
Further Reading:
Useful resources,ORDER BY Clause
a)The FLOOR function returns the smallest integer greater or equal to the argument.
(b)The CEIL function gives the largest integer equal to or less that the argument.
- (a) is true
- (b) is true
- both (a) and (b) are true
- both (a) and (b) are false
Answer: Answer is d
Further Reading:
- True
- False
Answer: Answer is a
select empno, DISTINCT ename, Salary from emp;
- EMPNO, unique value of ENAME and then SALARY are displayed
- EMPNO, unique value ENAME and unique value of SALARY are displayed
- DISTINCT is not a valid keyword in SQL
- No values will be displayed because the statement will return an error
Answer: Answer is d
- select * from orders where sum(amount) > 20000
- select * from orders where sum(amount) > 20000 order by OrderDate
- select * from orders group by OrderDate having sum(amount)>20000
- select * from orders group by OrderDate where sum(amount) > 20000
Answer: Answer is c
Further Reading:
Useful resources, HAVING clause
- 1
- 2
- 3
- 4
- 5
- 6
- None of the above
Answer: Answer is g
Further Reading:
Useful resources, Maximum Capacity Specifications for SQL Server
1)It calculates the results of the group functions of each group
2)It groups those rows together based on the group by clause
3)It orders the groups based on the results of the group functions in the order by clause
4)It chooses and eliminates groups based on the having clause
5)It chooses rows based on the where clause
Arrange the above steps in the correct order of execution:
- 4,3,5,1,2
- 4,5,3,2,1
- 5,2,1,4,3
- 5,2,3,4,1
- 2,3,1,4,5
- 2,3,1,5,4
- 1,2,3,4,5
- 3,2,1,4,5
Answer: Answer is c
- CONCAT()
- SUBSTR()
- UPPER()
- LOWER()
- REPLACE()
Answer: Answer is c
- Query Parser
- The Database Manager
- Query Optimization
- Database Administrator
Answer: Answer is a
- Select * from A.Sales join B.Sales
- Select * from A.Sales union all B.Sales
- Select * from A.Sales, B.Sales
- None of the above
Answer: Answer is b
- Group of users
- Group of indexes
- Method of storing tables that are intimately related and often joined together into the same area of the disk
- Compressed datafile
- Segment of a partitioned table
- Group of constraints
- Group of databases
- Group of roles/p>
Answer: Answer is c
Further Reading:
Useful resources, cluster
- Methods to resolve integrated domain names (IDNs), such domain names are special embedded names
- Methods to swap bytes between network byte order and host byte order
- Methods to convert internationalized domain names (IDNs) between a normal Unicode representation and an ASCII Compatible Encoding (ACE) representation
- This class does not exist
- None of the above
Answer: Answer is c
Further Reading:
Useful resources,Class IDN
- File
- DataOutput
- Directory
- FileDescriptor
- FileOutputStream
Answer: Answer is c
Further Reading:
Useful resources, Directory Class
- With DDL, you can create and remove tables, schemas, domains, indexes and views.
- SELECT, INSERT and UPDATE are DCL commands.
- GRANT and REVOKE are DML commands.
- COMMIT and ROLLBACK are DCL commands.
Answer: Answer is a
Further Reading:
Post a Comment