First of all, the relational database management system will check whether the defined integrity rules are destroyed when executing insert, modify, delete statements,
including: entity integrity, referential integrity, user-defined integrity (not null constraints, unique constraints, values Domain constraints).
1. Insert data:
insert into 表名···values()···;
-
insert into table name values ("", "", ···);
insert an entire tuple; -
insert into table name attribute column 1, attribute column 2, attribute column 3, ... values ("attribute value 1", "attribute value 2", "attribute value 3", ···);
insert individual attribute values, other The attribute value defaults to null; -
insert into subquery; insert
the results of the subquery into the table;
Note: The target column of the subquery must match the into clause, including the number and type of target columns.
Example:
insert into Student (Sdept, Sgrade)
select Sdept, Sgrade
from Student
group by Sdept;
(Sdept and Sgrade here correspond one-to-one with the target column selected in the subquery)
2. Modify the data:
update 表名 set···;
-
update table name set column name = expression, ··· where ···;
Example: update student set Sage = 22 where Sno = "201215121";
change the age of the student with the student number 201215121 to 22. -
update table name set an attribute name = the attribute name + n;
add n to all information data in the attribute;Example: update table name set Sage = Sage + n;
increase the age of all students by 10; -
Similarly, the object of modifying data can also be the result of a subquery, and the requirements are also consistent.
3. Delete data:
delete from 表名 where ···;
- delete from Student where Sno = “201215121”;
delete all records of students with student number 201215121; - delete from Student;
delete all the information in the Student table; - Delete statement with subquery.