Skip to main content
Documents
Share
LinkedIn
Facebook
Twitter
Copy
ClausesStatementsKeywordsExpressionsFunctions

Statements

MySQL statements are the actionable commands that interact with the database. They enable data creation, modification, and control within the database system. Common types of MySQL statements include Data Definition Language (DDL), Data Manipulation Language (DML), and Data Control Language (DCL).

Common Uses of MySQL Statements

  1. CREATE Statement: Creates new tables or databases.
  2. INSERT Statement: Adds new data to tables.
  3. UPDATE Statement: Modifies existing data.
  4. DELETE Statement: Removes data from tables.
  5. DROP Statement: Deletes tables or databases.

Examples

  1. CREATE Statement Example
     
    CREATE TABLE customers (id INT, name VARCHAR(50));

    Explanation: Creates a customers table with id and name columns.

  2. INSERT Statement Example
     
    INSERT INTO customers (id, name) VALUES (1, 'John Doe');

    Explanation: Adds a new record to the customers table.

  3. UPDATE Statement Example
     
    UPDATE customers SET name = 'Jane Doe' WHERE id = 1;

    Explanation: Updates the name of the customer with id 1.

  4. DELETE Statement Example
     
    DELETE FROM customers WHERE id = 1;

    Explanation: Deletes the record where id is 1.

  5. DROP Statement Example
     
    DROP TABLE customers;

    Explanation: Deletes the customers table.