日期:2014-05-17  浏览次数:20630 次

为什么修改不了数据类型啊
我创建了一个表,但是ponum 定义的长度太短,想给他改长点,用以以下语句,可一直提示错误
ALTER TABLE purchase_order4 ALTER COLUMN ponum CHARACTER(10);

CREATE TABLE purchase_order4
(
  ponum character(5) NOT NULL,
  qty character(10),
  orderdate date,
  duedate date,
  receiveddate date,
  CONSTRAINT purchase_order4_pkey PRIMARY KEY (ponum)
)
------解决方案--------------------
--查询约束
sp_helpconstraint purchase_order4
--删除约束
ALTER TABLE purchase_order4 
drop constraint purchase_order4_pkey


然后你再修改下字段试试..
------解决方案--------------------
ALTER TABLE purchase_order4  add constraint purchase_order4_pkey PRIMARY KEY(ponum)

还有别忘了再加回约束..
------解决方案--------------------


CREATE TABLE  purchase_order4

(
  ponum character(5) NOT NULL,
  qty character(10),
  orderdate datetime,
  duedate datetime,
  receiveddate datetime,
  CONSTRAINT purchase_order4_pkey PRIMARY KEY (ponum)

--改变前字符长度为5
/*
Column_name                                                                                                                      Type                                                                                                                             Computed                            Length      Prec  Scale Nullable                            TrimTrailingBlanks                  FixedLenNullInSource                Collation
-------------------------------------------------------- -------------------------------------------------------- ----------------------------------- ----------- ----- ----- ---------------------------------