SQL CRUD Operations u0026 Optimization Quiz Quiz

  1. Basic SELECT Syntax

    Which SQL statement correctly retrieves all columns from a table named Employees?

    1. SELECT * FROM Employees;
    2. SELLECT ALL FROM Employees;
    3. SELECT * IN Employees;
    4. GET * FROM Employees;
    5. SELECT ALL Employees;
  2. Inserting Data Correctly

    Which statement correctly inserts a new row into the Customers table with values for Name and Email?

    1. INSERT INTO Customers (Name, Email) VALUES ('John Doe', 'john@example.com');
    2. INSERT Customers Name, Email VALUES ('John Doe', 'john@example.com');
    3. INSERT INTO Customers VALUES (Name='John Doe', Email='john@example.com');
    4. INERT INTO Customers (Name, Email) VALUES ('John Doe, 'john@example.com');
    5. INSERT TO Customers (Name Email) VALUES 'John Doe', 'john@example.com';
  3. Updating Existing Data

    If you want to change the Price to 19.99 for the product with ID 3 in the Products table, which SQL command should you use?

    1. UPDATE Products SET Price = 19.99 WHERE ID = 3;
    2. CHANGE Products SET Price = 19.99 WHERE ID is 3;
    3. UPDATE Products Price = 19.99 WHEN ID = 3;
    4. MODIFY Products (Price = 19.99) WHERE ID = 3;
    5. UPDATE Product SET Price to 19.99 where ID = 3;
  4. Efficient Data Deletion

    What is the correct SQL command to delete all records from the Orders table where the Status is 'Canceled'?

    1. DELETE FROM Orders WHERE Status = 'Canceled';
    2. REMOVE FROM Orders WHERE Status = 'Canceled';
    3. DELETE * FROM Orders WHERE Status = 'Canceled';
    4. DELETE Orders WHERE Status = 'Canceled';
    5. REMOVE Orders WHERE Status EQUALS 'Canceled';
  5. Limiting Query Results

    Which SQL statement fetches only the first 10 rows from a table named Sales?

    1. SELECT * FROM Sales LIMIT 10;
    2. SELECT ALL FROM Sales TOP 10;
    3. SELECT FIRST 10 * FROM Sales;
    4. SELECT TOP 10 FROM Sales;
    5. SELECT * FROM Sales ROWNUM = 10;
  6. Filtering Query Data

    What is the correct SQL way to select employees whose last name is 'Smith'?

    1. SELECT * FROM Employees WHERE LastName = 'Smith';
    2. SELECT * FROM Employees IF LastName = 'Smith';
    3. SELECT * Employees WHERE LastName == 'Smith';
    4. SELECT FROM Employees WHERE LastName = Smith;
    5. SELECT Employees WHERE LastName EQUAL 'Smith';
  7. Preventing SQL Injection

    Which strategy is best for preventing SQL injection when using SQL queries in application code?

    1. Use parameterized queries or prepared statements.
    2. Concatenate user input directly into SQL queries.
    3. Use SELECT * to reduce complexity.
    4. Delete unnecessary constraints from all tables.
    5. Only use the LIMIT clause in queries.
  8. Aggregating Data

    How can you count the number of products in the Products table using SQL?

    1. SELECT COUNT(*) FROM Products;
    2. COUNT * FROM Products;
    3. SELECT PRODUCT_COUNT() FROM Products;
    4. SELECT COUNT FROM Products;
    5. SELECT * FROM Products COUNT;
  9. Optimizing Query Performance

    Which optimization technique improves query performance, especially on large tables?

    1. Create indexes on frequently filtered columns.
    2. Use SELECT * in all queries.
    3. Avoid using WHERE clauses.
    4. Always retrieve all rows with no limits.
    5. Drop all constraints from the table.
  10. Updating Multiple Records

    You need to increase the salary by 5% for all employees in the 'Sales' department. Which SQL UPDATE is correct?

    1. UPDATE Employees SET Salary = Salary * 1.05 WHERE Department = 'Sales';
    2. UPDATE Employees Salary = Salary + 5% WHERE Department = 'Sales';
    3. UPDATE Employees WHERE Department = 'Sales' INCREASE Salary BY 5%;
    4. SET Salary = Salary * 1.05 FROM Employees WHERE Department = 'Sales';
    5. UPDATE Set Salary = Salary + 5 percent WHERE Employees.Department = 'Sales';