Inserts results
Statement format
INSERT
INTO <表名> [(<属性列1> [,<属性列2>… )]
子查询;
[Requirements] sub-query
SELECT clause, target columns must match the INTO clause, including
- The number of values
- The type of value
Example: For each department, find the average age of the students, and the results stored in the database
INSERT
INTO Dept_age(Sdept,Avg_age)
SELECT Sdept,AVG(Sage) FROM Student GROUP BY Sdept;
Strap query modification statements
Statement format
UPDATE <表名>
SET <列名>=<表达式>[,<列名>=<表达式>]…
WHERE <条件> IN 子查询;
Example: Department of Computer Science all students grades zero
UPDATE SC
SET Grade=0
WHERE Sno IN ( SELETE Sno FROM Student WHERE Sdept= 'CS' );
Strap query delete statement
Statement format
DELETE FROM <表名>
WHERE <条件> IN 子查询;
Example: Department of Computer Science student enrollment delete all records
DELETE FROM SC
WHERE Sno IN (SELETE Sno FROM Student WHERE Sdept= 'CS') ;