由于在查询中需要用到 UNION ALL 操作,而表中的存在 LONG 类型字段,操作无法完成,根据具体业务场景,将 LONG 类型字段修改为 CLOB 类型。修改后,UNION ALL 操作可行,但是子表的增删改操作出现了问题,提示为父表的 INDEX 不可用。 这里顺便说一句:如果
由于在查询中需要用到 UNION ALL 操作,而表中的存在 LONG 类型字段,操作无法完成,根据具体业务场景,将 LONG 类型字段修改为 CLOB 类型。修改后,UNION ALL 操作可行,但是子表的增删改操作出现了问题,提示为父表的 INDEX 不可用。这里顺便说一句:如果要从VARCHAR2类型修改为特殊类型CLOB,那么不能直接从VARCHAR2转换为CLOB,需要使用LONG类型,来做一个过渡(可以先修改为LONG类型,然后从LONG修改为CLOB)。
-
解决方案:
1.同事前不久也遇到了这个问题,他的解决方案是:备份旧的表,删除表,然后再导入数据,并且依然需要重建主键等。对没有直接操作权限的ORCALE服务器恐怕有难度。所以这里归根结底还是drop and re-create。
2.重建索引。Oracle重建索引有多种方式,如 drop and re-create、rebuild、rebuild online等。这里采用的是第一种方式删除创建。需要的一些脚本如下(TB_SCENERY是父表【景点表】,TB_SCENERY_TICKETS是子表【景点门票表】):
1.--查询主外键,表名一定要大写
2.select constraint_name from user_constraints where table_name = 'TB_SCENERY'; 3.select constraint_name from user_constraints where table_name = 'TB_SCENERY_TICKETS'; 4.
5.--删除主外键,注意大小写 6.alter table TB_SCENERY drop constraint SCENERY_PK_ID; 7.alter table TB_SCENERY_TICKETS drop constraint SCENERY_ID; 8.
9.--增加主键(增加主键时会自动建立关于主键的索引) 10.alter table TB_SCENERY add constraint SCENERY_PK_ID primary key (ID) ; 11.
12.--增加外键 13.alter table TB_SCENERY_TICKETS add constraint SCENERY_PK_ID foreign key (SCENERY_ID) references TB_SCENERY (ID); 14.
15.--查询表的相关索引 16.select index_name,index_type,table_name from user_indexes where table_name='TB_SCENERY'; 17.
18.--删除索引[强制] 19.DROP INDEX SCENERY_PK_ID [FORCE]; 20.
21.--查询哪些表没有建立索引 22.SELECT table_name FROM User_tables t WHERE NOT EXISTS (SELECT table_name FROM User_constraints c WHERE constraint_type = 'P' AND t.table_name=c.table_name) 这里的步骤是:
1.查询子表的外键名称,删除对应的外键,以及外键对应的索引
2.查询主表的主键名称,删除对应的主键,以及主键对应的索引
3.建立主表主键(主键索引会自动建立),建立子表外键,建立外键索引
3.drop and re-create 方式的有点是速度快,缺点是会影响原有的SQL查询,如果考虑这个影响那就可以采用rebuild的方式(IDX_TEST_C1这是索引名称):
ALTER INDEX IDX_TEST_C1 REBUILD;
其实开始是尝试的是rebuild的方式,但是失败了,无可奈何只能采用drop and re-create 方式。

方法:1、利用“select*from user_indexes where table_name=表名”语句查询表中索引;2、利用“select*from all_indexes where table_name=表名”语句查询所有索引。

oracle asm指的是“自动存储管理”,是一种卷管理器,可自动管理磁盘组并提供有效的数据冗余功能;它是做为单独的Oracle实例实施和部署。asm的优势:1、配置简单、可最大化推动数据库合并的存储资源利用;2、支持BIGFILE文件等。

在oracle中,可以利用“TO_SINGLE_BYTE(String)”将全角转换为半角;“TO_SINGLE_BYTE”函数可以将参数中所有多字节字符都替换为等价的单字节字符,只有当数据库字符集同时包含多字节和单字节字符的时候有效。

在Oracle中,可利用lsnrctl命令查询端口号,该命令是Oracle的监听命令;在启动、关闭或重启oracle监听器之前可使用该命令检查oracle监听器的状态,语法为“lsnrctl status”,结果PORT后的内容就是端口号。

在oracle中,可以利用“select ... From all_tab_columns where table_name=upper('表名') AND owner=upper('数据库登录用户名');”语句查询数据库表的数据类型。

在oracle中,可以利用“drop sequence sequence名”来删除sequence;sequence是自动增加数字序列的意思,也就是序列号,序列号自动增加不能重置,因此需要利用drop sequence语句来删除序列。

方法:1、利用“LOWER(字段值)”将字段转为小写,或者利用“UPPER(字段值)”将字段转为大写;2、利用“REGEXP_LIKE(字符串,正则表达式,'i')”,当参数设置为“i”时,说明进行匹配不区分大小写。

方法:1、利用“alter system set sessions=修改后的数值 scope=spfile”语句修改session参数;2、修改参数之后利用“shutdown immediate – startup”语句重启服务器即可生效。


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Dreamweaver Mac version
Visual web development tools

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

SublimeText3 Chinese version
Chinese version, very easy to use

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),
