07 2011 档案

摘要:1,使用下面的命令移动:alter table table_name move tablespace tablespace_name;2,如果有索引的话必须重建索引:alter index index_name rebuild tablespace tablespace_name;然,可以使用spool来帮助实现多个表的操作.set header off;spool /export/home/oracle/alter_tables.sql;select 'alter table ' || object_name || ' move tablespace users 阅读全文
posted @ 2011-07-22 14:35 jex 阅读(1441) 评论(0) 推荐(0)
摘要:打开不重复记录的单个字段(重复的NAME被过滤,只出现一次)select distinct NAME from table打开不重复记录的所有字段值(有重复的NAME,且不是最小ID的记录被过滤,只出现最小ID的NAME)select * from table where ID in (Select min(ID ) FROM table group by NAME)查出NAME字段不重复出现的记录(有重复的NAME被过滤,多于1次的NAME不出现了)select * fromtablewhereNAME in (selectNAME from tablegroup by NAME havin 阅读全文
posted @ 2011-07-22 11:45 jex 阅读(975) 评论(0) 推荐(0)
该文被密码保护。
posted @ 2011-07-21 21:21 jex 阅读(1) 评论(0) 推荐(0)
该文被密码保护。
posted @ 2011-07-21 21:19 jex 阅读(0) 评论(0) 推荐(0)
该文被密码保护。
posted @ 2011-07-21 21:13 jex 阅读(1) 评论(0) 推荐(0)
该文被密码保护。
posted @ 2011-07-21 20:57 jex 阅读(3) 评论(0) 推荐(0)
该文被密码保护。
posted @ 2011-07-21 20:49 jex 阅读(1) 评论(0) 推荐(0)
该文被密码保护。
posted @ 2011-07-21 20:44 jex 阅读(0) 评论(0) 推荐(0)
该文被密码保护。
posted @ 2011-07-21 20:16 jex 阅读(2) 评论(0) 推荐(0)
该文被密码保护。
posted @ 2011-07-21 20:00 jex 阅读(3) 评论(0) 推荐(0)
摘要:SELECT ROUND( number, [ decimal_places ] ) FROM DUAL说明:number : 将要处理的数值decimal_places : 四舍五入,小数取几位,不填默认为0Sample :select round(123.456) from dual; 结果: 123 select round(123.456, 0) from dual; 结果: 123 select round(123.456, 1) from dual; 结果: 123.5 select round(123.456, 2) from dual; 结果:123.46 select rou 阅读全文
posted @ 2011-07-21 19:35 jex 阅读(281) 评论(0) 推荐(0)
摘要:test.sql内容:create or replace procedure ptest001 isbeginnull;end ptest001;/create or replace procedure ptest002 isbeginnull;end ptest002;/create or replace procedure ptest003 isbeginnull;end ptest003;/create or replace procedure ptest004 isbeginnull;end ptest004;/create or replace procedure ptest005 阅读全文
posted @ 2011-07-21 19:32 jex 阅读(317) 评论(0) 推荐(0)
摘要:1、全角转半角函数 TO_SINGLE_BYTE 2、数字转英文,利用to_char、to_date 3、sys_guid()1、全角转半角函数 TO_SINGLE_BYTESQL> select TO_SINGLE_BYTE('oracle') from dual;TO_SINGLE_BYTE('ORACLE')------------------------------oracle2、数字转英文,利用to_char、to_dateSQL> select to_char(to_date('12345','J'),&# 阅读全文
posted @ 2011-07-21 19:29 jex 阅读(770) 评论(0) 推荐(0)
摘要:create sequence seq2start with 0 --起始值increment by 1 --步长maxvalue 4999 --最大值minvalue 0 --最小值cycle --循环cache 4 --缓存4个数create table testa(ins number(4) primary key,nm varchar2(20));-- Created on 2007-10-17 by YCZ declare -- Local variables herei integer;begin-- Test statements herefor i in 1..5000 loo 阅读全文
posted @ 2011-07-21 19:29 jex 阅读(222) 评论(0) 推荐(0)
摘要:--列转行CREATE TABLE t_col_row(ID INT,c1 VARCHAR2(10),c2 VARCHAR2(10),c3 VARCHAR2(10));INSERT INTO t_col_row VALUES (1, 'v11', 'v21', 'v31');INSERT INTO t_col_row VALUES (2, 'v12', 'v22', NULL);INSERT INTO t_col_row VALUES (3, 'v13', NULL, 'v33'); 阅读全文
posted @ 2011-07-21 19:22 jex 阅读(218) 评论(0) 推荐(0)
摘要:数据字典dict总是属于Oracle用户sys的。 1、用户: select username from dba_users; 改口令 alter user spgroup identified by spgtest; 2、表空间: select * from dba_data_files; select * from dba_tablespaces;//表空间 select tablespace_name,sum(bytes), sum(blocks) from dba_free_space group by tablespace_name;//空闲表空间 select * from dba 阅读全文
posted @ 2011-07-21 19:22 jex 阅读(232) 评论(0) 推荐(0)
摘要:用法if ... then ... elsif ... then ... else ... end if; if ... then ... else ... end if; if ... then ... end if; 阅读全文
posted @ 2011-07-21 19:00 jex 阅读(3580) 评论(0) 推荐(0)
摘要:The table below shows the ADO Data Type mapping between Access, SQL Server, and Oracle:DataType EnumValueAccessSQLServerOracleadBigInt20BigInt (SQL Server 2000 +)adBinary128BinaryTimeStampRaw *adBoolean11YesNoBitadChar129CharCharadCurrency6CurrencyMoneySmallMoneyadDate7DateDateTimeadDBTimeStamp135Da 阅读全文
posted @ 2011-07-21 15:08 jex 阅读(430) 评论(0) 推荐(0)
摘要:存储过程创建语法:(1)无参create or replace procedure 存储过程名as变量1 类型(值范围);变量2 类型(值范围);Begin........................Exception ........................End;(2)带参create or replace procedure 存储过程名(param1 in type,param2 out type)as变量1 类型(值范围);变量2 类型(值范围);Begin Select count(*) into 变量1 from 表A where列名=param1; If (判断条件) 阅读全文
posted @ 2011-07-20 15:20 jex 阅读(2519) 评论(0) 推荐(0)
摘要:Oracle 更改列名1. alter table tableName rename column original_Col to dest_Col ; eg. (把lrpo 中的列baNo 改为 pNo) alter table lrpo rename column baNo to pNo ; 2. alter table original_tableName rename to dest_tableName ; eg. (把 lrpo 表重命名为 lrDom 表) alter table lrpo rename to lrDom ; 1.删除一列: alter table rig drop 阅读全文
posted @ 2011-07-19 22:01 jex 阅读(4655) 评论(0) 推荐(0)
摘要:oracle 10+g不支持对类型为CLOB的列进行distinct,也不支持union,所以在遇到此问题,需要对SQL语句进行重新,从另一思想去实现同样的效果的。union没仔细思考过,具体还要看union里面的条件如何,最简单的方法是利用to_char将clob字段转换成char型,但存在一个问题,如clob中的字符长度超过4000时会报错。在此主要对distinct的转换方法进行列举:表结构如下:Table1:id(varchar)title(varchar)content(clob)1title1<CLOB>2title2<CLOB>Table2:id(varc 阅读全文
posted @ 2011-07-16 09:40 jex 阅读(3753) 评论(0) 推荐(0)
摘要:1.按姓氏笔画排序:Select * From TableName Order By CustomerName Collate Chinese_PRC_Stroke_ci_as 2.数据库加密:select encrypt('原始密码')select pwdencrypt('原始密码')select pwdcompare('原始密码','加密后密码') = 1--相同;否则不相同 encrypt('原始密码')select pwdencrypt('原始密码')select pwdcompare(&# 阅读全文
posted @ 2011-07-16 09:32 jex 阅读(232) 评论(0) 推荐(0)
摘要:解决10g上 非本机SQLPLUS conn as sysdba出现ORA-01031: insufficient privileges问题这个多半是密码文件的问题本机可以通过验证但是非本机就不行,是因为本地的话,不会check密码文件,而安全性对异地登录的(通过SID)登录要验证密码文件首先查看select * from v$pwfile_user;---应该没有记录,说明还没有SYS的密码文件。 使用密码文件orapwd 命令 orapwd -c file=”$ORACLE_HOME/dbs/orapwd$ORACLE_SID” entity=5 password=changeoninst 阅读全文
posted @ 2011-07-12 15:13 jex 阅读(3651) 评论(0) 推荐(0)
摘要:大家在应用ORACLE的时候可能会遇到很多看起来不难的问题,现跟各位分享下1. Oracle安装完成后的初始口令? internal/oracle sys/change_on_install system/manager scott/tiger sysman/oem_temp2. ORACLE9IAS WEB CACHE的初始默认用户和密码?administrator/administrator3. oracle 8.0.5怎么创建数据库?用orainst。如果有motif界面,可以用orainst /m4. oracle 8.1.7怎么创建数据库?dbassist5. oracle 9i 怎 阅读全文
posted @ 2011-07-09 15:37 jex 阅读(405) 评论(0) 推荐(0)
摘要:--1、创建函数get_sum_FYF001 获取合计的应发金额CREATE OR REPLACE FUNCTION get_sum_FYF001(table_name IN VARCHAR2,FPeriodNum1 IN VARCHAR2 ,FPeriodNum2 IN VARCHAR2 )RETURN NUMBER ISresult NUMBER;sql_str VARCHAR2(2000);BEGIN sql_str:='SELECT Sum(FYF001) FROM '||table_name||' where FPeriodNum between '| 阅读全文
posted @ 2011-07-08 21:55 jex 阅读(831) 评论(0) 推荐(0)
摘要:--Oracle的方式判断记录是否存在不存在则插入---insert into a(a.user_id,a.user_name) select '2','李四' from dual where not exists(select 1 from a where a.user_id='2')--sql server的方式--if not exists(select Test_TB.ID from Test_TB where ID='2') insert into Test_TB values('2','李四&# 阅读全文
posted @ 2011-07-08 21:45 jex 阅读(273) 评论(0) 推荐(0)
摘要:通过Database Link集成远程数据库时,从远程数据库上查询Blob字段时总返回ORA- 22992 错误 。有人采用物化视图解决这个问题,但物化视图同步机制会带来麻烦,如果同步时间设置过短,则占用大量的系统资源,给服务器带来极大的压力;如果设置时间过长,前台用户不可接受。 参考网上资料,据说来自 AskTom,使用全局临时表,实现了自认为优雅的解决。 代码如下: create or replace package pkg_photo as type sys_refcursor is ref cursor; procedure proc_photo(p_sfzh in string, p 阅读全文
posted @ 2011-07-08 21:43 jex 阅读(6538) 评论(0) 推荐(0)
摘要:lv_sql:=' insert into ETL_SUCESS_AMOUNT select SEQ_OS_ETL_AMOUNTID.NEXTVAL AS AMOUNTID,1,AMOUNT_DATA,AMOUNT_HOUR, serviceid,portalid,mouduleid,actionid,RESERVE1_ID,RESERVE2_ID,RESERVE3_ID, RESERVE4_ID,AMOUNT,AMOUNT_TIME from ( select trunc(INSERTTIME) AS AMOUNT_DATA, TO_CHAR(INSERTTIME,'' 阅读全文
posted @ 2011-07-08 21:41 jex 阅读(4264) 评论(0) 推荐(0)
摘要:select count(*) into flag from all_tables where table_name=upper(你要判断的表名)if (flag=0) thenexecute immedate 'create table 表名(列名1,列名2...)'end if; 阅读全文
posted @ 2011-07-08 21:37 jex 阅读(555) 评论(0) 推荐(0)
摘要:删除数据库链接:drop database link linkname;创建数据库链接:create database link linknameconnect to usernameidentified by passwordusing 'connection string';如果想建立全局链接,则需要使用关键字:public create public database link linknameconnect to usernameidentified by passwordusing 'connection string';connection stri 阅读全文
posted @ 2011-07-08 21:30 jex 阅读(450) 评论(0) 推荐(0)
摘要:方法如下:Use Sunjammer's services plug-in: Services.zip (20 KB).Use dselkirk's NSIS Service Lib.Use sl's nsSCMUse doberlec's all-in-one Swiss scripting knife - Nopey.Use Speed78's NSIS Simple Service PluginExecute the NET command (use Exec, ExecWait or nsExec).Execute your service EX 阅读全文
posted @ 2011-07-05 19:02 jex 阅读(3463) 评论(0) 推荐(0)
摘要:l方括号表达示方括号表达式描述[[:alnum:]]字母和数字混合的字符[[:alpha:]]字母字符[[:cntrl:]]控制字符[[:digit:]]数字字符[[:graph:]]图像字符[[:lower:]]小写字母字符[[:print:]]打印字符[[:punct:]]标点符号字符[[:space:]]空格字符[[:upper:]]大写字母字符[[:xdigit:]]十六进制数字字符l元字符元字符描述*?如果有前面字符串的0次以上出现时匹配+?如果有前面字符串的1次以上出现时匹配{m}m是整数。它文本中找出给定子表达式的恰好m次出现{n}?前面的字符串只出现一次时匹配{m,}M是整数。 阅读全文
posted @ 2011-07-02 20:41 jex 阅读(430) 评论(0) 推荐(0)
摘要:oracle 存储过程中使用事务管理存储过程里的事务操作:create or replace procedure pr_mypro2(p_a in varchar2,p_b in varchar2,p_count out number)temp varchar2(1000); /**//*定义临时变量*/isbeginselect code into p_count from table1 where a=p_a; /**//*查询并返回值*/temp := p_count; /**//*将返回值赋给临时变量*/savepoint point1; /**//*保存点*/insert into 阅读全文
posted @ 2011-07-02 20:12 jex 阅读(745) 评论(0) 推荐(0)
摘要:如何用正则取美国人名. 类似”Celmer,Kenneth Raymond”,"Cockrell Jr,Robert Charles”,"St John,Michael Raymond”需要取出颠倒然后用空格分隔取出第一个名字“Kenneth Celmer”,”Robert Cockrell”,”Michael St’。通过ITPUB高手指点,可用如下代码实现。SELECT name full_name, REGEXP_REPLACE(name,'\s*(\S+)[^,]*\,+\s*(\S+)[^,]*','\2 \1') name, us 阅读全文
posted @ 2011-07-02 20:04 jex 阅读(610) 评论(0) 推荐(0)
摘要:如何用正则表达式实现这样的需求通过wm_concat()函数得到了这样的结果: '014,014,018,022,317,319,023,021' 如何继续排序和去重复呢? 期望结果:'014,018,021,022,023,317,319' 测试数据: select '014,014,018,022,317,319,023,021' from dual; wm_concat集合函数在plsql中不能加distinct关键字,在sql中执行没事。 有三种方式屏蔽: 1、改为sql串,动态执行; 2、定义视图; 3、先 distinct ,套一层在 阅读全文
posted @ 2011-07-02 20:03 jex 阅读(178) 评论(0) 推荐(0)
只有注册用户登录后才能阅读该文。
posted @ 2011-07-02 19:59 jex 阅读(49) 评论(0) 推荐(0)
摘要:1. 非贪婪模式?当该字符紧跟在任何一个其他限制符(*,+,?,{n},{n,},{n,m})后面时,匹配模式是非贪婪的。非贪婪模式尽可能少的匹配所搜索的字符串,而默认的贪婪模式则尽可能多的匹配所搜索的字符串。例如,对于字符串“oooo”,“o+?”将匹配单个“o”,而“o+”将匹配所有“o”。2. (?:pattern)匹配pattern但不获取匹配结果,也就是说这是一个非获取匹配,不进行存储供以后使用。这在使用或字符“(|)”来组合一个模式的各个部分是很有用。例如“industr(?:y|ies)”就是一个比“industry|industries”更简略的表达式。(?=pattern)正 阅读全文
posted @ 2011-07-02 19:50 jex 阅读(569) 评论(0) 推荐(0)
摘要:CREATE OR REPLACE PROCEDURE "SP_GET_ARTICLE_DATA"(article_detail_id_$ number, Record_Md5_ID_$ varchar2, content_text_$ clob, ReturnValue out number) isbegin declare --自定义数组 TYPE StringArray IS table OF VARCHAR2(1000); Offset_URL number; Offset_Email number; Offset_Phone number; Offset_Acco 阅读全文
posted @ 2011-07-02 19:49 jex 阅读(476) 评论(0) 推荐(0)