Download presentation
Presentation is loading. Please wait.
1
Database Management System
Lecture - 27 © Virtual University of Pakistan
2
© Virtual University of Pakistan
Alter Table Statement Purpose is to make changes in the definition of a table already created through Create statement Can add, drop attributes or constraints, activate or deactivate constraints; the format is © Virtual University of Pakistan
3
© Virtual University of Pakistan
ALTER TABLE table { [ ALTER COLUMN column_name { new_data_type [ ( precision [ , scale ] ) ] [ NULL | NOT NULL ] ] | ADD { [ < column_definition > ] | column_name AS computed_column_expression } [ ,...n ] | DROP { [ CONSTRAINT ] constraint_name | COLUMN column } [ ,...n ] | { CHECK | NOCHECK } CONSTRAINT { ALL | constraint_name [ ,...n ] } } © Virtual University of Pakistan
4
© Virtual University of Pakistan
Alter Table Command ALTER TABLE Student add constraint fk_st_pr foreign key (prName) references Program (prName) ALTER TABLE program add constraint ck_totSem check (totSem < 9) © Virtual University of Pakistan
5
Removing or Changing Attribute
ALTER TABLE student ALTER COLUMN stFName char(20) Alter table student drop column curSem drop constraint ck_st_pr © Virtual University of Pakistan
6
Removing Rows and Tables
TRUNCATE TABLE table_name Truncate table class Delete can also be used DROP TABLE table_name © Virtual University of Pakistan
7
Data Manipulation Language
Insert Select Update © Virtual University of Pakistan
8
© Virtual University of Pakistan
Insert Statement To insert records into tables INSERT [ INTO] table { [ ( column_list ) ] { VALUES ( { DEFAULT | NULL | expression } [ ,...n] ) } } | DEFAULT VALUES © Virtual University of Pakistan
9
Database Management System
Lecture - 27 © Virtual University of Pakistan
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.