Sybase 是否支持它不正确修剪的字符串类型? [英] Does Sybase support string types that it doesn't right trim?

查看:39
本文介绍了Sybase 是否支持它不正确修剪的字符串类型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个问题的公认答案声称使用字符列将保留all 在 Sybase 中的字符串中填充空格,但这不是我看到的行为(除非我误解了填充空格"的含义).例如,当我运行以下脚本时:

The accepted answer to this question claims that using a char column will preserve all filling spaces in a string in Sybase, but that is not the behavior I am seeing (unless I'm mistaken about what 'filling spaces' means). For example, when I run the following script:

create table #check_strings
(
    value char(20) null
)

insert into #check_strings values (null)
insert into #check_strings values ('')
insert into #check_strings values (' ')
insert into #check_strings values ('     ')
insert into #check_strings values ('blah')
insert into #check_strings values ('blah ')
insert into #check_strings values ('blah    ')
insert into #check_strings values ('    blah    ')

select value, len(value) from #check_strings

我得到以下输出:

[NULL]            - [NULL]
[single space]    - 1
[single space]    - 1
[single space]    - 1
blah              - 4
blah              - 4
blah              - 4
[four spaces]blah - 8

有什么方法可以让 Sybase 去除尾随空格?另外,有没有办法让它将空字符串保存为空字符串,而不是单个空格?

Is there any way to get Sybase to not strip off trailing spaces? Additionally, is there any way to get it to save an empty string as an empty string, and not as a single space?

我使用的是 Sybase 15.5.

I'm using Sybase 15.5.

推荐答案

请参见 http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.help.ase_15.0.sqlug/html/sqlug/sqlug208.htm

当您创建允许空值的 char、unichar 或 nchar 列时,Adaptive Server 将其转换为 varchar、univarchar 或 nvarchar 列并使用这些数据类型的存储规则."

"When you create a char, unichar, or nchar column that allows nulls, Adaptive Server converts it to a varchar, univarchar, or nvarchar column and uses the storage rules for those datatypes."

请检查非空列.

这篇关于Sybase 是否支持它不正确修剪的字符串类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆