alter table dept modify (loc char(12)); alter table dept modify loc char(12);
alter table dept modify (dname char(13),loc char(12)); 创建视图
create view managers as select ename,job,sal from emp
where job='manager'; 为视图列名取别名 create view mydept (person,title,salary) as select ename,job,sal from emp
where deptno=10; with check option选项
使用with check option,保证当对视图插入或更新数据时, 该数据必须满足视图定义中select命令所指定的条件。 create view dept20 as select ename,job,sal,deptno from emp
where deptno=20 with check option;
在做下述操作时,会发生错误 update dept20 set deptno=30 where ename='ward'; 基表、视图的拷贝 create table emp2 as select from emp; 基表、视图的删除 drop table 表名 drop view 视图名 ----------
5 SQLPLUS报表功能
SQL*PLUS的一些基本格式命令 column deptno heading department column ename heading name column sal heading salary column sal format $99,999.00 ttitle sample report for|hitech corp btitle strictly confidential break on deptno
compute sum of sal on deptno run
表头和表尾
ttitle sample report for|hitech corp btitle right strictly confidential “|”表示换行,结尾不必加分号 选项有三种:left right center
使用TTITLE,系统将自动地在每页的顶部显示日期和页号。
TTITLET和BTITLE命令有效,直至重新设置表头或表尾,或退出SQL*PLUS。 下面命令使标题语句失效 TTITLE OFF BTITLE OFF 列名
column命令定义用于显示列名 若名字为一个单词,不必加引号 column ename heading employee column ename heading 'employee|name' (|为换行) 取消栏定义
column ename clear 列的格式
column ename format A15 column sal format $9,999.99 column comm like sal
like子句,使得某一列的格式参照另一列格式,它拷贝列名及其格式 控制记录显示分组顺序 break on deptno (不显示重复值) select deptno,ename from emp order by deptno;
(ORDER BY子句用于控制BREAK) 显示为 10 clark niller 20 smith scott 30 allen blake
每次只有一个BREAK命令起作用,但一次可以在多个列上使用BREAK命令 break on 列名1 on 列名2 记录分组
break on deptno skip 2 select deptno,ename from emp order by deptno;
相关推荐: