10.3.2 Data manipulation language (DML)

Cards (136)

  • What is the purpose of Data Manipulation Language (DML)?
    To manage data within tables
  • The `SELECT` command in DML is used to retrieve
  • The `INSERT` command is used to add new data to a table.
  • What does the `UPDATE` command in DML do?
    Modifies existing data
  • The `DELETE` command is used to remove data from a table
  • DML allows users to retrieve, insert, update, and delete data.
  • The `SELECT` command can retrieve data from multiple tables.
  • The `INSERT` command requires specifying the table name and the values
  • What clause is used with `UPDATE` to specify which rows to modify?
    WHERE
  • Order the main DML commands based on their purpose:
    1️⃣ SELECT (Retrieve data)
    2️⃣ INSERT (Add new data)
    3️⃣ UPDATE (Modify existing data)
    4️⃣ DELETE (Remove data)
  • The `INSERT` command can only add one row at a time.
    False
  • The `UPDATE` command can modify multiple rows if the `WHERE` clause matches conditions
  • What happens if the `WHERE` clause is omitted in a `DELETE` statement?
    All data is removed
  • The `SELECT` command is used to add new data to a table.
    False
  • DML is a subset of SQL
  • What is the primary function of the `SELECT` command in DML?
    Retrieving data
  • The `INSERT` statement requires specifying both column names and values.
  • Provide an example of an `INSERT` statement to add a new student to the `Students` table.
    \begin{align * } \textbf{INSERT INTO} & \text{Students} \\ & (\text{StudentID}, \text{Name}, \text{Age}, \text{Major}) \\ \textbf{VALUES} & (789, '\text{Jane Doe}', 22, '\text{Economics}'); \end{align * }
  • When using `INSERT`, the values must match the data types of the columns
  • The `INSERT` statement in SQL is used to add new rows
  • The number and order of values in an `INSERT` statement must match the column list.
  • If some columns are omitted in an `INSERT` statement, they must allow NULL values or have default constraints
  • What is the primary purpose of Data Manipulation Language (DML) in SQL?
    Manage data
  • Match the DML command with its purpose:
    SELECT ↔️ Retrieves data
    INSERT ↔️ Adds new data
    UPDATE ↔️ Modifies existing data
    DELETE ↔️ Removes data
  • The `SELECT` command in DML is used to retrieve data from one or more tables
  • The `UPDATE` command in DML modifies existing data based on a `WHERE` clause.
  • What is the primary purpose of the `DELETE` command in DML?
    Remove data
  • The main commands in DML include `SELECT`, `INSERT`, `UPDATE`, and DELETE
  • Steps for using the `INSERT` statement in SQL:
    1️⃣ Specify the table name
    2️⃣ List the column names
    3️⃣ Provide the values to insert
    4️⃣ Execute the statement
  • What is the primary purpose of the `UPDATE` statement in SQL?
    Modify existing data
  • The `DELETE` statement in SQL requires a `WHERE` clause to prevent unintentional data loss
  • The `DELETE` statement in SQL is used to remove rows from a table based on specified conditions
  • The `WHERE` clause is optional in a `DELETE` statement.
    False
  • Data Manipulation Language (DML) is a subset of SQL that manages data
  • Match the DML command with its purpose:
    SELECT ↔️ Retrieve data
    INSERT ↔️ Add new data
    UPDATE ↔️ Modify data
    DELETE ↔️ Remove data
  • Using the `WHERE` clause in `UPDATE` and `DELETE` commands avoids unintentional data changes
  • The `UPDATE` statement in SQL is used to modify existing data
  • Steps to update data using the `UPDATE` statement:
    1️⃣ Identify the table
    2️⃣ Use the `SET` clause to specify changes
    3️⃣ Use the `WHERE` clause to filter rows
  • The `DELETE` statement requires the `WHERE` clause to prevent unintentional data loss
  • Match the `SELECT` statement example with its description:
    `SELECT * FROM Students;` ↔️ Select all columns
    `SELECT Name, Age FROM Students;` ↔️ Select specific columns
    `SELECT Name, Age FROM Students WHERE Major = 'Computer Science';` ↔️ Select with a condition