随笔分类 -  随笔 Oracle

游标遍历
摘要:-- 将user_tables的所有table_name以逗号间隔作为一个字符串输出-- 通过for循环 显示游标 遍历 declare var_sql varchar2(32767) := ''; cursor cur is select table_name from user_tables order by table_name;begin for rec in cur loop var_s... 阅读全文
posted @ 2010-03-02 14:25 Good life 阅读(375) 评论(0) 推荐(0) 编辑
oracle 导入导出实用程序(imp/exp)
摘要:本文转载自该地址:http://www.javaeye.com/topic/581066导入导出实用程序用于实施数据库的逻辑备份和恢复 导出实用将数据库中的对象定义和数据备份到一个操作系统二进制文件中 导入使用程序读取二进制导出文件并将对象和数据载入数据库中 导出额导入实用程序的特点有: 1.可以按时间保存表结构和数据 2.允许导出指定的表,并重新导入到新的数据库中 3.可以吧数据库迁移到另外一台... 阅读全文
posted @ 2010-03-02 14:19 Good life 阅读(473) 评论(0) 推荐(0) 编辑
oracle 导入/出命令
摘要:本文转载自该地址:http://www.javaeye.com/topic/183699导入 IMP Oracle 的导入实用程序 (Import utility) 允许从数据库提取数据,并且将数据写入操作系统文件。 imp 使用的基本格式: imp[username[/password[@service]]] ,以下例举 imp 常用用法。 1. 获取帮助 imp help=y 2. 导入一个完... 阅读全文
posted @ 2010-03-02 14:18 Good life 阅读(151) 评论(0) 推荐(0) 编辑
字符串分割的处理
摘要:========================================================== 作者: hanjs(http://hanjs.itpub.net)发表于: 2007.02.03 17:24分类: oracle 出处: http://hanjs.itpub.net/post/28217/260065--------------------------------... 阅读全文
posted @ 2009-04-16 10:31 Good life 阅读(499) 评论(0) 推荐(0) 编辑
一个分隔字符串的例子
摘要:原文位于:http://www.itpub.net/viewthread.php?tid=610297&extra=page%3D2%26amp%3Bfilter%3Ddigest&page=2把'a|||b|||c'字符串分隔成abccreate or replace function f_test(var_str in string) return t_ret_table is... 阅读全文
posted @ 2009-04-16 10:25 Good life 阅读(309) 评论(0) 推荐(0) 编辑
浅谈oracle复合数据类型
摘要:原文位于:http://www.itpub.net/viewthread.php?tid=610297&extra=page%3D2%26amp%3Bfilter%3Ddigest--本文档可以直接拷贝运行。/*oracle复合数据类型PL/SQL有两种复合数据结构:记录和集合。记录由不同的域组成,集合由不同的元素组成。*//*一、记录类型类似C语言中的结构,有两种定义方式:显式定义和隐式... 阅读全文
posted @ 2009-04-16 10:22 Good life 阅读(666) 评论(0) 推荐(0) 编辑
oracle record
摘要:-------- begining of the structure of test -------- /* userId userName 1 John1 2 John2 3 John3 4 John4 5 John5 */ ------------- record 1 --------------- declare v_record test%R... 阅读全文
posted @ 2008-08-28 11:58 Good life 阅读(1182) 评论(1) 推荐(0) 编辑
oracle cursor
摘要:-------- begining of the structure of test --------/*userId userName1 John12 John23 John34 John45 John5*/ ---------------- part 1 ----------------declare cursor v_cursor is selec... 阅读全文
posted @ 2008-08-28 11:47 Good life 阅读(740) 评论(0) 推荐(0) 编辑
設置sqlplus格式
摘要:sqlplus数据显示格式很不方便:n字段名称显示为n行,数据也是如此,并且查询结果每3条数据为一段。如何设置其格式,使其显示结果类似sqlserver的查询分析器那样的格式,象一个数据表的格式。 sql>set linesize 99999 sql>set heading off 阅读全文
posted @ 2008-08-27 18:07 Good life 阅读(720) 评论(0) 推荐(0) 编辑
sqlplus 命令列表
摘要:假设当前执行命令为:select * from tab; (a)ppend 添加文本到缓冲区当前行尾 a order by tname 结果:select * from tab order by tname; (注:a后面跟2个空格) (c)hange/old/new 在当前行用新的文本替换旧的文本 c/*/tname 结果:select tname... 阅读全文
posted @ 2008-08-27 17:56 Good life 阅读(353) 评论(0) 推荐(0) 编辑
create sequence
摘要:create sequence seq_test minvalue 1maxvalue 999999999999999999999999999start with 1increment by 1cache 20; current sequence value:select seqpart.currval from dual; next sequence value:select seqpa... 阅读全文
posted @ 2008-08-27 16:23 Good life 阅读(324) 评论(0) 推荐(0) 编辑
Oracle几个循环
摘要:转载自:http://www.jo99.com/post/Oraclee587a0e4b8aae5beaae78eaf.aspx 1、loop declare x number:= 0;begin x:=0; loop x:=x+1; /*if x>=10 then exit; end if;*/ ... 阅读全文
posted @ 2008-08-27 14:07 Good life 阅读(1181) 评论(1) 推荐(0) 编辑
将一个字段的若干行转为一个字串(Oracle)
摘要:1、使用for/*----------------------------------------------------------*/declare v_str varchar2(4000) := ''; v_rowcount number := 0; v_top_n number := 3; begin select count(*) ... 阅读全文
posted @ 2008-08-27 12:23 Good life 阅读(287) 评论(0) 推荐(0) 编辑
随机获取5条记录
摘要:1、Access尽管在Access的sql视图下可以根据select top 5 * from tb order by rnd(field_id);实现,但是如果在应用程序中执行这条语句每次得到的结果总是一样;个人感觉这是由于随机种子没有被初始化。因此,需要利用程序,帮助其初始化随机种子。System.Random rnd = new System.Random();string iTmp = r... 阅读全文
posted @ 2008-08-06 11:35 Good life 阅读(228) 评论(0) 推荐(0) 编辑
使用sqllder从csv导入数据到oracle
摘要:一、关于CSV文件添加到ORACLE的学习体会 我有一个EXCEL的文件Prize_VS.xls,由姓名、身份证编号、通信地址、邮政编码四列组成,在EXCEL中将Prize_VS.xls另存为Prize_VS.csv,现在来向我的ORACLE服务器上的表增加数据。 进行最后操作前,在Prize_VS.csv所在的目录下新建文本文件input.ctl,内容为: load ... 阅读全文
posted @ 2008-08-05 21:46 Good life 阅读(2080) 评论(0) 推荐(0) 编辑
通过数据库编程进行递归(Oracle)
摘要:一、用于测试数据及其结构和生成该测试数据的sql语句如下:1、测试数据nodeId parentId---------- ----------A01 AA02 AA03 AA0101 A01A0102 A01A0201 A02A0202 A02B01 BB02 BB0201 ... 阅读全文
posted @ 2008-08-05 11:00 Good life 阅读(208) 评论(0) 推荐(0) 编辑
使用Sqlldr向oracle导入数据
摘要:一、准备工作: 1、要导入的数据保存在一个txt文件中; 2、控制文件中需要指明:数据文件所在的位置、数据文件的栏位与数据库中各栏位的对应关系,以及数据的导入方式(Append/ Truncate)。 3、文件具体内容: A、数据文件(test.txt) 4200 ELECTRIC Cellular access F2831442 2008/07/07 14:35:104100 ELECTRIC ... 阅读全文
posted @ 2008-08-05 09:27 Good life 阅读(607) 评论(0) 推荐(0) 编辑