SQLServer 2008 R2 删除字段前检查字段的约束: select a.name,b.name as cname from syscolumns a left join sysobjects b on a.cdefault=b.id where a.id=object_id('TableName') and a.name='FieldName'
在PowerDesinger中,若表名过长,自动生成的主键名会被自动截取. 解决如下:DataBase/Edit Current DBMS/Scripts/Objects/PKey/ConstName中找到Value的值,默认是 PK_%.U27:TABLE%,U27表示截取27个字符.改成PK_%TABLE%主键名就不会被截取了. 同理,对生成的约束名常常因为截断字符串而导致重名错误,可以放开. DataBase/Edit Current DBMS/Scripts/Objects/Refere
//////////////////查询指定表外键约束select a.name as 约束名, object_name(b.parent_object_id) as 外键表, d.name as 外键列, object_name(b.referenced_object_id) as 主健表, c.name as 主键列 from sys.foreign_keys A inner join sys.foreign_key_columns B on A.object_id=b.constraint
select a.name as 约束名, object_name(b.parent_object_id) as 外键表, d.name as 外键列, object_name(b.referenced_object_id) as 主健表, c.name as 主键列 from sys.foreign_keys A inner join sys.foreign_key_columns B on A.object_id=b.constraint_object_id inner join sys.c
修改数据库表某一列或添加列,转载的哦~ --增加一列 ALTER TABLE 表名 ADD 列名 VARCHAR(20) NULL --删除一列 ALTER TABLE 表名 drop COLUMN 列名 --修改一列 alter TABLE 表名 ALTER COLUMN 列名 VARCHAR(40) NULL --修改一列的类型 alter TABLE 表名 ALTER COLUMN 列名 VARCHAR(40)- -添加主键约束 alter table 表名add constraint 约