You are on page 1of 7

Database Manipulation in

SQL
Learn how to manipulate data in SQL using various statements such as INSERT
INTO, UPDATE, DELETE, and more.

by Ijaz Ahmad
INSERT INTO Statement

Adding New Data Multiple Records

Use the INSERT INTO statement to add new rows of Insert multiple records at once by specifying multiple
data into a table. value sets.

Copying Data

Copy data from one table to another using the


UPDATE Statement
1 Modify Existing Data 2 Conditional Updates 3 Updating with Joins

Alter the values of one or Control which rows are Combine data from
more columns in existing updated by specifying multiple tables to update
rows using the UPDATE conditions in the WHERE specific rows.
statement. clause.
DELETE Statement
1 Delete All Rows

Remove all rows from a table using the DELETE statement with no conditions.

2 Conditional Deletion

Delete specific rows based on conditions specified in the WHERE clause.

3 Cascading Deletion

Delete related rows in other tables using foreign key constraints.


LIMIT Clause
Limiting the Result Set

Use the LIMIT clause to restrict the number of rows returned by a query.

Pagination

Implement pagination by specifying the number of rows to skip with OFFSET.

Dynamic Limit

Calculate the limit dynamically based on user inputs or query results.


INSERT INTO SELECT Statement
1 Copy Select Rows

Select specific rows from one table and insert them into another table.

2 Data Transformation

Modify data during the insertion process using expressions and functions.

3 Filtering Records

Apply filtering conditions to the SELECT statement within the INSERT INTO
SELECT statement.
DESC and EXPLAIN Statements

DESC Statement EXPLAIN Statement

Retrieve detailed information about the structure of a Analyze the execution plan of a query to optimize its
table using DESC. performance using EXPLAIN.

You might also like