0% found this document useful (0 votes)
12 views5 pages

MySQL Lab 4

Uploaded by

samrrakhalid2005
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)
12 views5 pages

MySQL Lab 4

Uploaded by

samrrakhalid2005
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

Purpose of alter:-

The ALTER command in Mysql is used to modify the structure of an existing


table. It can:
1. Add, delete,or modify columns.
2. Change the data type of column.
3. Add or drop constraints (e.g. keys)

Example:-
ALTER TABLE table_name ADD column_name datatype;

Purpose of alter add:-


The ALTER ADD command in MySQL is used to add new
columns to an existing table.

Syntax:- ALTER TABLE table_name ADD column_name datatype;

Example:-
Purpose of alter modify:-
The ALTER MODIFY Command in MySQL is used to change the
data type, size, or attributes of an existing column in a table.

Syntax:-
ALTER TABLE table_name MODIFY column_name new_datatype;

Example:-
Purpose of alter drop:-
The ALTER DROP command in MySQL is used to delete a column
from and existing table.

Syntax:-
ALTER TABLE table_name DROP COLUMN column_name.

Example:-
Pupose of drop table or drop database:-
The DROP TABLE command is used to delete a table and all
its data from the database. The DROP DATABASE command deletes an entire
database along with all its tables and data.

Syntax:-
Drop table:- DROP TABLE table_name;
Drop database:- DROP DATABASE database_name;

Example:-

You might also like