0% found this document useful (0 votes)
3 views1 page

SQL ALTER and DROP Commands Guide

The document provides SQL commands for altering tables, including adding and removing columns, as well as deleting tables and records. It explains the use of the ALTER and DROP commands, and introduces Data Manipulation Language (DML) for managing data in databases. Key DML commands include INSERT, which retrieves data from tables, with notes on handling columns not included in INSERT operations.
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)
3 views1 page

SQL ALTER and DROP Commands Guide

The document provides SQL commands for altering tables, including adding and removing columns, as well as deleting tables and records. It explains the use of the ALTER and DROP commands, and introduces Data Manipulation Language (DML) for managing data in databases. Key DML commands include INSERT, which retrieves data from tables, with notes on handling columns not included in INSERT operations.
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

ALTER : - change defini on of a table

Adding column
The new columns are appended at the end of today by default

Ques :- Add a new column called email to the persons table


Ans : ALTER TABLE persons
ADD email VARCHAR(50) NOT NULL

SELECT * FROM persons

Ques:- Remove the column phone from the persons table


ALTER TABLE persons
DROP COLUMN Phone

SELECT * FROM persons

DROP :- Remove TABLE, COLUMN from the Database


DELETE FROM table_name
WHERE condi on;

Example :- DELETE FROM customers


WHERE id IN (8, 9);

-- Delete the table persons from the database

DROP TABLE persons

Data Manipulate
DML in SQL stands for Data Manipula on Language. It is a subset of SQL commands used to manage and
manipulate data within database tables or views. DML commands are primarily focused on the records
stored in the database, allowing users to interact with and modify the actual data.
The main DML commands in SQL include:

Insert : Used to retrieve data from one or more


tables in a database.

Notes:-
1. Column not included in INSERT become NULL (unless a default or constraint exists)

You might also like