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。