易截截图软件、单文件、免安装、纯绿色、仅160KB

Oracle中合并字符串总结

在数据库中经常要合并字符串,而合并字符串的方法有很多,现在总结如下:
--创建会话级临时表
create global temporary table TMPA
(
  ID   INTEGER,
  NAME VARCHAR2(10)
)
on commit preserve rows;
--插入记录
insert into tmpa select 1,'aa' from dual;
insert into tmpa select 1,'bb' from dual;
insert into tmpa select 1,'cc' from dual;
insert into tmpa select 2,'dd' from dual;
insert into tmpa select 2,'ee' from dual;
insert into tmpa select 3,'ff' from dual;
commit;
--1、sys_conect_by_path方法
select id,max(ltrim(sys_connect_by_path(name,','),',')) as group_name
from
(
select a.*,row_number()over(partition by id order by name) as row_num
from tmpa a
) a
group by id
start with row_num=1
connect by prior id=id and prior row_num= row_num-1
--2、wm_concat方法
select id,wm_concat(name) as group_name from tmpa
group by id;
--3、自定义函数法
--定义函数
create function group_concat(vid number)
return varchar2
as
vResult varchar2(100);
begin
for cur in (select name from tmpa where id=vid) loop
vResult := vResult||cur.name;
end loop;
return vResult;
end;
--查询
select id,group_concat(id) as group_name from tmpa
group by id;
--查询的结果
ID GROUP_NAME
1  aa,bb,cc
2  dd,ee
3  ff


相关文档:

【oracle序列专题】(转载)

ORACLE没有象SQL SERVER中一样的自增加字段,要实现只能通过SEQUENCE来实现
1.创建序列:
create sequence your_seq
nocycle
maxvalue 9999999999
start with 1;
2.使用触发器实现自增:
create or replace trigger your_seq_tri
before insert on your_table1 for each row
declare
next_id number;
begin
se ......

Oracle存储过程,函数。

--在应用程序中往往有些固定的数据库操作,我们常常为致谢固定的操作定义了一些存储过程。这些存储过程不仅
--可以简化客户端的应用程序的开发和维护。而且还可以提高应用的运行性能。
-- 创建存储过程的语法。
create [or replace] procedure <过程名>[(参数)]
is|as
[局部变量声明]
begin
......

Exam : Oracle 1Z0 051

Exam : Oracle 1Z0-051
Title : Oracle Database: SQL Fundamentals I
1. View the Exhibit to examine the description for the SALES table.
Which views can have all DML operations performed on it? (Choose all that apply.)
A. CREATE VIEW v3
AS SELECT * from SALES
WHERE cust_id = 2034
WITH CHECK OPTI ......

从jdk安装到jsp连接oracle数据库的相关配置

1.安装jdk(版本6u7);
  2.配置jdk环境变量(安装目录:D:\tools\java\jdk1.6.0_07):
  1). JAVA_HOME = D:\tools\java\jdk1.6.0_07;
  2). Path的最前面追加"D:\tools\java\jdk1.6.0_07\bin;D:\tools\java\jre1.6.0_07\bin";
  3). CLASSPATH = D:\tools\java\jdk1.6.0_07\lib;D:\tools\java\jdk1.6.0_07\lib\too ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号