九、数据库的修改

l Deletion oftuples from a given relation (删除元组)

l Insertion ofnew tuples into a given relation (插入新的元组)

l Updatingvalues in some tuples in a given relation (修改某些元组的值)

l Subquery canbe used in modification of  the database (子查询也可以用于数据库的修改)

 

删除:

例子:Delete all tuples in the instructor relation forthose instructors associated with a department located in the Watson building.

delete from instructor

    wheredept_name in (select dept_name

                       from department

                        where building  = ‟Watson‟);

插入:

例子:

Addall instructors to the student relation with tot_creds set to 0 。

insert into student

select ID, name,dept_name, 0

       from  instructor

The select from where statement is evaluated fully beforeany of its results are inserted into the relation (otherwise queries like :

insert into table1 select * from table1

would cause problems, if table1 did not have any primarykey defined.)

 

更新:

updateinstructor

setsalary = salary * 5;

将工资增加到原来的五倍。

你可能感兴趣的:(九、数据库的修改)