SQL学习(六)

1.  INSERT

 通用形式:

 INSERT INTO tablename [colname {,colname...}]

              {VALUES (expr |NULL | Subquery)}

例:1. insert into orders (ordno,month)

                    values (1107.'aug');

     2.  insert  into swcusts

                  select * from customers 

                             where city in ('dallas','austin');

2.  UPDATE

    例:1.update agents set percent=1.1*percent where city='New York';

          2.update customers set discnt=1.1*discnt where cid in

             (select cid from orders  group by cid having  sum(dollars)>1000);

3.  DELETE

     例:1.delete from agents where city ='New York';

           2. delete  from agents where in

                      (select aid from orders group by adi having sum(dollars)<600);

posted @ 2011-03-05 21:51  一杯浓茶  阅读(...)  评论(... 编辑 收藏