SQL Statements and Constraints Quiz
10 Questions
0 Views

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to lesson

Podcast

Play an AI-generated podcast conversation about this lesson

Questions and Answers

Which SQL statement correctly updates the stock table when 100 items with code A1 are sold?

  • update stock set quantity=quantity - 100 having code=A1
  • update stock set quantity=quantity - 100 where code=A1 (correct)
  • update stock set quantity=100 where code=A1
  • delete from stock set quantity=quantity - 100 where code=A1
  • What is the correct SQL statement to delete the product with code A1 from the stock table?

  • delete from stock where code=A1 (correct)
  • delete from stock having code=A1
  • drop from stock where code=A1
  • update stock where code=A1
  • Which constraint should be used to ensure that an attribute always has a value?

  • Not null (correct)
  • Unique
  • Null
  • Distinct
  • What is the correct syntax to create a view with the name 'v'?

    <p>Create view v as 'query expression'</p> Signup and view all the answers

    Which option is used to delete entries in the department table when a corresponding entry is deleted in the course table?

    <p>On delete cascade</p> Signup and view all the answers

    Which SQL statement is needed to update the stock table so that 100 items with code A1 are deducted from the quantity?

    <p>UPDATE stock SET quantity = quantity - 100 WHERE code = A1</p> Signup and view all the answers

    In order to successfully delete a record with code A1 from the stock table, which SQL statement should be used?

    <p>DELETE FROM stock WHERE code = A1</p> Signup and view all the answers

    Which constraint ensures that an attribute in a database table cannot be left empty?

    <p>Not null</p> Signup and view all the answers

    What is the correct syntax for creating a view named 'v' that executes a specific query?

    <p>CREATE VIEW v AS query expression</p> Signup and view all the answers

    When deleting an entry in the course table, which option ensures that related entries in the department table are also removed?

    <p>ON DELETE CASCADE</p> Signup and view all the answers

    More Like This

    SQL Statements Quiz
    10 questions
    Advanced Database Systems Quiz
    37 questions
    Database Management Quiz
    16 questions

    Database Management Quiz

    ConfidentIrony6422 avatar
    ConfidentIrony6422
    Use Quizgecko on...
    Browser
    Browser