接受的答案,以this question声称使用CHAR列将保留所有填空格在Sybase的字符串,但这并不是我所看到的(除非我弄错的行为是什么“填空格”的意思)。例如,当我运行下面的脚本:Sybase是否支持不正确的字符串类型?
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到不剥离尾部的空格?此外,有没有办法让它将空字符串保存为空字符串,而不是作为单个空格?
我正在使用Sybase 15.5。
谢谢。它适用于not null设置,但问题是它总是返回长度为20的字符串(例如,我插入一个空白字符串,并在select上返回20个空格)。这不是一个可接受的解决方案。 Varchar是要走的路,但是这种修改我插入的数据的行为在Sybase中是相当恼人的行为。 –
前一段时间,我必须在同一个案例中总是添加一个字符。当然,我必须在客户端删除最后一个字符。这不是最好的,但在我的情况下工作。 – kolchanov