Navigate
JavaScript Tutorial for Beginners
The Ultimate CSS Tutorial for Beginners
Data Structure Tutorial for Beginners
ReactJS Tutorial for Beginners
Java Tutorial for Beginners
Node.js Tutorial for Beginners
SQL Tutorial for Beginners
Modifying Data
Content
- Modifying Data
- Inserting Data
- Updating Data
- Deleting Data
- Activity
- Updated on 10/09/2024
- 450 Views
Inserting Data
Use the INSERT INTO statement to add new rows to a table. Example: INSERT INTO products (name, price) VALUES ('Laptop', 1200);
Updating Data
Use the UPDATE statement to modify existing records. Example: UPDATE products SET price = 1000 WHERE name = 'Laptop';
Deleting Data
Use the DELETE statement to remove records from a table. Example: DELETE FROM products WHERE name = 'Laptop';
Activity
Add a new record to a products table, update an existing record, and then delete a record.
Quiz
1. Which SQL command is used to insert new data into a table?
- a) INSERT INTO
- b) ADD INTO
- c) CREATE INTO
- d) UPDATE INTO
2. How do you update an existing record in SQL?
- a) INSERT INTO
- b) UPDATE
- c) DELETE
- d) SELECT
3. What is the purpose of the DELETE statement?
- a) To add new data
- b) To remove existing data
- c) To modify existing data
- d) To retrieve data
4. How do you modify the salary of an employee named 'Alice' to 70000?
- a) UPDATE employees SET salary = 70000 WHERE name = 'Alice';
- b) INSERT INTO employees SET salary = 70000 WHERE name = 'Alice';
- c) DELETE FROM employees SET salary = 70000 WHERE name = 'Alice';
- d) SELECT * FROM employees SET salary = 70000 WHERE name = 'Alice';
5. Which command would you use to remove all records from a table?
- a) DELETE * FROM tableName;
- b) DROP TABLE tableName;
- c) TRUNCATE TABLE tableName;
- d) REMOVE ALL FROM tableName;