如何在 Oracle 中的查询结果中显示字段的隐藏字符?

发布于 2024-10-19 09:00:00 字数 306 浏览 2 评论 0原文

我有两行的 varchar 列根据 Java .equals() 有所不同。我无法轻松更改或调试针对此特定数据库运行的 Java 代码,但我可以使用 SQLDeveloper 直接针对数据库进行查询。这些字段对我来说看起来是一样的(它们是街道地址,有两行由一些新行或回车/新行组合分隔)。

有没有办法查看查询结果中的所有隐藏字符?我想避免将 ascii() 函数与 substr() 一起使用在每一行上找出哪个隐藏字符是不同的。

我还接受一些查询,显示哪个字符是两个字段之间的第一个区别。

I have two rows that have a varchar column that are different according to a Java .equals(). I can't easily change or debug the Java code that's running against this particular database but I do have access to do queries directly against the database using SQLDeveloper. The fields look the same to me (they are street addresses with two lines separated by some new line or carriage feed/new line combo).

Is there a way to see all of the hidden characters as the result of a query?I'd like to avoid having to use the ascii() function with substr() on each of the rows to figure out which hidden character is different.

I'd also accept some query that shows me which character is the first difference between the two fields.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

喜爱皱眉﹌ 2024-10-26 09:00:00

尝试

select dump(column_name) from table

更多信息位于文档

至于寻找角色不同的位置,这可能会给你一个想法:

create table tq84_compare (
  id  number,
  col varchar2(20)
);

insert into tq84_compare values (1, 'hello world');
insert into tq84_compare values (2, 'hello' || chr(9) || 'world');

with c as (
 select
  (select col from tq84_compare where id = 1) col1,
  (select col from tq84_compare where id = 2) col2
 from
  dual
),
l as (
  select
  level l from dual
  start with 1=1
  connect by level < (select length(c.col1) from c)
)
select 
  max(l.l) + 1position
from c,l
  where substr(c.col1,1,l.l) = substr(c.col2,1,l.l);

Try

select dump(column_name) from table

More information is in the documentation.

As for finding the position where the character differs, this might give you an idea:

create table tq84_compare (
  id  number,
  col varchar2(20)
);

insert into tq84_compare values (1, 'hello world');
insert into tq84_compare values (2, 'hello' || chr(9) || 'world');

with c as (
 select
  (select col from tq84_compare where id = 1) col1,
  (select col from tq84_compare where id = 2) col2
 from
  dual
),
l as (
  select
  level l from dual
  start with 1=1
  connect by level < (select length(c.col1) from c)
)
select 
  max(l.l) + 1position
from c,l
  where substr(c.col1,1,l.l) = substr(c.col2,1,l.l);
_畞蕅 2024-10-26 09:00:00
SELECT DUMP('€ÁÑ', 1016)
FROM DUAL

...将打印类似以下内容:

Typ=96 Len=3 CharacterSet=WE8MSWIN1252: 80,c1,d1
SELECT DUMP('€ÁÑ', 1016)
FROM DUAL

... will print something like:

Typ=96 Len=3 CharacterSet=WE8MSWIN1252: 80,c1,d1
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文