Finals Lecture 2: SQL Flashcards

1
Q

SQL stands for ___.

A

Structured Query Language

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

It is used for storing and managing data in Relational Database Management System (RDBMS).

A

SQL

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is SQL used for?

A

It is used for storing and managing data in Relational Database Management System (RDBMS).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

RDBMS

A

Relational Database Management System

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

It is a standard language for Relational Database System.

A

SQL

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

SQL enables user to…

A

create, read, update and delete relational databases and tables.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

All the RDBMS like MySQL, Informix, Oracle, MS Access and SQL Server use ___ as their standard database language.

A

SQL

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

SQL allows users to ___ the database in a number of ways, using English-like statements.

A

query

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Structure query language is ___. Generally, keywords of SQL are written in uppercase.

A

not case sensitive

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Statements of SQL are ___. We can use a ___ on one or ___.

A

dependent on text lines; single SQL statement; multiple text line

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Using the ___, you can perform most of the actions in a database.

A

SQL statements

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

SQL depends on ___ and ___.

A

tuple relational calculus; relational algebra

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

SQL follows the following rules:

A
  1. is not case sensitive but is usually written in uppercase
  2. dependent on text lines
  3. uses sql statements to perform actions in a db
  4. depends on tuple relational calculus and relational algebra
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

When an ___ is executing for any RDBMS, then the system figure out the best way to ___ and the ___ determines that how to interpret the task.

A

SQL command; carry out the request; SQL engine

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

In the process, various components are included. These components can be…

A

optimization Engine, Query engine, Query dispatcher, classic, etc.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

All the non-SQL queries are handled by the ___, but SQL query engine won’t ___.

A

classic query engine; handle logical files

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

What is the SQL Process

A

When an SQL command is submitted:

system&raquo_space; figures out the best way to carry out the request

SQL engine» determines how to interpret the task

classic query engine&raquo_space; handles non-SQL queries

SQL query engine&raquo_space; handles SQL queries but not logical files

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

Graphical framework of SQL Process

A

SQL Query&raquo_space; Query Language Processor -> [Parser + Optimizer]&raquo_space; DBMS Engine -> [File Manager + Transaction Manager]&raquo_space; Physical Database

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

What is Advantages of SQL?

A
  • High speed
  • No coding needed
  • Well defined standards
  • Portability
  • Interactive language
  • Multiple data view
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

What is SQL Datatype?

A

SQL Datatype is used to define the values that a column can contain. Every column is required to have a name and data type in the database table

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

Enlist the SQL datatypes

A

Binary
Numeric
Extract Numeric
String
Date

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

SQL commands are ___. It is used to communicate with the database. It is also used to perform specific tasks, functions, and queries of data.

A

instructions;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

It is used to communicate with the database.

A

SQL commands

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

It is also used to perform specific tasks, functions, and queries of data.

A

SQL commands

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Q

SQL can perform various tasks like: (5)

A

create a table, add data to tables, drop the table, modify the table, set permission for user

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
26
Q

Types of SQL Commands

A

DDL, DML, DCL, TCL, DQL

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
27
Q

DDL

A

Data Definition Language

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
28
Q

DML

A

Data Manipulation Language

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
29
Q

DCL

A

Data Control Language

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
30
Q

TCL

A

Transaction Control Language

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
31
Q

DQL

A

Data Query Language

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
32
Q

Commands under DDL

A

Create, Drop, Alter, Truncate

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
33
Q

Commands under DML

A

Insert, Update, Delete

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
34
Q

Commands under DCL

A

Grant, Revoke

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
35
Q

Commands under TCL

A

Commit, Rollback, Save point

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
36
Q

Commands under DQL

A

Select

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
37
Q

SQL command that changes the structure of the table like creating a table, deleting a table, altering a table, etc.

A

DDL, Data Definition Language

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
38
Q

DDL command, is used to create a new table in the database.

A

CREATE

Syntax:
CREATE TABLE TABLE_NAME (COLUMN_NAME DATATYPES[,….]);

Example:
CREATE TABLE EMPLOYEE(Name VARCHAR2(20), Email VARCHAR2(100), DOB DATE);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
39
Q

DDL command, is used to delete both the structure and record stored in the table.

A

DROP

Syntax:
DROP TABLE ;

Example:
DROP TABLE EMPLOYEE;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
40
Q

DDL command, is used to alter the structure of the database. This change could be either to modify the characteristics of an existing attribute or probably to add a new attribute.

A

ALTER

Syntax:
ALTER TABLE table_name ADD column_name COLUMN-definition;
ALTER TABLE MODIFY(COLUMN DEFINITION….);

Example:
ALTER TABLE STU_DETAILS ADD(ADDRESS VARCHAR2(20));
ALTER TABLE STU_DETAILS MODIFY (NAME VARCHAR2(20));

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
41
Q

DDL command, is used to delete all the rows from the table and free the space containing the table.

A

TRUNCATE

Syntax:
TRUNCATE TABLE table_name;

Example:
TRUNCATE TABLE EMPLOYEE;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
42
Q

___ are used to modify the database. It is responsible for all form of CHANGES in the database.

A

DML, Data Manipulation Language

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
43
Q

The command of DML is ___ that means it can’t permanently save all the changes in the database. They can be ___.

A

not auto-committed; rollback

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
44
Q

DML command, the ___ is a SQL query. It is used to insert data into the row of a table.

A

INSERT statement;

INSERT

Syntax:
INSERT INTO TABLE_NAME (col1, col2, col3,…. col N) VALUES (value1, value2, value3, …. valueN);

OR

INSERT INTO TABLE_NAME VALUES (value1, value2, value3, …. valueN);

Example:
INSERT INTO XYZ (Author, Subject) VALUES (“Sonoo”, “DBMS”);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
45
Q

DML command, is used to update or modify the value of a column in the table.

A

UPDATE

Syntax:
UPDATE table_name SET [column_name1= value1,…column_nameN = valueN] [WHERE CONDITION]

Example:
UPDATE students SET User_Name = ‘Sonoo’ WHERE Student_Id = ‘3’

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
46
Q

___ are used to GRANT and TAKE BACK authority from any database user.

A

DCL commands

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
47
Q

DCL command, is used to give user access privileges to a database.

A

GRANT

Example:
GRANT SELECT, UPDATE ON MY_TABLE TO SOME_USER, ANOTHER_USER;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
48
Q

DCL command, is used to take back permissions from the user.

A

REVOKE

Example:
REVOKE SELECT, UPDATE ON MY_TABLE FROM USER 1, USER 2;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
49
Q

___ can only use with DML commands like INSERT, DELETE and UPDATE only

A

TCL commands

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
50
Q

These operations are automatically committed in the database that’s why they cannot be used while creating tables or dropping them.

A

TCL, transaction control language

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
51
Q

TCL command, is used to save all the transactions to the database.

A

COMMIT

Syntax:

COMMIT;

Example:
DELETE FROM CUSTOMERS WHERE AGE = 25;
COMMIT;

52
Q

TCL command, is used to undo transactions that have not already been saved to the database.

A

ROLLBACK

Syntax:

ROLLBACK;

Example:
DELETE FROM CUSTOMERS WHERE AGE = 25;
ROLLBACK;

53
Q

TCL command, is used to roll the transaction back to a certain point without rolling back the entire transaction.

A

SAVEPOINT

Syntax:
SAVEPOINT SAVEPOINT_NAME;

54
Q

___ is used to fetch the data from the database.

A

DQL, data query language

55
Q

It uses only one command: SELECT

A

DQL

56
Q

This is the same as the projection operation of relational algebra. It is used to select the attribute based on the condition described by WHERE clause.

A

SELECT

Syntax:
SELECT expressions FROM TABLES WHERE conditions;

Example:
SELECT emp_name FROM employee WHERE age > 20

57
Q

SQL Operators, what are the various types?

A

Arithmetic Operator, Comparison Operator, Logical Operator

58
Q

SQL Comparison Operators

A

+ (adds the value of both operands);
- (is used to subtract the right-hand operand from the left-hand - operand.)
* (used to multiply the value of both operands)
/ (used to divide the left-hand operand by the right-hand operand)
% (used to divide the left-hand operand by the right-hand operand and returns reminder)

59
Q

SQL Arithmetic Operators

A

= (checks if two operands values are equal or not, if the values are equal then condition becomes true)
!= (checks if two operands values are equal or not, if values are not equal, then condition becomes true)
<> (checks if two operands values are equal or not, if values are not equal then condition becomes true)
> (checks if the left operand value is greater than right operand value, if yes then condition becomes true)
< (checks if the left operand value is less than right operand value, if yes then condition becomes true)
>= (checks if the left operand value is greater than or equal to the right operand value, if yes then condition becomes true)
<= (checks if the left operand value is less than or equal to the right operand value, if yes then condition becomes true)
!< (checks if the left operand value is not less than the right operand value, if yes then condition becomes true)
!> (checks if the left operand value is not greater than the right operand value, if yes then condition becomes true)

60
Q

SQL Logical Operators

(1) compares a value to all values in another value set

(2) allows the existence of multiple conditions in an SQL statement

(3) compares the values in the list according to the condition

(4) is used to search for values that are within a set of values

(5) compares a value to that specified list value

(6) reverses the meaning of any logical operator

(7) combines multiple conditions in SQL statements

(8) is used to search for the presence of a row in a specified table

(9) compares a value to similar values using wildcard operator

A

(1) All
(2) AND
(3) ANY
(4) Between
(5) IN

(6) NOT
(7) OR
(8) EXIST
(9) LIKE

61
Q

Example:

SQL> CREATE TABLE EMPLOYEE (
EMP_ID INT NOT NULL,
EMP_NAME VARCHAR (25) NOT NULL,
PHONE_NO INT NOT NULL,
ADDRESS CHAR (30),
PRIMARY KEY (ID)
);

A
  • DESC EMPLOYEE;
  • DELETE FROM table_name WHERE condition
  • DROP TABLE “table_name”;
  • SELECT * FROM table_name;
  • INSERT INTO TABLE_NAME VALUES (value1, value2, value 3, …. Value N);
  • INSERT INTO TABLE_NAME[(col1, col2, col3,…. col N)] VALUES (value1, value2, value 3, …. Value N);
  • UPDATE table_name SET column_name = value WHERE condition;
  • UPDATE table_name SET column_name = value1, column_name2 = value WHERE condition;
  • DELETE FROM table_name WHERE some_condition;
62
Q

Views in SQL are considered as a ___. A ___ also contains rows and columns.

A

virtual table; view

63
Q

To create the view, we can ___ from one or more tables present in the database.

A

select the fields

64
Q

A ___ can either have specific rows based on certain condition or all the rows of a table.

A

view

65
Q

Creating view

A view can be created using the ___ statement. We can create a view from a ___.

A

CREATE VIEW; single table or multiple tables

Syntax:
CREATE VIEW view_name AS
SELECT column1, column2…..
FROM table_name
WHERE condition;

66
Q

Creating View from a single table:

A

CREATE VIEW DetailsView AS
SELECT NAME, ADDRESS
FROM Student_Details
WHERE STU_ID < 4

67
Q

Creating View from multiple tables:

A

In the given example, a view is created named MarksView from two tables Student_Detail and Student_Marks.

CREATE VIEW MarksView AS
SELECT Student_Detail.NAME, Student_Detail.ADDRESS, Student_Marks.MARKS
FROM Student_Detail, Student_Mark
WHERE Student_Detail.NAME = Student_Marks.NAME;

SELECT * FROM MarksView;
DROP VIEW view_name;

68
Q

View from multiple tables can be created by simply ___.

A

including multiple tables in the SELECT statement

69
Q

___ are special lookup tables. It is used to retrieve data from the database very fast.

A

Indexes

70
Q

An ___ is used to speed up select queries and where clauses. But it shows down the data input with insert and update statements.

A

Index

71
Q

Indexes can be created or dropped without affecting the data.

True | False

A

True

72
Q

An index in a database is just like an index in the back of a book.

To create Index statement:

A

CREATE INDEX index_name ON table_name (column1, column2, …);

73
Q

Unique Index statement

A

Syntax:
CREATE UNIQUE INDEX index_name ON table_name (column1, column2, …);

Example:
CREATE UNIQUE INDEX websites_idx ON websites (site_name);

74
Q

Drop Index Statement

A

Syntax:
DROP INDEX index_name;

Example:
DROP INDEX websites_idx;

75
Q

A ___ is a query within another SQL query and embedded within the WHERE clause.

A

Subquery

76
Q

A subquery can be placed in a number of SQL clauses like ___ clause, ___ clause, ___ clause

A

WHERE; FROM; HAVING

77
Q

You can use Subquery with ___ statements along with the operators like =, <, >, >=, <=, IN, BETWEEN,

A

SELECT, UPDATE, INSERT, DELETE

78
Q

A subquery is a…

A

query within another query

79
Q

In a subquery…

The outer query is known as the ___, and the inner query is known as a ___.

A

main query; subquery

80
Q

Subqueries are on the right side of the ___. A subquery is enclosed in ___.

A

comparison operator; parentheses

81
Q

In the Subquery, ___ command cannot be used. But ___ command can be used to perform the same function as ___ command.

A

ORDER BY; GROUP BY, ORDER BY

82
Q

SQL subqueries are most frequently used with the ___.

A

Select statement

Syntax:
SELECT column_name
FROM table_name
WHERE column_name expression operator
( SELECT column_name from table_name WHERE … );

Example:
SELECT *
FROM EMPLOYEE
WHERE ID IN (SELECT ID
FROM EMPLOYEE
WHERE SALARY > 4500)

83
Q

SQL subquery can also be used with the ___.

In the insert statement, data returned from the subquery is used to___.

A

Insert statement; insert into another table

84
Q

In the subquery, the ___ can be modified with any of the character, date functions.

A

selected data

Syntax:
INSERT INTO table_name (column1, column2, column3….)
SELECT * FROM table_name WHERE VALUE OPERATOR

Example:
INSERT INTO EMPLOYEE_BKP
SELECT * FROM EMPLOYEE
WHERE ID IN (SELECT ID
FROM EMPLOYEE);

85
Q

Subqueries with the UPDATE Statement

A

The subquery of SQL can be used in conjunction with the Update statement.

86
Q

When a subquery is used with the Update statement, then either single or multiple columns in a table can be updated.

A

Syntax:
UPDATE table SET column_name = new_value WHERE VALUE OPERATOR (SELECT COLUMN_NAME FROM TABLE_NAME WHERE condition);

Example:
Let’s assume we have an EMPLOYEE_BKP table available which is backup of EMPLOYEE table. The given example updates the SALARY by .25 times in the EMPLOYEE table for all employee whose AGE is greater than or equal to 29.

UPDATE EMPLOYEE
SET SALARY = SALARY * 0.25
WHERE AGE IN (SELECT AGE FROM CUSTOMERS_BKP
WHERE AGE >=

87
Q

Subqueries with the DELETE Statement

A

Syntax:
DELETE FROM TABLE_NAME WHERE VALUE OPERATOR (SELECT COLUMN_NAME FROM TABLE_NAME WHERE condition);

Example:
Let’s assume we have an EMPLOYEE_BKP table available which is backup of EMPLOYEE table. The given example deletes the records from the EMPLOYEE table for all EMPLOYEE whose AGE is greater than or equal to 29.

DELETE FROM EMPLOYEE
WHERE AGE IN (SELECT AGE FROM EMPLOYEE_BKP
WHERE AGE >= 29

88
Q

SQL Clauses

A

Group by Clause
Having Clause
Order by Clause

89
Q

SQL ___ statement is used to arrange identical data into groups.

A

GROUP BY

90
Q

The GROUP BY statement is used with the SQL ___ statement.

A

SELECT

91
Q

The ___ statement follows the WHERE clause in a SELECT statement and precedes the ORDER BY clause.

A

GROUP BY

92
Q

The GROUP BY statement is used with ___.

A

aggregation function

93
Q

SQL GRUOP BY example

A

Syntax:
SELECT column
FROM table_name
WHERE conditions
GROUP BY column
ORDER BY column

Example:
SELECT COMPANY, COUNT(*)
FROM PRODUCT_MAST
GROUP BY COMPANY;

94
Q

___ is used to specify a search condition for a group or an aggregate.

A

HAVING clause

95
Q

___ is used in a GROUP BY clause. If you are not using GROUP BY clause then you can use HAVING function like a ___ clause

A

Having; WHERE

96
Q

Example of using the HAVING clause

A

Syntax:
SELECT column1, column2 FROM table_name
WHERE conditions
GROUP BY column1, column2
HAVING conditions
ORDER BY column1, column2;

Example:
SELECT COMPANY, COUNT()
FROM PRODUCT_MAST
GROUP BY COMPANY
HAVING COUNT(
)>2;

97
Q

The ___ clause sorts the result-set in ascending or descending order.

A

ORDER BY

98
Q

It sorts the records in ascending order by default. ___ is used to sort the records in descending order.

A

ORDER BY; DESC keyword

99
Q

Example of using the ORDER BY clause

A

Syntax:
SELECT column1, column2
FROM table_name
WHERE condition
ORDER BY column1, column2… AS C|DESC;

Example:
SELECT *
FROM CUSTOMER
ORDER BY NAME;
OR
SELECT *
FROM CUSTOMER
ORDER BY NAME DESC;

100
Q

SQL Aggregate Functions

A

COUNT
SUM
AVG
MAX
MIN

101
Q

___ is used to Count the number of rows in a database table. It can work on both numeric and non-numeric data types.

A

COUNT function

102
Q

COUNT function uses the ___ that returns the count of all the rows in a specified table. ___ considers duplicate and Null.

A

COUNT(*)

103
Q

Example of using the COUNT function

A

Syntax:
COUNT(*) or COUNT( [ALL|DISTINCT] expression )

Example:
 SELECT COUNT() FROM PRODUCT_MAST;
 SELECT COUNT(
) FROM PRODUCT_MAST; WHERE RATE>=20;
 SELECT COUNT(DISTINCT COMPANY) FROM PRODUCT_MAST;
 SELECT COMPANY, COUNT() FROM PRODUCT_MAST GROUP BY COMPANY;
 SELECT COMPANY, COUNT(
) FROM PRODUCT_MAST GROUP BY COMPANY HAVING COUNT(*)>2;

104
Q

___ is used to calculate the sum of all selected columns. It works on numeric fields only.

A

Sum function

105
Q

Syntax and Example of sum function

A

Syntax:
SUM() or SUM( [ALL|DISTINCT] expression )

Example:
SELECT SUM(COST) FROM PRODUCT_MAST;

SUM() with WHERE:
SELECT SUM(COST) FROM PRODUCT_MAST WHERE QTY>3;

SUM() with GROUP BY:
SELECT SUM(COST) FROM PRODUCT_MAST WHERE QTY>3
GROUP BY COMPANY;

SUM() with HAVING:
SELECT COMPANY, SUM(COST) FROM PRODUCT_MAST GROUP BY COM
PANY HAVING SUM(COST)>=170;

106
Q

The ___ is used to calculate the average value of the numeric type. AVG function returns the average of all ___.

A

AVG function; non-Null values

Syntax:
AVG() or AVG( [ALL|DISTINCT] expression )

Example:
SELECT AVG(COST) FROM PRODUCT_MAST;

107
Q

___ is used to find the maximum value of a certain column. This function determines the largest value of all selected values of a column.

A

MAX function

Syntax:
MAX() or MAX( [ALL|DISTINCT] expression )

Example:
SELECT MAX(RATE) FROM PRODUCT_MAST;

108
Q

___ is used to find the minimum value of a certain column. This function determines the smallest value of all selected values of a column

A

MIN function

Syntax:
MIN() or MIN( [ALL|DISTINCT] expression )

Example:
SELECT MIN(RATE) FROM PRODUCT_MAST

109
Q

SQL JOIN means ___.

A

“to combine two or more tables”

110
Q

In SQL, ___ is used to combine the records from two or more tables in a database.

A

JOIN clause

111
Q

Types of SQL JOIN

A

 INNER JOIN
 LEFT JOIN
 RIGHT JOIN
 FULL JOIN

112
Q

In SQL, ___ selects records that have matching values in both tables as long as the condition is satisfied. It returns the combination of all rows from both the tables where the condition satisfies.

A

INNER JOIN

Syntax:
SELECT table1.column1, table1.column2, table2.column1,….
FROM table1
INNER JOIN table2
ON table1.matching_column = table2.matching_column;

Example:
SELECT EMPLOYEE.EMP_NAME, PROJECT.DEPARTMENT
FROM EMPLOYEE
INNER JOIN PROJECT
ON PROJECT.EMP_ID = EMPLOYEE.EMP_ID;

113
Q

The ___ returns all the values from left table and the matching values from the right table. If there is no matching join value, it will return NULL.

A

SQL left join

Syntax:
SELECT table1.column1, table1.column2, table2.column1,….
FROM table1
LEFT JOIN table2
ON table1.matching_column = table2.matching_column;

Example:
SELECT EMPLOYEE.EMP_NAME, PROJECT.DEPARTMENT
FROM EMPLOYEE
LEFT JOIN PROJECT
ON PROJECT.EMP_ID = EMPLOYEE.EMP_ID;

114
Q

In SQL, ___ returns all the values from the values from the rows of right table and the matched values from the left table. If there is no matching in both tables, it will return NULL.

A

RIGHT JOIN

Syntax:
SELECT table1.column1, table1.column2, table2.column1,….
FROM table1
RIGHT JOIN table2
ON table1.matching_column = table2.matching_column;

Example:
SELECT EMPLOYEE.EMP_NAME, PROJECT.DEPARTMENT
FROM EMPLOYEE
RIGHT JOIN PROJECT
ON PROJECT.EMP_ID = EMPLOYEE.EMP_ID;

115
Q

In SQL, ___ is the result of a combination of both left and right outer join. Join tables have all the records from both tables. It puts NULL on the place of matches not found.

A

FULL JOIN

Syntax:
SELECT table1.column1, table1.column2, table2.column1,….
FROM table1
FULL JOIN table2
ON table1.matching_column = table2.matching_column;

Example:
SELECT EMPLOYEE.EMP_NAME, PROJECT.DEPARTMENT
FROM EMPLOYEE
FULL JOIN PROJECT
ON PROJECT.EMP_ID = EMPLOYEE.EMP_ID;

116
Q

The SQL ___ is used to combine the two or more SQL SELECT statements

A

Set operation

117
Q

Types of Set Operation

A

Union
UnionAll
Intersect
Minus

118
Q

The ___ is used to combine the result of two or more SQL SELECT queries.

A

SQL Union operation

119
Q

In the union operation, all the ___ must be same in both the tables on which UNION operation is being applied.

A

number of datatype and columns

120
Q

The union operation eliminates the ___ from its result set.

A

duplicate rows

121
Q

Syntax and Example of using the Union Operation

A

Syntax:
SELECT column_name FROM table1
UNION
SELECT column_name FROM table2;

Example:
SELECT * FROM First
UNION
SELECT * FROM Second

122
Q

It is used to combine two SELECT statements.

A

Intersect operation

123
Q

The ___ returns the common rows from both the SELECT statements.

A

Intersect operation

124
Q

In the ___, the number of datatype and columns must be the same. It has no duplicates and it arranges the data in ascending order by default.

A

Intersect operation

125
Q

Syntax and Example of Intersect operation

A

Syntax:
SELECT column_name FROM table1
INTERSECT
SELECT column_name FROM table2;

Example:
SELECT * FROM First
INTERSECT
SELECT * FROM Second;

126
Q

It combines the result of two SELECT statements. ___ is used to display the rows which are present in the first query but absent in the second query.

It has no duplicates and data arranged in ascending order by default.

A

Minus operator

127
Q

Syntax and Example of Minus Operation

A

Syntax:
SELECT column_name FROM table1
MINUS
SELECT column_name FROM table2;

Example:
SELECT * FROM First
MINUS
SELECT * FROM Second