Sybase,数据类型
Sybase, data type
我有 2 个问题:
(1)
declare @m varchar
set @m='10'
select * from test where month=@m
(2)
declare @m varchar(2)
set @m='10'
select * from test where month=@m
结果中的行数不同。在 2 个变体中比第一个变体更多。可能是什么原因?
那是因为当您没有指定 varchar
变量可以容纳多少字节时,引擎使用 default 和 1
:
When n isn't specified in a data definition or variable declaration
statement, the default length is 1. If n isn't specified when using
the CAST and CONVERT functions, the default length is 30.
因此,在第一种情况下,您有:
select * from test where month=1
第二个:
select * from test where month=10
我有 2 个问题:
(1)
declare @m varchar
set @m='10'
select * from test where month=@m
(2)
declare @m varchar(2)
set @m='10'
select * from test where month=@m
结果中的行数不同。在 2 个变体中比第一个变体更多。可能是什么原因?
那是因为当您没有指定 varchar
变量可以容纳多少字节时,引擎使用 default 和 1
:
When n isn't specified in a data definition or variable declaration statement, the default length is 1. If n isn't specified when using the CAST and CONVERT functions, the default length is 30.
因此,在第一种情况下,您有:
select * from test where month=1
第二个:
select * from test where month=10