0% found this document useful (0 votes)
1 views2 pages

Alter

Uploaded by

roysia
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)
1 views2 pages

Alter

Uploaded by

roysia
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

CREATE TABLE Students (

StudentID INT PRIMARY KEY,


Name VARCHAR(50),
Age INT,
Course VARCHAR(50));

INSERT INTO Students (StudentID, Name, Age, Course)


VALUES
(1, 'Alice Johnson', 20, 'Computer Science'),
(2, 'Bob Smith', 22, 'Mathematics'),
(3, 'Carol Davis', 19, 'Physics'),
(4, 'David Brown', 21, 'Chemistry'),
(5, 'Eve Clark', 23, 'Biology');

SELECT * FROM Students;


desc students;
Alter
ALTER TABLE Students ADD Email VARCHAR(100);

ALTER TABLE Students MODIFY Course VARCHAR(100);


ALTER TABLE Students DROP COLUMN Email;
Rename
ALTER TABLE Students RENAME COLUMN Age TO StudentAge;
ALTER TABLE Students RENAME TO CollegeStudents;
Drop
DROP TABLE Students;
DML

INSERT INTO Students (StudentID, Name, StudentAge, Course) VALUES


(1, 'Alice Johnson', 20, 'Computer Science'),
(2, 'Bob Smith', 22, 'Mathematics'),
(3, 'Carol Davis', 19, 'Physics'),
(4, 'David Brown', 21, 'Chemistry'),
(5, 'Eve Clark', 23, 'Biology');

UPDATE Students SET Course = 'Data Science' WHERE StudentID = 1;


Delete
DELETE FROM Students WHERE StudentID = 5;

Select
SELECT * FROM Students;
Where
SELECT * FROM Students WHERE Course = 'Physics';

You might also like