设为首页 收藏本站
查看: 620|回复: 0

[经验分享] sql的一些 oracle3

[复制链接]

尚未签到

发表于 2016-11-11 09:43:58 | 显示全部楼层 |阅读模式
1 oracle常用函数
引用


数值函数:


abs(m)  m的绝对值
mod(m,n) m被n除后的余数
power(m,n) m的n次方
round(m[,n]) m四舍五入至小数点后n位的值(n缺省为0)
trunc(m[,n]) m截断n位小数位的值(n缺省为0)  


--------------------------------------------------------------------------------


字符函数:


initcap(st) 返回st将每个单词的首字母大写,所有其他字母小写
lower(st) 返回st将每个单词的字母全部小写
upper(st) 返回st将每个单词的字母全部大写
concat(st1,st2)  返回st为st2接st1的末尾(可用操作符"||")
lpad(st1,n[,st2]) 返回右对齐的st,st为在st1的左边用st2填充直至长度为n,st2的缺省为空格
rpad(st1,n[,st2]) 返回左对齐的st,st为在st1的右边用st2填充直至长度为n,st2的缺省为空格
ltrim(st[,set])  返回st,st为从左边删除set中字符直到第一个不是set中的字符。缺省时,指的是空格
rtrim(st[,set])  返回st,st为从右边删除set中字符直到第一个不是set中的字符。缺省时,指的是空格
replace(st,search_st[,replace_st]) 将每次在st中出现的search_st用replace_st替换,返回一个st。缺省时,删除search_st
substr(st,m[,n]) n=返回st串的子串,从m位置开始,取n个字符长。缺省时,一直返回到st末端
length(st) 数值,返回st中的字符数
instr(st1,st2[,m[,n]])  数值,返回st1从第m字符开始,st2第n次出现的位置,m及n的缺省值为1
例:
1.
select initcap('THOMAS'),initcap('thomas') from test;
initca initca
------ ------
Thomas Thomas
2.
select concat('abc','def') "first" from test;
first
-----
abcdef
3.
select 'abc'||' '||'def' "first" from test;
first
-----
abc def
4.
select lpad(name,10),rpad(name,5,'*') from test;
lpad(name,10) rpad(name,5,'*')
------------ ----------------
         mmx mmx**
      abcdef abcde
5.
去掉地址字段末端的点及单词st和rd
select rtrim(address,'. st rd') from test
6.
select name,replace(name,'a','*') from test;
name  replace(name,'a','*')
----  ---------------------
great gre*t
7.
select substr('archibald bearisol',6,9) a,substr('archibald bearisol',11) b from test;
a         b
-------   -------
bald bear bearisol
8.
select name,instr(name,' ') a,instr(name,' ',1,2) b from test;
name    a        b
------- -------- ---------
li lei  3        0
l i l   2        4  

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

转换函数:
nvl(m,n) 如果m值为null,返回n,否则返回m
to_char(m[,fmt]) m从一个数值转换为指定格式的字符串fmt缺省时,fmt值的宽度正好能容纳所有的有效数字
to_number(st[,fmt]) st从字符型数据转换成按指定格式的数值,缺省时数值格式串的大小正好为整个数
附:
to_char()函数的格式:
---------------------------------
符号    说明
---------------------------------
9       每个9代表结果中的一位数字
0       代表要显示的先导0
$       美元符号打印在数的左边
L       任意的当地货币符号
.       打印十进制的小数点
,       打印代表千分位的逗号
---------------------------------
例:
1.
select to_number('123.45')+to_number('234.56') form test;
to_number('123.45')+to_number('234.56')
----------------------------------------
                               358.01
2.
select to_char(987654321) from test;
to_char(987654321)
------------------
987654321
3.
select to_char(123,'$9,999,999') a,to_char(54321,'$9,999,999') b,to_char(9874321,'$9,999,999') c from test;
作者:211.155.28.*    2006-3-6 11:17   回复此发言  
2 oracle常用函数
a       b          c
------- ---------- -----------
$123    $54,321    $9,874,321
4.
select to_char(1234.1234,'999,999.999') a,to_char(0.4567,'999,999.999') b,to_char(1.1,'999,999.999') from test;
a         b          c
--------- ---------- ------------
1,234.123 .457       1.100


--------------------------------------------------------------------------------


分组函数:


avg([distinct/all] n) 列n的平均值
count([all] *)  返回查询范围内的行数包括重复值和空值
count([distinct/all] n) 非空值的行数
max([distinct/all] n) 该列或表达式的最大值
min([distinct/all] n) 该列或表达式的最小值
stdev([distinct/all] n) 该列或表达式的标准偏差,忽略空值
sum([distinct/all] n) 该列或表达式的总和
variance([distinct/all] n) 该列或表达式的方差,忽略空值  


--------------------------------------------------------------------------------


日期函数:

>  

add_months(d,n)  日期d加n个月
last_day(d)  包含d的月份的最后一天的日期
month_between(d,e) 日期d与e之间的月份数,e先于d
new_time(d,a,b)  a时区的日期和时间d在b时区的日期和时间
next_day(d,day)  比日期d晚,由day指定的周几的日期
sysdate  当前的系统日期和时间
greatest(d1,d2,...dn) 给出的日期列表中最后的日期
least(d1,k2,...dn) 给出的日期列表中最早的日期
to_char(d [,fmt]) 日期d按fmt指定的格式转变成字符串
to_date(st [,fmt]) 字符串st按fmt指定的格式转成日期值,若fmt忽略,st要用缺省格式
round(d [,fmt])  日期d按fmt指定格式舍入到最近的日期
trunc(d [,fmt])  日期d按fmt指定格式截断到最近的日期
附:
日期格式:
--------------------------------
格式代码     说明   举例或可取值的范围
--------------------------------
DD            该月某一天  1-3
DY    三个大写字母表示的周几 SUN,...SAT
DAY    完整的周几,大写英文 SUNDAY,...SATURDAY
MM       月份   1-12
MON      三个大写字母表示的月份 JAN,...DEC
MONTH         完整   JANUARY,...DECEMBER
RM       月份的罗马数字  I,...XII
YY或YYYY      两位,四位数字年
HH:MI:SS   时:分:秒
HH12或HH24  以12小时或24小时显示
MI      分
SS      秒
AM或PM    上下午指示符
SP      后缀SP要求拼写出任何数值字段
TH      后缀TH表示添加的数字是序数 4th,1st
FM            前缀对月或日或年值,禁止填充
---------------------------------
例:
1.
下一个周五的日期
select next_day(sysdate,6) from test;
2.
两个月前的今天的日期
select add_months(sysdate,-2) from test;


--------------------------------------------------------------------------------------------------------------------------------------------------------------------


---------------------------------------------------------------------------------------------------------------------------------------------------------------------
in 等于括号内任一成员 如 select * from dept where deptno in ('10','20','30','40');
not in 不等于括号内任一成员 如 select * from dept where deptno not in ('10','20','30','40');
between A and b 大于等于A与小于等于B 如 select * from emp where sal beteen 1000 and 1500;
not between A and b 不大于等于A与小于等于B 如 select * from emp where sal beteen 1000 and 1500;
like '%A%' 包含给定子串A 如 select * from emp where ename like '%A%';
>= 大于或等于    <= 小于或等于 数值型常用函数  函数  返回值            样例    
       显示 ceil(n) 大于或等于数值n的最小整数  select ceil(10.6) from dual;
in 等于括号内任一成员 如 select * from dept where deptno in ('10','20','30','40');
not in 不等于括号内任一成员 如 select * from dept where deptno not in ('10','20','30','40');
between A and b 大于等于A与小于等于B 如 select * from emp where sal beteen 1000 and 1500;
not between A and b 不大于等于A与小于等于B 如 select * from emp where sal beteen 1000 and 1500;
like '%A%' 包含给定子串A 如 select * from emp where ename like '%A%';
>= 大于或等于    <= 小于或等于 数值型常用函数  函数  返回值            样例   
显示 ceil(n) 大于或等于数值n的最小整数  select ceil(10.6) from dual;
11
floor(n) 小于等于数值n的最大整数  select ceil(10.6) from dual;
10
mod(m,n) m除以n的余数,若n=0,则返回m select mod(7,5) from dual;
2
power(m,n) m的n次方         select power(3,2) from dual;
9
round(n,m) 将n四舍五入,保留小数点后m位  select round(1234.5678,2) from dual;
1234.57
sign(n) 若n=0,则返回0,否则,n>0,则返回1,n<0,则返回-1 select sign(12) from dual;
1
sqrt(n) n的平方根         select sqrt(25) from dual ;
5
常用字符函数 initcap(char) 把每个字符串的第一个字符换成大写  select initicap('mr.ecop') from dual;
Mr.Ecop
lower(char) 整个字符串换成小写         select lower('MR.ecop') from dual;
mr.ecop
replace(char,str1,str2) 字符串中所有str1换成str2 select replace('Scott','s','Boy') from dual;
Boycott
substr(char,m,n) 取出从m字符开始的n个字符的子串  select substr('ABCDEF',2,2) from dual;
CD
length(char) 求字符串的长度    select length('ACD') from dual;
3
|| 并置运算符    select 'ABCD'||'EFGH' from dual;
ABCDEFGH
日期型函数 sysdate 当前日期和时间 select sysdate from dual;
last_day  本月最后一天 select last_day(sysdate) from dual;
add_months(d,n) 当前日期d后推n个月 select add_months(sysdate,2) from dual;
months_between(d,n) 日期d和n相差月数 select months_between(sysdate,to_date('20020812','YYYYMMDD')) from
dual;
next_day(d,day) d后第一周指定day的日期 select next_day(sysdate,'Monday') from dual;
day 格式  有  'Monday' 星期一          'Tuesday' 星期二 'wednesday'  星期三 'Thursday' 星
期四 'Friday' 星期五 'Saturday' 星期六         'Sunday' 星期日 特殊格式的日期型函数 Y或YY或YYY ~
年的最后一位,两位,三位 select to_char(sysdate,'YYY') from dual;
Q 季度,1-3月为第一季度    select to_char(sysdate,'Q') from dual;
MM  月份数           select to_char(sysdate,'MM') from dual;
RM 月份的罗马表示 select to_char(sysdate,'RM') from dual;
IV month 用9个字符表示的月份名 select to_char(sysdate,'month') from dual;
ww 当年第几周         select to_char(sysdate,'ww') from dual;
w 本月第几周         select to_char(sysdate,'w') from dual;
DDD 当年第几天,一月一日为001 ,二月一日032 select to_char(sysdate,'DDD') from dual;
DD 当月第几天 select to_char(sysdate,'DD') from dual;
D 周内第几天 select to_char(sysdate,'D') from dual;
如 sunday DY 周内第几天缩写       select to_char(sysdate,'DY') from dual;
如 sun hh12 12小时制小时数       select to_char(sysdate,'hh12') from dual;
hh24 24小时制小时数       select to_char(sysdate,'hh24') from dual;
Mi 分钟数            select to_char(sysdate,'Mi') from dual;
ss 秒数             select to_char(sysdate,'ss') from dual;
select to_char(sysdate,'YYYY-MM-DD HH:24:mi:ss') from dua;
to_number() 将合法的数字字符串 select to_number('88877') from dual;
"kk" 43 行,4016 字符
in 等于括号内任一成员 如 select * from dept where deptno in ('10','20','30','40');
not in 不等于括号内任一成员 如 select * from dept where deptno not in ('10','20','30','40');
between A and b 大于等于A与小于等于B 如 select * from emp where sal beteen 1000 and 1500;
not between A and b 不大于等于A与小于等于B 如 select * from emp where sal beteen 1000 and 1500;
like '%A%' 包含给定子串A 如 select * from emp where ename like '%A%';
>= 大于或等于    <= 小于或等于 数值型常用函数  函数  返回值            样例    ~
       显示 ceil(n) 大于或等于数值n的最小整数  select ceil(10.6) from dual;
11 floor(n) 小于等于数值n的最大整数  select ceil(10.6) from dual;
10 mod(m,n) m除以n的余数,若n=0,则返回m select mod(7,5) from dual;
2 power(m,n) m的n次方         select power(3,2) from dual;
9 round(n,m) 将n四舍五入,保留小数点后m位  select round(1234.5678,2) from dual;
1234.57 sign(n) 若n=0,则返回0,否则,n>0,则返回1,n<0,则返回-1 select sign(12) from dual;
1 sqrt(n) n的平方根         select sqrt(25) from dual ;
5 常用字符函数 initcap(char) 把每个字符串的第一个字符换成大写  select initicap('mr.ecop') from dual;
Mr.Ecop lower(char) 整个字符串换成小写         select lower('MR.ecop') from dual;
mr.ecop replace(char,str1,str2) 字符串中所有str1换成str2 select replace('Scott','s','Boy') from dual;
Boycott substr(char,m,n) 取出从m字符开始的n个字符的子串  select substr('ABCDEF',2,2) from dual;
CD length(char) 求字符串的长度    select length('ACD') from dual;
3 || 并置运算符    select 'ABCD'||'EFGH' from dual;
ABCDEFGH 日期型函数 sysdate 当前日期和时间 select sysdate from dual;
last_day  本月最后一天 select last_day(sysdate) from dual;
add_months(d,n) 当前日期d后推n个月 select add_months(sysdate,2) from dual;
months_between(d,n) 日期d和n相差月数 select months_between(sysdate,to_date('20020812','YYYYMMDD')) from
dual;
next_day(d,day) d后第一周指定day的日期 select next_day(sysdate,'Monday') from dual;
day 格式  有  'Monday' 星期一          'Tuesday' 星期二 'wednesday'  星期三 'Thursday' 星
期四 'Friday' 星期五 'Saturday' 星期六         'Sunday' 星期日 特殊格式的日期型函数 Y或YY或YYY ~
年的最后一位,两位,三位 select to_char(sysdate,'YYY') from dual;
Q 季度,1-3月为第一季度    select to_char(sysdate,'Q') from dual;
MM  月份数           select to_char(sysdate,'MM') from dual;
RM 月份的罗马表示 select to_char(sysdate,'RM') from dual;
IV month 用9个字符表示的月份名 select to_char(sysdate,'month') from dual;
ww 当年第几周         select to_char(sysdate,'ww') from dual;
w 本月第几周         select to_char(sysdate,'w') from dual;
DDD 当年第几天,一月一日为001 ,二月一日032 select to_char(sysdate,'DDD') from dual;
DD 当月第几天 select to_char(sysdate,'DD') from dual;
D 周内第几天 select to_char(sysdate,'D') from dual;
如 sunday DY 周内第几天缩写       select to_char(sysdate,'DY') from dual;
如 sun hh12 12小时制小时数       select to_char(sysdate,'hh12') from dual;
hh24 24小时制小时数       select to_char(sysdate,'hh24') from dual;
Mi 分钟数            select to_char(sysdate,'Mi') from dual;
ss 秒数             select to_char(sysdate,'ss') from dual;
select to_char(sysdate,'YYYY-MM-DD HH:24:mi:ss') from dua;
to_number() 将合法的数字字符串 select to_number('88877') from dual;



2 oracle常见错误
引用
ORA-01650:unable to extend rollback segment NAME by NUM intablespace NAME

  产生原因:上述ORACLE错误为回滚段表空间不足引起的,这也是ORACLE数据管理员最常见的ORACLE错误信息。当用户在做一个非常庞大的数据操作导致现有回滚段的不足,使可分配用的回滚段表空间已满,无法再进行分配,就会出现上述的错误。

  解决方式:使用“ALTER TABLESPACE tablespace_name ADD DATAFILE filename SIZE size_of_file”命令向指定的数据增加表空间,根据具体的情况可以增加一个或多个表空间。当然这与还与你主机上的裸盘设备有关,如果你主机的裸盘设备已经没有多余的使用空间,建议你不要轻意的增加回滚段表空间的大小,可使用下列的语句先查询一下剩余的tablespace空间有多少:

  Select user_name,sql_text from V$open_cursor where user_name=’’;

  如果多余的空间比较多,就可以适当追加一个大的回滚段给表空间使用,从而避免上述的错误。你也可以用以下语句来检测一下rollback segment的竞争状况:

  Select class,count from V$waitstat where calss in(‘system undo header’,’system undo block’,’undo header’,’undo block’);和Select sum(value) from V$sysstat where name in (‘db_block_gets’,’consistents gets’);


  如果任何一个class in count/sum(value)大于1%,就应该考虑增加rollback segment。

  相应的英文如下:

  Cause:Failed to allocate extent from the rollback segment in tablespace

  Action:Use the ALTER TABLESPACE ADD DATAFILE statement to add one or more files to the specified tablespace.

  ORA-01652:unable to extend temp segment by num in tablespace name

  产生原因:ORACLE临时段表空间不足,因为ORACLE总是尽量分配连续空间,一但没有足够的可分配空间或者分配不连续就会出现上述的现象。

  解决方法:我们知道由于ORACLE将表空间作为逻辑结构-单元,而表空间的物理结构是数据文件,数据文件在磁盘上物理地创建,表空间的所有对象也存在于磁盘上,为了给表空间增加空间,就必须增加数据文件。先查看一下指定表空间的可用空间,使用视图SYS.DBA_FREE_SPACE,视图中每条记录代表可用空间的碎片大小:
 SQL>Select file_id,block_id,blocks,bytes from sys.dba_free_space where tablespace_name=’’;返回的信息可初步确定可用空间的最大块,看一下它是否小于错误信息中提到的尺寸,再查看一下缺省的表空间参数:

  SQL>SELECT INITIAL_EXTENT,NEXT_EXTENT,MIN_EXTENTS,PCT_INCREASE FROM SYS.DBA_TABLESPACES WHERE TABLESPACE_NAME=name;

  通过下面的SQL命令修改临时段表空间的缺省存储值:

  SQL>ALTER TABLESPACE name DEFAULT STORAGE (INITIAL XXX NEXT YYY);

  适当增大缺省值的大小有可能解决出现的错误问题,也可以通过修改用户的临时表空间大小来解决这个问题:

  SQL>ALTER USER username TEMPORARY TABLESPACE new_tablespace_name;

  使用ALTER TABLESPACE命令,一但完成,所增加的空间就可使用,无需退出数据库或使表空间脱机,但要注意,一旦添加了数据文件,就不能再删除它,若要删除,就要删除表空间。

  一个报错例子如下:

  ORA-1652:unable to extend temp segment by 207381 in tablespace TEMPSPACE

  相应的英文如下:

  Cause: Failed to allocate extent for temp segment in tablespace

  Action:Use the ALTER TABLESPACE ADD DATAFILE statement to add one or more files to the specified tablespace or create the object in another tablespace.

  产生原因:当ORACLE访问一个数据块时,由于1、硬件的I/O错误;2、操作系统的I/O错误或缓冲问题;3、内存或paging问 题;4、ORACLE试图访问一个未被格式化的系统块失败;5、数据文件部分溢出等上述几种情况的一种引起了逻辑坏块或者物理坏块,这时就会报ORA-01578的错误。

  解决方式:由于ORACLE只有在访问到有问题的数据文件时才会报错,所以报错的时间有可能会比实际出错的时间要晚,如果ORA-01578出错信息提示数据坏块指向的是用户自己的数据文件,则用以下方法来解决:

  如果通过下面的SQL语句查出的坏块出现有索引上,则只需重建索引即可

  SQL>Select owner,segment_name,segment_type from dba_extents where file_id= and between block_id and block_id+blocks-1;(和分别是ORA-01578报出的坏块出现的文件号和块号)

  如果坏块出现在表上,先用以下语句分析是否为永久性坏块(建议多执行一两次,有助于鉴别数据坏块是永久性的(硬盘上的物理坏块)还是随机性的(内存或硬件错误引起)):

  SQL>Analyze table validate structure cascade;

  执行该命令后,可能会出现以下的结果:

  ORA-01578:与原先错误信息有相同的参数,为永久性的物理或逻辑坏块;与原先错误信息有不同的参数,可能与内存,page space和I/O设备有关。如果用户有此表的最新备份,那么最好是用此备份来恢复此表,或者使用event 10231来取出坏块以外的数据:

  <1>.先关闭数据库

  <2>.编辑init.ora文件,加入:

  event=”10231 trace name context forever,level 10”

  <3>.startup restrict

  <4>.创建一个临时表:SQL>create table errortemp as select * from error;(error是坏表的表名)

  <5>.把event从init.ora文件中删掉并重起数据库


  <6>.rename坏表,把临时表rename成坏表的表名

  <7>.创建表上的INDEX等

  如果ORA-01578出错信息提示数据坏块指向的是数据字典或者是回滚段的话,你应该立即与ORACLE公司联系,共同商量一个好的解决办法。

  这里所讲的解决方法只是比较常见的一种,一些更为具体的解决办法可以查看一下ORACLE的故障解决手册,那里面有浞及使用ROWID方法来取出坏块以外的数据的方法,这里就不介绍了。

  相应的英文如下:

  Cause:The given data block was corrupted,probably due to program errors

  Action:Try to restore the segment containing the given data block,This may involve dropping the segment and recreating it,If there is a trace file,report the messages recorded in it to customer support.

  ORA-01628:max # of extents num reached for rollback segment num

  产生原因:这种错误通常为一个回滚段和一个表空间已经达到MAXEXTENTS参数设置的极限。要注意的是这个MAXEXTENTS不是该回滚段或表空间的硬件极限,硬件极限取决于数据库创建时在init.ora文件中指定的DB_BLOCK_SIZE参数的值。

  解决方法:使用SQL命令ALTER TABLESPACE…STORAGE(MAXEXTENTS XXXX)来增加 MAXEXTENTS,其中“XXXX”值必须大于错误信息中所指的数值,但不能大于LARGEST MAXEXTENT的值,如果已经达到了LARGEST MAXEXTENT VALUE,解决的办法就是重新创建较大的范围尺寸,使用带有选项COMPRESS=Y的Export工具导出表,如果表空间有可用空间,先给表做一个备份,用alter tablespace tablespace_name更改其名字,然后再装载表回数据库。查看其错误出现的地方,如果出现在回滚段或索引上,那么必须将其删除并重建,如果出现在临时表空间,修改临时表空间的存储字段,便可解决这个问题。

一个报错例子如下:

  ORA-1628:max # extents 50 reached for rollback segment RBS_1

  相应的英文如下:

  Cause: An attempt was made to extend a rollback segment that already has reached its maximum size or space could not be allocated in the data dictionary to contain the definition of the object.

  Action:If possible,increase the value of either the MAXEXTENTS or PCTINCREASE initialization parameters or find the data dictionary table lacking space and alter the storage parameters,as described in the Oracle8 Server Administrator’s Guide.

  产生原因:这种错误通常为ORACLE的内部错误,只对OSS和ORACLE开发有用。ORA-600的错误经常伴随跟踪文件的状态转储 (系统状态和进程状态),系统状态存储将包括ORACLE RDBMS持有的当前对象的信息,进程状态转储则将显示特殊进程持有的对象,当进程符合了某错误条件时,经常是由于一些信息取自它持有的一个块,如果我们知道这些错误进程持有的块,就容易跟踪问题的来源。

  解决方法:一般来说出现这个错误我们本身是无法解决的,只有从提高系统本身各方面来解决这个内部问题,如增加硬件设备,调整系统性能,使用OPS(当然OPS从某种意义上说并不是一种好的解决方式)等。ORA-600错误的第一个变量用于标记代码中错误的位置(代码中的每个部分的第一变量都不一样),从第二个到第五个变量显示附加信息,告诉OSS代码在哪里出现了错误。

  一个报错例子如下:

  ORA-00600: internal error code, arguments: [1237], [], [], [], [], [], [], []

  相应的英文如下:

  Cause:This is a catchall internal error message for Oracle program exceptions.It indicates that a process has met a low-level,unexpected condition.Various causes of this message include:

  Time-outs(超时)

  File corruption(文件太老)

  Failed data checks in memory(内存检索失败)

  Hardware,memory,or I/O errors(硬件、内存或者磁盘错误)

  Incorrectly restored files(错误的重建文件)

  ORA-03113:end-of-file on communication channel

  产生原因:通讯不正常结束,从而导致通讯通道终止

  解决方法:

  1>.检查是否有服进程不正常死机,可从alert.log得知

  2>.检查sql*Net Driver是否连接到ORACLE可执行程序

  3>.检查服务器网络是否正常,如网络不通或不稳定等

  4>.检查同一个网上是否有两个同样名字的节点

  5>.检查同一个网上是否有重复的IP地址

Cause:An unexpected end-of-file was processed on the communication channel.The problem could not be handled by the Net8,two task,software.This message could occur if the shadow two-task process associated with a Net8 connect has terminated abnormally,or if there is a physical failure of the interprocess communication vehicle,that is,the network or server machine went down.

  Action:If this message occurs during a commection attempt,check the setup files for the appropriate Net8 driver and confirm Net8 software is correctly installed on the server.If the message occurs after a connection is well established,and the error is not due to a physical failure,check if a trace file was generated on the server at failure time.Existence of a trace file may suggest an Oracle internal error that requires the assistance of customer support.

  ORA-00942:table or view does not exist

  产生原因:这是由于装载的表或视图不存在,多半是CATEXP.SQL还没有运行,无法执行Export视图,如果CATEXP.SQL已经运行,则可能是版本错误。

  解决方法:因为Import和Export共享的一些视图是通过运行CATEXP.SQL来装载的(它们具有相同的视图),并不生成单独的CATEXP.SQL,因而造成视图与Export代码不同步,较难保持彼此之间的兼容,用户就必须建立自己的Export应用,从而避免ORA-00942的错误。

  相应的英文如下:

  Cause:The table or view entered does not exist,a synonym that is jnot allowed here was used,or a view was referenced where a table is required.Existing user tables and views can be listed by querying the data dictionary.Certain privileges may required to access the table.If an application returned this message,the table the application tried to access does not exist in the database,or the application does not have access to it.

  Action:Check each of the following:

  The spelling of the table or view name.

  That a view is not specified where a table is required

  That an existing table or view name exists.

  Contact the database administrator if the table needs to be created or if user or application priviledes are required to access the table.

  Also, if attempting to access a table or view in another schema,make certain thecorrect schema is referenced and that access to the object is granted.

  ORA-01598:rollback segment “name” is not online

  Cause:The rollback segment was taken offline either manually or by SMON.

  Action:Check the status of the rollback segment in DBA_ROLLBACK_SEGS.

  ORA-1636: rollback segment “name” is already online

  Cause:A rollback segment can only be used by one instance and an instance is trying to bring a rollback segment online that is already in use.

  Action:Check that the values set in the initialization parameter file for parameters

  ROLLBACK_SEGMENTS,ROLLBACK_SEGMENT_INITIAL,and ROLLBACK_SEGMENT_COUNT are correctly set for the instance whiththe problem,Also check that the instance is using the correct initialization parameter file.Make sure you are not confused about the difference between private and public rollback segments.See the Oracle8 Server Administrator’s Guide for more information about using rollback segments in paraller mode.

  上述错误均为我们在使用回滚段时比较常见的问题,ORA-01598指明当前使用的回滚段的状态为“not online”,不能使用,将它改为“online”状态即可使用;ORA-01636指明当前回滚段已经为“online”状态,可以直接使用,不用再集合它。
 ORA-1636 signalled during: alter rollback segment rb00 online

  我们在做统计时还可能遇到下述问题:一个rollback segment的状态为”Needs Recovery”的现象,这是由于ORACLE回退一个事物表中的没有提交的事物时失败所造成的。通常原因为一个datafile或者tablespace是在offline的状态或者一个undo的目标被破坏或者rollback segment被破坏。解决的办法是将所有的tablespace和datafile都置为online状态,如果不能解决则做下面的工作:1>.在initsid.ora中加入event=”10015 trace name context forever lever 10”;2>.shutdown数据库然后重启;3>.在$ORACLE_HOME/rdbms/log下,找到startup时生成的trace file;4>.在trace文件中,找到下列信息“error recovery tx(#,#) object #”;5>.根据object#(与sys.dba_objects表中的object_id相同)在sys.dba_objects表中查出该object的名字;6>.将该object drop掉;7>.在init.ora文件中将该rollback segment放回rollback_segments参数中,删除event;8>.shutdown数据库然后重启。此时”Needs Recovery”的问题应该是完全解决了,否则就是rollback segment被破坏了。

  ORA-01688:unable to extend table name.name partition NAME by NUM in tablespace NAME

  产生原因:指定的tablespace空间已经被占用满,无法扩展。

  解决方法:使用“ALTER TABLESPACE ADD DATAFILE”命令增加文件系统文件和原始分区,或者增加INITIAL的大小(如:alter tablespace CDRS101 default storage(next 500M pctincrease 1))应该能够解决,否则就是有人使用你的表空间上创建了一个比较大的数据文件导致你的表空间不够用。

  一个报错例子如下:

  ORA-1688: unable to extend table RMMCDR.LOCAL_CDR partition LOCAL_CDR101 by 460800 in tablespace CDRS101

  相应的英文如下:

  Cause:An extent could not be allocated for a table segment in tablespace

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-298758-1-1.html 上篇帖子: MY SQL 1130 ERROR 下篇帖子: 在同一个xp系统里同时安装SQL Server2000和SQL Server2005
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表