当前位置: 动力学知识库 > 问答 > 编程问答 >

My PostgreSQL auto inserts many space characters after the value of a field

问题描述:

When I insert data in PostgreSQL, it is auto inserting many spaces after the value of the field.

I tired to fix it, but I can't find anything

For example: I want to insert value 'John' in column 'Name'. It inserts spaces after John.

->> 'John______________________________________________________________'

网友答案:

character is an awful data type that should not be used. This is just one of the reasons. See character types - postgresql manual.

Change those fields to text or to varchar(n). text with a check constraint on length where one is required is usually the best option.

ALTER TABLE thetable ALTER COLUMN colname TYPE text;

BTW, it's easier to answer your questions if you post the SQL and - preferably - the output of running that SQL in psql, which produces copy-and-pasteable plain text output.

分享给朋友:
您可能感兴趣的文章:
随机阅读: