0% found this document useful (0 votes)
14 views3 pages

SQL Insert Delete Update Guide

The document outlines basic SQL commands for inserting, deleting, and updating data in a database. It provides examples for adding new columns and rows, deleting specific columns and rows, and updating values in one or multiple columns. Key operations include using ALTER TABLE for structural changes and INSERT, DELETE, and UPDATE statements for data manipulation.

Uploaded by

Anil Bhard Waj
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views3 pages

SQL Insert Delete Update Guide

The document outlines basic SQL commands for inserting, deleting, and updating data in a database. It provides examples for adding new columns and rows, deleting specific columns and rows, and updating values in one or multiple columns. Key operations include using ALTER TABLE for structural changes and INSERT, DELETE, and UPDATE statements for data manipulation.

Uploaded by

Anil Bhard Waj
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

SQL BASICS: INSERT, DELETE, UPDATE (Columns & Rows)

1. INSERTING DATA

A. Add a New Column:


----------------------------------------
ALTER TABLE table_name
ADD column_name data_type;

Example:
ALTER TABLE Students
ADD Phone VARCHAR(15);

B. Insert a New Row:


----------------------------------------
INSERT INTO table_name (column1, column2, ...)
VALUES (value1, value2, ...);

Example:
INSERT INTO Students (ID, Name, Age)
VALUES (1, 'Anil Kumar', 21);

2. DELETING DATA

A. Delete a Column:
----------------------------------------
ALTER TABLE table_name
DROP COLUMN column_name;

Example:
ALTER TABLE Students
DROP COLUMN Phone;

B. Delete a Row:
----------------------------------------
DELETE FROM table_name
WHERE condition;

Example:
DELETE FROM Students
WHERE ID = 1;

3. UPDATING DATA

A. Update a Column's Value for Specific Row(s):


----------------------------------------
UPDATE table_name
SET column_name = new_value
WHERE condition;

Example:
UPDATE Students
SET Name = 'Anil Sharma'
WHERE ID = 1;

B. Update Multiple Columns at Once:


----------------------------------------
UPDATE table_name
SET column1 = value1, column2 = value2
WHERE condition;
Example:
UPDATE Students
SET Name = 'Ravi Kumar', Age = 23
WHERE ID = 2;

C. Set a Column to NULL Based on Condition (Clear Value):


----------------------------------------
UPDATE Students
SET Name = NULL
WHERE Age < 25;

D. Update All Rows (Use with caution!):


----------------------------------------
UPDATE Students
SET Age = Age + 1;

You might also like