Q1
Q1
Q1
view
1. **Database Recovery**: Restoring a database after a failure or
corruption event to ensure data integrity and availability.
1. **CREATE SEQUENCE**:
- **Definition**: In SQL, a sequence is an object that generates a
series of unique numeric values. The `CREATE SEQUENCE` statement
is used to create such a sequence in a database.
- **Usage**: It's commonly used to generate unique identifiers for
tables, ensuring each new record gets a distinct identifier
2. **DROP SEQUENCE**:
- **Definition**: The `DROP SEQUENCE` statement is used to remove
a previously created sequence from the database.
- **Usage**: When a sequence is no longer needed or if it was created
in error, you can use this statement to delete it
Certainly!
**GROUP BY** is a clause in SQL used for aggregating rows that have
the same values in specific columns. It's often used with aggregate
functions like SUM, COUNT, AVG, etc. Here's an example to illustrate its
usage:
```sql
SELECT CustomerID, Product, SUM(Quantity) as TotalQuantity
FROM Orders
GROUP BY CustomerID, Product;
```
In this example:
- Q4.
**`SELECT CustomerID, Product, SUM(Quantity) as TotalQuantity`**
specifies that we want to select the CustomerID, Product, and the total
quantity of each product ordered.
- **`FROM Orders`** indicates that we're selecting data from the
`Orders` table.
- **`GROUP BY CustomerID, Product`** groups the rows based on the
values in the CustomerID and Product columns.
- **`SUM(Quantity)`** is an aggregate function that calculates the total
quantity for each group.
- **`as TotalQuantity`** renames the result of the aggregate function to
"TotalQuantity" for better readability.