insert data
SQL data insertion statement insert usually has two forms, inserting tuple and inserting sub-query results, the latter can insert multiple tuple at a time
insert tuple
Insert a new student ancestor
insert into Student //The attribute name can be listed, the order can be different, but the values should correspond to the attribute name order one by one values ('16999010','Messi','Male',30,'CS');
Insert a course selection record
insert into SC //Can write: SC(Sno, Cno), automatically assign NULL when the newly inserted record has no value values ('16999010','1',NULL)
Insert subquery result
...
change the data
1. Change the age of student 16999010 to 22
update Student set Sage=22 where Sno='16999010';
2. Increase the age of all students by 1 year
update Student set Sage=Sage+1;
3. Set the grades of all students in the computer science department to zero
update SC set Grade=0 where Sno in ( select Sno from Student where Sdept='CS' );
delete data
1. Delete the student record whose student number is 16999010
delete from Student where Sno='16999010';
2. Delete all students' course selection records
delete from SC; // will make SC an empty table, removing all tuples of SC
3. Delete the course selection records of all students in the Department of Computer Science
delete from SC where Sno in ( select Sno from Student where Sdept='CS' );