1.

You have two tables called Employee and Department.

Employee

Field Type
EmployeeId int
EmployeeName text
DepartmentId int

Department

Field Type
DepartmentId int
DepartmentName text

Sample:

Employee

EmployeeId EmployeeName departmentId
1 Mark 1
2 John 1
3 Mike 1
4 Mary 2
5 Stacy 2

Sample:

Department

DepartmentId DepartmentName
1 IT
2 HR
3 Payroll
4 Admin

Sample Output

DepartmentName EmployeeName
IT Mark
IT John
IT Mike
HR Mary
HR Stacy

Using the Employee and Department tables, which of the following queries will return the same sample output?

 1. select DepartmentName,EmployeeName from Employee JOIN Department onDepartments.DepartmentId=EmployeeId.DepartmentId;

 2. select DepartmentName,EmployeeName from Employee LEFT JOIN Department onDepartments.DepartmentId=EmployeeId.DepartmentId;

 3.  select DepartmentName,EmployeeName from Employee RIGHT JOIN Department onDepartments.DepartmentId=EmployeeId.DepartmentId;
2.

In an SQL Server, which of the following queries will you use to get the list of all the employees working in any department along with all those who are not assigned to any department?

EMP_ID User_name F_Name L_name Dep_ID
1 AAlice Alice Smith 1
2 BBob Bob Jones 1
3 BBen Ben Johnson 2
4 MMike Mike White 2
5 AAnita Anita Williams 3
6 LLisa Lisa Davis 3
7 MMary Mary Brown 4
8 JJohn John Wilson 4

 

 

 

 

 

 

 

 

Dep_ID Dep_name
1 Technical Innovations
2 Technical Support
3 Operations
4 Customer Delight
3.

What will be the result of the following MySQL statements:

 
ΑLTER TΑBLE test_tbl DROP col1;
ΑLTER TΑBLE test_tbl ΑDD col1 INT ΑFTER col2;
4.

What will be the result of the following MySQL query:

 
SELECT * FROM table_name WHERE col_1 = MAX(col_1);
5.

In MySQL, which of the following is the correct syntax to modify the definition of an existing table?

6.

In SQL, which of the following operations is equivalent to performing SELECT on a MERGE statement?

7.

The following tables and dataset are created in the database:

CREATE TABLE students (st_id INT NOT NULL AUTO_INCREMENT, st_name VARCHAR(255), PRIMARY KEY (st_id) );
CREATE TABLE library_issue ( lib_issue_id INT NOT NULL AUTO_INCREMENT, st_id INT NOT NULL, PRIMARY KEY (lib_id), FOREIGN KEY (student_id) REFERENCES students (st_id) );
CREATE TABLE books_library (book_id INT NOT NULL AUTO_INCREMENT, book_name VARCHAR(255), PRIMARY KEY (book_id) );
CREATE TABLE books_issue_students ( lib_issue_id INT NOT NULL, book_id INT NOT NULL, PRIMARY KEY (lib_issue_id, book_id,), FOREIGN KEY (lib_issue_id) REFERENCES library_issue ( lib_issue_id), FOREIGN KEY (book_id) REFERENCES books_library (book_id) );


Consider the tables and data set, what will be the output when we the following SQL statement is executed?

INSERT INTO (issue_id, book_id) VALUES (1,2);

Table name: students

st_id st_name
1 Alice
2 Bob
3 Ben
4 Mike
5 Tara
6 Anita
7 Lisa
8 Mary
9 John
10 Paul


Table name: library_issue

lib_issue_id st_id
1 1
2 4
3 5
4 7
5 5
6 9
7 4
8 7
9 5


Table Name: books_library

book_id book_name
1 Book1
2 Book2
3 Book3
4 Book4
5 Book5
6 Book6
7 Book7
8 Book8
9 Book9


Table Name: books_issue_students

lib_issue_id book_id
1 2
2 3
2 4
3 5
4 7
4 1
5 6
6 13
7 14
7 15
8 10
9 12
8.

The following tables and data set is created in database:
 

CREATE TABLE students (st_id INT NOT NULL AUTO_INCREMENT, st_name VARCHAR(255), PRIMARY KEY (st_id) );
CREATE TABLE library_issue ( lib_issue_id INT NOT NULL AUTO_INCREMENT, st_id INT NOT NULL, PRIMARY KEY (lib_id), FOREIGN KEY (student_id) REFERENCES students (st_id) );
CREATE TABLE books_library (book_id INT NOT NULL AUTO_INCREMENT, book_name VARCHAR(255), PRIMARY KEY (book_id) );
CREATE TABLE books_issue_students ( lib_issue_id INT NOT NULL, book_id INT NOT NULL, PRIMARY KEY (lib_issue_id, book_id,), FOREIGN KEY (lib_issue_id) REFERENCES library_issue ( lib_issue_id), FOREIGN KEY (book_id) REFERENCES books_library (book_id) );
 

Consider the given tables and data set. How many records will be displayed when the following SQL query is executed?

SELECT library_issue.lib_issue_id, students.st_name FROM library_issue INNER JOIN students ON library_issue.st_id = students.st_id ORDER BY lib_issue.id;

Table name: students

st_id st_name
1 Alice
2 Bob
3 Ben
4 Mike
5 Tara
6 Anita
7 Lisa
8 Mary
9 John
10 Paul


Table name: library_issue

lib_issue_id st_id
1 1
2 4
3 5
4 7
5 5
6 9
7 4
8 7
9 5


Table Name: books_library

book_id book_name
1 Book1
2 Book2
3 Book3
4 Book4
5 Book5
6 Book6
7 Book7
8 Book8
9 Book9


Table Name: books_issue_students

lib_issue_id book_id
1 2
2 3
2 4
3 5
4 7
4 1
5 6
6 13
7 14
7 15
8 10
9 12
9.

In MySQL, which of the following returns all the databases whose names start with db?

10.

In MySQL, which of the following is not a column comparison operator?