2010-03-17 7 views

답변

9

뭔가 변경 ALTER TABLE t ALTER COLUMN c TYPE VARCHAR(255) USING SUBSTR(c, 1, 255)

0
BEGIN; 
UPDATE table SET column = CAST(column as varchar(255)); 
ALTER TABLE table ALTER COLUMN column TYPE varchar(255); --not sure on this line. my memory is a bit sketchy 
COMMIT; 
3

1)을 절단하는 문자열 방법을 사용하여 열 데이터를 업데이트

update t set col = substring(col from 1 to 255) 

2) 그런 다음 테이블 열 여기

alter table t alter column col type varchar(255) 

문서 도구와 같은 http://www.postgresql.org/docs/8.4/static/sql-altertable.html

+1

더 최근의 pgsql과 같습니다 : update t set col = substring (1에서 255까지 col) ("for"가 "to"를 대체합니다) – user1051849