Interview Questions: Placement Preparation
Interview Questions: Placement Preparation
Interview Questions: Placement Preparation
PLACEMENT PREPARATION
[EXCLUSIVE NOTES]
HIMANSHU KUMAR(LINKEDIN)
https://www.linkedin.com/in/himanshukumarmahuri
𝑪𝑯𝑬𝑪𝑲𝑶𝑼𝑻 𝑨𝑵𝑫 𝑫𝑶𝑾𝑵𝑳𝑶𝑨𝑫 𝑴𝒀 𝑨𝑳𝑳 𝑵𝑶𝑻𝑬𝑺
𝑳𝑰𝑵𝑲- https://linktr.ee/exclusive_notes
1. What is SQL?
SQL stands for Structured Query Language. It is a language used to
interact with the database, i.e to create a database, to create a table in
the database, to retrieve data or update a table in the database, etc.
SQL is an ANSI(American National Standards Institute) standard. Using
SQL, we can do many things. For example - we can execute queries, we
can insert records into a table, we can update records, we can create a
database, we can create a table, we can delete a table, etc.
2. What is a database?
A Database is defined as a structured form of data storage in a
computer or collection of data in an organized manner and can be
SQL PL/SQL
SQL tells databases, what to do? PL/SQL tells databases how to do.
BETWEEN
The BETWEEN operator is used to fetch rows based on a range of
values.
For example,
LOWER('string')
UPPER('string')
INITCAP('string')
Basic Syntax:
CREATE VIEW view_name AS
SELECT column1, column2.....
FROM table_name
WHERE condition;
view_name: Name for the View
table_name: Name of the table
condition: Condition to select rows
2 3325 3
3 4521 2
4 8532 1
Customers
1 RAMESH DELHI
2 SURESH NOIDA
3 DHARMESH GURGAON
As we can see clearly, that the field C_ID in the Orders table is the
primary key in the Customers' table, i.e. it uniquely identifies each row
in the Customers table. Therefore, it is a Foreign Key in the Orders
table.
Syntax:
CREATE TABLE Orders
(
O_ID int NOT NULL,
ORDER_NO int NOT NULL,
C_ID int,
PRIMARY KEY (O_ID),
FOREIGN KEY (C_ID) REFERENCES Customers(C_ID)
)
• INNER JOIN: The INNER JOIN keyword selects all rows from both
the tables as long as the condition satisfies. This keyword will
create the result-set by combining all rows from both the tables
where the condition satisfies i.e the value of the common field will
be the same.
• LEFT JOIN: This join returns all the rows of the table on the left
side of the join and matching rows for the table on the right side of
the join. For the rows for which there is no matching row on the
right side, the result-set will be null. LEFT JOIN is also known as
LEFT OUTER JOIN
• RIGHT JOIN: RIGHT JOIN is similar to LEFT JOIN. This join returns
all the rows of the table on the right side of the join and matching
rows for the table on the left side of the join. For the rows for which
there is no matching row on the left side, the result-set will contain
null. RIGHT JOIN is also known as RIGHT OUTER JOIN.
• FULL JOIN: FULL JOIN creates the result-set by combining results
of both LEFT JOIN and RIGHT JOIN. The result-set will contain all
the rows from both tables. For the rows for which there is no
matching, the result-set will contain NULL values.
1) Minimizing Redundancy
2) Minimizing the Insertion, Deletion, And Update Anomalies
Relation schemas that do not meet the properties are decomposed into
smaller relation schemas that could meet desirable properties.
• One-to-One Relationship.
• One to Many Relationships.
• Many to One Relationship.
• Self-Referencing Relationship.
1. Arithmetic Operators
2. Logical Operators
3. Comparison Operators
Identity of column retains the Identity of the column is reset to its seed
identity after using DELETE value if the table contains an identity
Statement on table. column.
The delete can be used with Truncate cannot be used with indexed
indexed views. views.
31. What are local and global variables and their differences?
• Global Variable:
Local variables are variables that are defined within functions. They
have local scope, which means that they can only be used within the
functions that define them.
The clustered index requires less The non-Clustered index requires more memory
memory for operations. for operations.
In a clustered index, the index is the In the Non-Clustered index, the index is a copy of
main data. data.
The clustered index has an inherent The non-Clustered index does not have the
ability to store data on the disk. inherent ability to store data on the disk.
Clustered indexes store pointers to The non-Clustered index store both value and a
block not data. pointer to actual row that holds data.
• Set Union
• Set Intersection
• Set Difference
UNION Operation: This operation includes all the tuples which are
present in either of the relations. For example: To find all the customers
who have a loan or an account or both in a bank.
SELECT CustomerName FROM Depositor
UNION
SELECT CustomerName FROM Borrower ;
The union operation automatically eliminates duplicates. If all the
duplicates are supposed to be retained, UNION ALL is used in the place
of UNION.
Aggregate functions:
These functions are used to do operations from the values of the
column and a single value is returned.
Scalar functions:
These functions are based on user input, these too return a single value.
The AND and OR operators are used with the WHERE clause.
AND Operator: This operator displays only those records where both
the conditions condition1 and condition2 evaluates to True.
OR Operator: This operator displays the records where either one of
the conditions condition1 and condition2 evaluates to True. That
is, either condition1 is True or condition2 is True.
COMMIT ROLLBACK
The transaction can not undo changes Transaction reaches its previous
after COMMIT execution. state after ROLLBACK.
• Aggregate functions.
• Ranking functions. There are different types of ranking functions.
• Rowset function.
• Scalar functions.
In SQL, zero or blank space can be compared with another zero or blank
space. whereas one null may not be equal to another null. null means
data might not be provided or there is no data.
56. How can you fetch common records from two tables?
The below statement could be used to get data from multiple tables,
so, we need to use join to get data from multiple tables.
Syntax :
SELECT tablenmae1.colunmname, tablename2.columnnmae
FROM tablenmae1
JOIN tablename2
ON tablenmae1.colunmnam = tablename2.columnnmae
ORDER BY columnname;
Syntax:
CURRENT_DATE
or
CURRENT DATE
A trigger can also contain INSERT, UPDATE, and DELETE logic within
itself, so when the trigger is fired because of data modification it can
also cause another data modification, thereby firing another trigger. A
trigger that contains data modification logic within itself is called a
nested trigger.
Syntax:
NVL (expr1, expr2)
Syntax:
SELECT column(s), CAOLESCE(expression_1,....,expression_n)
FROM table_name;
ISNULL(): The ISNULL function has different uses in SQL Server and
MySQL. In SQL Server, ISNULL() function is used to replace NULL values.
FROM table_name;
HIMANSHU KUMAR(LINKEDIN)
https://www.linkedin.com/in/himanshukumarmahuri
CREDITS- INTERNET
DISCLOSURE- THE DATA AND IMAGES ARE TAKEN FROM GOOGLE AND INTERNET.
𝑪𝑯𝑬𝑪𝑲𝑶𝑼𝑻 𝑨𝑵𝑫 𝑫𝑶𝑾𝑵𝑳𝑶𝑨𝑫 𝑴𝒀 𝑨𝑳𝑳 𝑵𝑶𝑻𝑬𝑺
𝑳𝑰𝑵𝑲- https://linktr.ee/exclusive_notes