改变字段类型? [英] Alter field type?

查看:77
本文介绍了改变字段类型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在不制作

a新表的情况下改变字段类型(从varchar到文本)?

问候,


BTJ

-

-------------------------- -------------------------------------------------- -------------------

有人写道:

我明白如果你向后播放Windows CD你听到很奇怪

撒旦的消息

有人回复:

它甚至比那更糟糕;玩转发它安装Windows

---------------------------------- -------------------------------------------------- -----------


--------------------------- (播出结束)---------------------------

提示9:规划师会忽略你的愿望如果您的

加入列的数据类型不匹配,请选择索引扫描

Is it possible to alter field type (from varchar to text) without making
a new table?
Regards,

BTJ

--
-----------------------------------------------------------------------------------------------
Someone wrote:
"I understand that if you play a Windows CD backwards you hear strange
Satanic messages"
To which someone replied:
"It''s even worse than that; play it forwards and it installs Windows"
-----------------------------------------------------------------------------------------------

---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column''s datatypes do not match

推荐答案




Am Do,den 26.08.2004 schrieb Bj?rn T Johansen um 9:48:
Hi,

Am Do, den 26.08.2004 schrieb Bj?rn T Johansen um 9:48:
是否可以改变字段类型(从varchar到text )没有制作一张新桌子?
Is it possible to alter field type (from varchar to text) without making
a new table?




在8.0中我认为。

7.4.x中的常见做法是:


BEGIN工作;

ALTER TABLE yourtable ADD COLUMN临时文本;

UPDATE yourtable SET tempcolumn = origcolumn;

ALTER TABLE yourtable DROP COLUMN origcolumn;

ALTER TABLE yourtable RENAME tempcolumn TO o rigcolumn;

COMMIT工作;


由于文本和(无限制)varchar完全相同,

你可以逃脱修改系统表。

但我不建议这样做。


问候

Tino Wildenhain

---------------------------(广播结束)--------------- ------------

提示3:如果通过Usenet发布/阅读,请向
subscribe-nomail命令=mailto:ma ******* @ postgresql.org> ma ******* @ postgresql.org
以便您的

消息可以通过干净的邮件清单



In 8.0 I think.
Common practice in 7.4.x is:

BEGIN work;
ALTER TABLE yourtable ADD COLUMN tempcolumn text;
UPDATE yourtable SET tempcolumn = origcolumn;
ALTER TABLE yourtable DROP COLUMN origcolumn;
ALTER TABLE yourtable RENAME tempcolumn TO origcolumn;
COMMIT work;

Since text and (unlimited) varchar are quite the same,
you could get away with modifying the system tables.
But I would not recomment to do so.

Regards
Tino Wildenhain
---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to ma*******@postgresql.org so that your
message can get through to the mailing list cleanly




Bj?rn T Johansen< bt*@havleik.no>写道:

Bj?rn T Johansen <bt*@havleik.no> writes:
是否可以在不制作新表的情况下改变字段类型(从varchar到文本)?
Is it possible to alter field type (from varchar to text) without making a new
table?




您可以添加新列,更新表以将新列设置为旧的

值。然后放弃旧列。然后你可能想把桌子抽真空。


在8.0中会有一个命令来做你想要的,但它仍然需要

do所有与上述相同的工作。


-

greg

---------- -----------------(广播结束)---------------------------

提示2:您可以使用取消注册命令一次性取消所有列表

(将注册YourEmailAddressHere发送到 ma ******* @ postgresql.org



You can add a new column, update the table to set the new column to the old
value. then drop the old column. Then you might want to vacuum full the table.

In 8.0 there will be a command to do what you want, but it will still have to
do all the same work as I described above.

--
greg
---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to ma*******@postgresql.org)


看起来像食谱,thx ... :)


BTJ


Tino Wildenhain写道:
That looks like a recipe, thx... :)

BTJ

Tino Wildenhain wrote:


Am Do,den 26.08.2004 schrieb Bj?rn T Johansen嗯9:48:
Hi,

Am Do, den 26.08.2004 schrieb Bj?rn T Johansen um 9:48:
是否可以改变字段类型(从varchar到text)而不用
一张新桌子?
Is it possible to alter field type (from varchar to text) without making
a new table?



8.0我认为。
7.4.x中的常见做法是:

BEGIN工作;
ALTER TABLE yourtable ADD COLUMN临时文本;
UPDATE yourtable SET tempcolumn = origcolumn;
ALTER TABLE yourtable DROP COLUMN origcolumn;
ALTER TABLE yourtable RENAME tempcolumn TO origcolumn;
COMMIT工作;

由于文本和(无限制)varchar完全相同,
你可以通过修改系统表来逃避。
但我不建议做所以。

问候
Tino Wildenhain


In 8.0 I think.
Common practice in 7.4.x is:

BEGIN work;
ALTER TABLE yourtable ADD COLUMN tempcolumn text;
UPDATE yourtable SET tempcolumn = origcolumn;
ALTER TABLE yourtable DROP COLUMN origcolumn;
ALTER TABLE yourtable RENAME tempcolumn TO origcolumn;
COMMIT work;

Since text and (unlimited) varchar are quite the same,
you could get away with modifying the system tables.
But I would not recomment to do so.

Regards
Tino Wildenhain




-

------- -------------------------------------------------- --------------------------------------

Bj?tn Johansen(BSc,MNIF)

执行经理
bt*@havleik.no Havleik Consulting
电话:+47 21 69 15 20 Bj?rneb?rstien 57

传真:+47 41 13 09 15 N-1348 Rykkinn

Cellular:+ 47 926 93 298 http://www.havleik.no

----------------- -------------------------------------------------- ----------------------------

有人写道:

我明白如果你向后播放Windows CD你会听到奇怪的声音

撒旦的消息

有人回复:

它是更糟糕的是;玩转发它安装Windows

---------------------------------- -------------------------------------------------- -----------


--------------------------- (广播结束)---------------------------

提示1:订阅和取消订阅命令转到< a href =mailto:ma ******* @ postgresql.org> ma ******* @ postgresql.org



--
-----------------------------------------------------------------------------------------------
Bj?rn T Johansen (BSc,MNIF)
Executive Manager
bt*@havleik.no Havleik Consulting
Phone : +47 21 69 15 20 Bj?rneb?rstien 57
Fax : +47 41 13 09 15 N-1348 Rykkinn
Cellular : +47 926 93 298 http://www.havleik.no
-----------------------------------------------------------------------------------------------
Someone wrote:
"I understand that if you play a Windows CD backwards you hear strange
Satanic messages"
To which someone replied:
"It''s even worse than that; play it forwards and it installs Windows"
-----------------------------------------------------------------------------------------------

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to ma*******@postgresql.org


这篇关于改变字段类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆