Document 1
Document 1
the organization of data on disk. A clustered index dictates the physical order of
data rows on disk, rearranging them to match the order of the index key. In
contrast, a non-clustered index creates a separate structure, storing index key
values along with pointers to the actual data rows without changing their
physical order.
A table can have only one clustered index, while multiple non-clustered
indexes are allowed. Clustered indexes are beneficial for range queries and
ordered retrieval, but they require more storage space. Non-clustered indexes
offer versatility in query optimization and consume less storage. The choice
depends on the specific performance and storage requirements of the
database.
Ans 17-
The key differences between executing a query and calling a stored procedure
in a database is executing a query is a single SQL statement for data retrieval or
manipulation, while calling a stored procedure involves invoking a predefined
set of actions with potentially complex logic encapsulated within the database.
Stored procedures provide modularity, reusability, and transaction control,
making them beneficial for more complex tasks.
Ans 18-
2. left join
- Returns all rows from the left table and the matched rows from the right
table. If there is no match, NULL values are returned for columns from the right
table.
SELECT Customers.CustomerID, Customers.CustomerName, Orders.OrderID
FROM Customers
LEFT JOIN Orders ON Customers.CustomerID = Orders.CustomerID;
3.right join
- Returns all rows from the right table and the matched rows from the left
table. If there is no match, NULL values are returned for columns from the left
table.
SELECT Orders.OrderID, Orders.OrderDate, Customers.CustomerName
FROM Orders
RIGHT JOIN Customers ON Orders.CustomerID = Customers.CustomerID;
4. full join
- Returns all rows when there is a match in either the left or the right table. If
there is no match, NULL values are returned for columns from the table
without a match.
5. cross join
- Returns the Cartesian product of the two tables, i.e., all possible
combinations of rows.
6. self join
- Joins a table with itself based on a related column. Commonly used when
dealing with hierarchical or recursive structures.