中易网

SQL语句修改表时显示找不到表或约束条件怎么回事?

答案:2  悬赏:0  
解决时间 2021-04-28 18:44
  • 提问者网友:✐ۖ﹏ℳ๓北风
  • 2021-04-27 17:44
原来的语句:create table 通信录( 编号 smallint primary key , 姓名 char(15) not null,地址 char(30), 生日 date, 电话 char(14), Email char(20));
我要改的语句:alter table 通讯录 add QQ号 char(15);
最佳答案
  • 二级知识专家网友:摧毁过往
  • 2021-04-27 19:22
这句有问题:alter table 通讯录 add QQ号 char(15);

改一下:
alter table 通讯录 add column QQ号 char(15);
前提是表“通讯录”已经创建
全部回答
  • 1楼网友:你把微笑给了谁
  • 2021-04-27 20:03
如果需要修改sql主键约束,该sql语句应该怎么写呢?下面就将教您sql主键约束的修改语句写法,如果您遇到过类似的问题,不妨一看。 --修改sql主键约束用sql --获取sql主键约束名字 declare @csname varchar(100) set @csname='' select @csname=name from sysobjects where xtype='pk' and parent_obj=object_id('表名') --删除约束 exec('alter table 表名 drop constraint ' + @csname) --禁用约束(不校验) exec('alter table 表名 nocheck constraint ' + @csname) --启用约束(校验) exec('alter table 表名 check constraint ' + @csname) --添加约束 alter table 表名 add constraint 主键约束名 primary key (列名) 例: if not exists ( select * from syscolumns where id = object_id('accpf_reffacctid') and name = 'id') alter table accpf_reffacctid add id int identity(1,1) constraint pk_accpf_reffacctid primary key (id)
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息!
大家都在看
推荐信息