Skip to main content

CRUD operations

info

CRUD is an acronym that stands for Create, Read, Update, and Delete, which are the four basic operations that can be performed on data in a database.

CRUD operations are fundamental to managing and interacting with data in any database management system (DBMS). Each operation can be related to SQL statements.

  1. Create

    SQL Statement: INSERT

    Adds new data or records to a database.

    INSERT INTO employees (first_name, last_name, email) VALUES ('John', 'Doe', 'john.doe@example.com');

    This statement adds a new record to the employees table with the specified values for first_name, last_name, and email.

  2. Read

    SQL Statement: SELECT

    Retrieves or queries data from a database.

    SELECT first_name, last_name FROM employees WHERE department = 'Sales';

    This statement retrieves the first_name and last_name of employees who work in the Sales department.

  3. Update

    SQL Statement: UPDATE

    Modifies existing data within a database.

    UPDATE employees SET email = 'j.doe@example.com' WHERE first_name = 'John' AND last_name = 'Doe';

    This statement updates the email address of the employee named John Doe.

  4. Delete

    SQL Statement: DELETE

    Removes data or records from a database.

    DELETE FROM employees WHERE last_name = 'Doe';

    This statement deletes all records from the employees table where the last_name is Doe.