Oracle实训笔记1

1、desc:列出表定义,列出PL/SQL语句定义。

2、disc:断开连接。conn scott/tiger@orcl :连接

3、passw:更改密码

4、nvl()函数的使用,处理NULL。sal+nvl(comm,0):即当comm为NULL时,将它看成0,当不是NULL时,将其忽略。

5、如果列别名区分大小写、包含特殊字符等,则需要双引号扩出来。

6、多表插入:

     使用子查询将一张表中的数据根据条件插入到多张表中,包括:无条件insert all,有条件insert all,有条件insert first三种。

      create table sal_history     AS      select ename,hiredate,sal from emp where 1=0;【扩展:where 1=0 ,永远返回FALSE,所以只会返回表结构,而不复制数据,可用于快速建表,where 1>0或者不写可返回所有结构。】

       create table mgr_history     AS      select ename,mgr,sal from emp where 1=0;

       实例一:无条件的insert all

                      将查询的结果无条件的复制到多个表中,例子:

                      Insert All

                      into sal_history values (ename,hiredate,sal)

                      into mgr_history values(ename,mgr,sal)

                     select ename,hiredate,mgr,sal from emp;

         实例二:有条件的insert all

                        insert all

                         when sal>1000 then

                                   into sal_history values(ename,hiredate,sal)

                          when mgr>7700 then

                                    into mgr_history  values(ename,mgr,sal)

                           select ename,hiredate,mgr,sal from emp;

7、删除数据

      delete语句,delete from emp1 where

       truncate语句,truncate from emp1

       区别:delete只删除表内容,不删除表结构,可以rollback。

 

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值