SQL Fundamentals Quiz
8 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 command is used to create a new table named 'students' with columns for student_id, name, and enrollment_date?

  • INSERT INTO students (student_id, name, enrollment_date) VALUES (1, 'John Doe', '2023-01-01');
  • MAKE TABLE students (student_id INT, name VARCHAR(100), enrollment_date DATE);
  • CREATE TABLE students (student_id INT, name VARCHAR(100), enrollment_date DATE); (correct)
  • ADD TABLE students (student_id INT, name VARCHAR(100), enrollment_date DATE);
  • What command should you use to modify the 'orders' table by adding a column called 'order_status'?

  • CHANGE TABLE orders ADD order_status VARCHAR(20);
  • UPDATE orders SET order_status = 'pending';
  • ALTER TABLE orders ADD COLUMN order_status VARCHAR(20); (correct)
  • MODIFY TABLE orders ADD order_status VARCHAR(20);
  • What command should you execute to remove a record from the 'inventory' table where the product_id is 10?

  • CLEAR inventory WHERE product_id = 10;
  • REMOVE FROM inventory WHERE product_id = 10;
  • DROP FROM inventory WHERE product_id = 10;
  • DELETE FROM inventory WHERE product_id = 10; (correct)
  • Which command would you use to grant a user named 'manager' permission to update records in the 'sales' table?

    <p>GRANT UPDATE ON sales TO 'manager';</p> Signup and view all the answers

    Which SQL command will you use to select all records from the 'employees' table where the hire_date is after January 1, 2020?

    <p>SELECT * FROM employees WHERE hire_date &gt; '2020-01-01';</p> Signup and view all the answers

    What command should you use to drop the 'departments' table from the database?

    <p>DROP TABLE departments;</p> Signup and view all the answers

    What is the appropriate command to update the email field of a user in the 'users' table where the user_id is 3?

    <p>UPDATE users SET email = '<a href="mailto:[email protected]">[email protected]</a>' WHERE user_id = 3;</p> Signup and view all the answers

    Which command would you choose to revoke SELECT permission from a user named 'guest' on the 'products' table?

    <p>REVOKE SELECT ON products FROM 'guest';</p> Signup and view all the answers

    Study Notes

    Creating Tables

    • CREATE TABLE students (student_id INT, name VARCHAR(255), enrollment_date DATE); creates a table named students with columns for student ID (integer), name (string), and enrollment date.

    Modifying Tables

    • ALTER TABLE orders ADD COLUMN order_status VARCHAR(255); adds an order_status column (string) to the orders table.

    Deleting Records

    • DELETE FROM inventory WHERE product_id = 10; removes the record with product_id 10 from the inventory table.

    Granting Permissions

    • GRANT UPDATE ON sales TO manager; grants the user manager permission to update the sales table.

    Selecting Records with Conditions

    • SELECT * FROM employees WHERE hire_date > '2020-01-01'; selects all records from employees where the hire_date is after January 1, 2020.

    Dropping Tables

    • DROP TABLE departments; removes the departments table from the database.

    Updating Records

    • UPDATE users SET email = '[email protected]' WHERE user_id = 3; updates the email address for the user with user_id 3 in the users table.

    Revoking Permissions

    • REVOKE SELECT ON products FROM guest; removes SELECT permission from the user guest on the products table.

    Studying That Suits You

    Use AI to generate personalized quizzes and flashcards to suit your learning preferences.

    Quiz Team

    Description

    Test your knowledge of SQL commands, including creating tables, modifying structures, deleting records, and managing permissions. This quiz covers essential SQL operations and conditions necessary for database management.

    More Like This

    DBMS Flashcards
    53 questions

    DBMS Flashcards

    SharperEducation9982 avatar
    SharperEducation9982
    Bases de Datos: Instalación y Migración
    5 questions
    Database Management Systems Quiz
    21 questions
    Use Quizgecko on...
    Browser
    Browser