九、数据库的修改

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;

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值