-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathalter.sql
More file actions
48 lines (38 loc) · 1.01 KB
/
alter.sql
File metadata and controls
48 lines (38 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
create database college;
use college;
create table student(
rollno int primary key,
name varchar(50),
marks int not null,
grade varchar(1),
city varchar(20));
insert into student(rollno, full_name, marks, grade, city)
values
(101, "anil", 78, "C", "Pune"),
(102,"bhumika", 93, "A", "Mumbai"),
(103, "chetan", 85, "B", "Mumbai"),
(104, "dhruv", 96, "A", "Delhi"),
(105, "emanuel", 12, "F", "Delhi"),
(106, "farah", 82, "B", "Delhi");
select * from student;
alter table student
add column age int;
alter table student
drop column age;
alter table student
add column age int not null default 19;
alter table student
modify column age varchar(2);
insert into student(rollno, name, marks,stu_age) values (107, "garghi",68,100);
alter table student
change age stu_age INT;
alter table student drop column stu_Age;
alter table student
rename to stu;
truncate table student;
alter table student change name full_name varchar(50);
delete from student
where marks<80;
SET SQL_SAFE_UPDATES=0;
alter table student
drop column grade;