in mysql...
登录 | 论坛导航 -> 华新鲜事 -> 求学狮城 | 本帖共有 3 楼,分 1 页, 当前显示第 1 页 : 本帖树形列表 : 刷新 : 返回上一页
<<始页  [1]  末页>>
作者:小蹦 (等级:10 - 炉火纯青,发帖:3962) 发表:2004-09-28 01:22:14  楼主  关注此帖
in mysql...
改一个column的属性怎样改?如果该column是primary key呢?

比方说从varchar(20)改为numeric(20)...


谢了!
欢迎来到华新中文网,踊跃发帖是支持我们的最好方法!原文 / 传统版 / WAP版所有回复从这里展开收起列表
作者:小蹦 (等级:10 - 炉火纯青,发帖:3962) 发表:2004-09-28 19:13:02  2楼
小蹦请进suppose u want to change column a in table t, from varchar(20) to numeric(20) and change its name from a to b, u can use ALTER TABLE t CHANGE a b numeric(20); value in the column will be truncated, if the memory of new type is not big enough to store this value; As for primary key, if u want to change its type from one to another, u should make sure that there won't be two duplicate value in that column after u do the transformation. otherwise, it will refuse to do the job
不行也。。。
i use: ALTER TABLE t CHANGE a a numeric(20);

got error: All parts of a PRIMARY KEY must be NOT NULL; If you need NULL in a key, use UNIQUE instead..

why? is it because the field 'a' is a primary key?
欢迎来到华新中文网,踊跃发帖是支持我们的最好方法!原文 / 传统版 / WAP版所有回复从这里展开收起列表
作者:小蹦 (等级:10 - 炉火纯青,发帖:3962) 发表:2004-09-28 22:24:24  3楼
how come this error appear,...after u do the altering???? do u have any null value which is ur primary key ?
没有啊。。。
id就是1, 10, 100, 101共四个。。。
欢迎来到华新中文网,踊跃发帖是支持我们的最好方法!原文 / 传统版 / WAP版所有回复从这里展开收起列表
论坛导航 -> 华新鲜事 -> 求学狮城 | 返回上一页 | 本主题共有 3 篇文章,分 1 页, 当前显示第 1 页 | 回到顶部
<<始页  [1]  末页>>

请登录后回复:帐号   密码