oracle行转列
select i.sid,i.sname,i.birthday,i.schooltime,i.sphone,c.classname,a.assnname,sum(decode(subject,'语文',s.score,0)) as chin,
sum(decode(subject,'数学',s.score,0)) as math,
sum(decode(subject,'英语',s.score,0)) as eng from student_info i
left join student_expand e on i.sid = e.sid left join student_class c on
c.classid = e.classid left join student_assn a on a.assnid = e.assnid left join student_score s on s.sid = i.sid
group by i.sid,i.sname,i.birthday,i.schooltime,i.sphone,c.classname,a.assnname;
行转列:
decode(subject,'数学',s.score,0) 用法:如果subject会等于数学 ,则最后值等于 s.score 否则值等于: 0
相关文档:
1. 将数据库完全导出
用户名system 密码system 导出到Oracle用户目录下的testdb20100522.dmp文件中
#exp system/system@testdb file=testdb20100522.dmp full=y
2. 将数据库中system用户与sys用户的表导出
#exp system/system@testdb file= testdb20100522.d ......
1. 查看Oracle创建过哪些用户
>select username from all_users;
2. 查看Oracle创建过哪些表空间,表空间的名字和大小
>select t.tablespace_name, round(sum(bytes/(1024*1024)),0) ts_size
from dba_tablespaces t, dba_data_files d
wher ......
Oracle的trunc 函数一般用来 对日期和时间进行截取。
1、数字处理 。截取
select trunc(5.75),trunc(5.75,1),trunc(5.75,-1),trunc(556.234,-2) from dual;
输出:
TRUNC(5.75) TRUNC(5.75,1) TRUNC(5.75,-1) TRUNC(556.234,-2)
----------- ------------- -------------- ----- ......
首先以sysdba身份登录
sqlplus connect system/orcl as sysdba;
然后修改参数
1.sga_target不能大于sga_max_size,可以设置为相等。
2.SGA加上PGA等其他进程占用的内存总数必须小于操作系统的物理内存。
alter system set sga_target=150M scope=spfile;
alter system set sga_max_size=150M scope=spfile;
//数据库 ......
select a.constraint_name, a.table_name, b.constraint_name
from user_constraints a, user_constraints b
where a.constraint_type = 'R'
and b.constraint_type = 'P'
and a.r_constraint_name = b.constraint_name
P 代表主键
R 代表外键 ......