开发者

SQL row is only varchar(10) but has 30+ characters in it

开发者 https://www.devze.com 2023-03-05 04:37 出处:网络
table on external database (when I click mo开发者_开发问答dify) states that row A is a varchar(10) but when I look at the data there is obviously many more characters in it. How is this possible?

table on external database (when I click mo开发者_开发问答dify) states that row A is a varchar(10) but when I look at the data there is obviously many more characters in it. How is this possible?

This concerns me because when I pull data from that row, I only get 10 characters, and the rest is cut off. I am not allowed to modify the external database tables.


How is this possible? The column was probably originally a varchar(30) and was subsequently altered to varchar(10). I assume data has been written since the change to varchar(10), which makes this a true mess. If altering the column back to a length of 30 is not possible, I would investigate the implications of truncating the old data to 10 characters.

Update run the following statement to confirm the column length:

select character_maximum_length
from information_schema.columns
where table_name='tablename' and COLUMN_NAME='columnname'

Update 2:

select max(len(column_name))
from tablename
0

精彩评论

暂无评论...
验证码 换一张
取 消