oracle列转行方法总结
方法一:
----------------------------------------------------------------
---Muti-row to line(col2row)
----------------------------------------------------------------
create or replace type str_tab is table of varchar2(20);
/
grant all on str_tab to public;
create public synonym str_tab for str_tab;
create or replace function col2row(pv in str_tab) return varchar2
is
ls varchar2(4000);
begin
for i in 1..pv.count loop
ls := ls || pv(i);
end loop;
return ls;
end;
/
grant execute on col2row to public;
create public synonym col2row for col2row;
----------------------------------------------------------------
--multi column,convert one column base on another column, for example
----------------------------------------------------------------
create table t(id number,name varchar2(10));
insert into t values(1,'Joan');
insert into t values(1,'Jack');
insert into t values(1,'Tom');
insert into t values(2,'Rose');
insert into t values(2,'Jenny');
---------------------------------------------------------------
SQL(c3dev)>select * from t;
ID NAME
---------- ----------
1 Joan
1 Jack
1 Tom
2 Rose
2 Jenny
---------------------------
--column to row
---------------------------
SQL(c3dev)>column names format a80;
SQL(c3dev)>set line 120
SQL(c3dev)>select t0.id,
2 col2row(cast(multiset(select name from t where t.id = t0.id) as str_tab)) names
3 from (select distinct id from t) t0;
ID NAMES
---------- --------------------------------------------------------------------------------
&nbs
相关文档:
Username
Password
Description
See Also
CTXSYS
CTXSYS
The Oracle Text account
Oracle Text Reference
DBSNMP
DBSNMP
The account used by the Management Agent component of Oracle Enterprise Manager to&nb ......
问题1: 进入时需要主机身份证明: 解决方案:管理工具——本地安全策略——用户权利指派——作为批处理作业等录(最后一项)——添加本机的账号与密码 ......
package cn.edu.bit.test;
import java.sql.*;
public class Jdbc {
public static void main(String[] args)
{
try{
Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
System.out.p ......
DBA 职责及日常工作职责:
1.安装和升级数据库服务器,以及应用程序工具构建和配置网络环境.
2.熟悉数据库系统的存储结构预测未来的存储需求,制订数据库的存储方案.
3.根据开发人员设计的应用系统需求创建数据库存储结构.
4.根据开发人员设 ......
以下是在后台更新易拓ERP数据库时遇到的一个问题:
1.在DB14数据库中将料件号P44开头,并且品名为"塑料袋"的料件改为消耗性料件.
这个简单: UPDATE DB14.ima_file SET ima70 = ‘Y’ WHERE ima01 like ‘P44%’ AND ima0 ......