CnPack Forum


 
Subject: MicroTip#6 对于组合主键的修改
koalaone
新警察
Rank: 1



UID 4832
Digest Posts 0
Credits 17
Posts 4
点点分 17
Reading Access 10
Registered 2007-1-21
Status Offline
Post at 2007-5-10 20:20  Profile | Blog | P.M. 
MicroTip#6 对于组合主键的修改

MicroTip#6 对于组合主键的修改

Wrtten by koalaone   2007.05.10
QQ Discuss Group: 130970

一般设计表的时候,一个表有一个主键。如果遇到有多个组合主键的时候这么处理呢?

如下步骤:
1.。  在查询分析器中输入:sp_help [表名],会出现有关[表名]的相关信息。找到列constraint_type,值为primary key,列constraint_name,值为a(我们要找的)。

alter table [表名] drop constraint  a(上面找到的)
go

--如果要修改的列为主键,该列不能允许为空
--ALTER TABLE [表名]  ALTER COLUMN [列名] int NOT NULL
--go


ALTER TABLE [dbo].[表名] WITH NOCHECK ADD
        CONSTRAINT [a] PRIMARY KEY  CLUSTERED    --a是上面找到的
        (
                 --设置主键
        )  ON [PRIMARY]
GO

[ 本帖最后由 skyjacker 于 2007-5-11 08:14 编辑 ]
Top
skyjacker
版主
Rank: 7Rank: 7Rank: 7
茶农


UID 2239
Digest Posts 9
Credits 617
Posts 269
点点分 617
Reading Access 100
Registered 2006-6-8
Status Offline
Post at 2007-5-10 21:41  Profile | Blog | P.M.  | QQ




一壶清茶煮青春.
Top
Passion (LiuXiao)
管理员
Rank: 9Rank: 9Rank: 9


UID 359
Digest Posts 19
Credits 6838
Posts 3591
点点分 6838
Reading Access 102
Registered 2004-3-28
Status Offline
Post at 2007-5-10 23:41  Profile | Blog | P.M. 
有点意思,算个Tips
Top
skyjacker
版主
Rank: 7Rank: 7Rank: 7
茶农


UID 2239
Digest Posts 9
Credits 617
Posts 269
点点分 617
Reading Access 100
Registered 2006-6-8
Status Offline
Post at 2007-5-11 08:15  Profile | Blog | P.M.  | QQ
分了个 tip号  MicroTip#6




一壶清茶煮青春.
Top
kendling (小冬)
高级版主
Rank: 8Rank: 8
MyvNet


Medal No.1  
UID 703
Digest Posts 5
Credits 978
Posts 580
点点分 978
Reading Access 101
Registered 2005-2-18
Location 广东
Status Offline
Post at 2007-5-11 10:26  Profile | Site | Blog | P.M.  | QQ | Yahoo!
不错,支持一下。




小冬
http://MyvNet.com
Top
zzzl (早安的空气)
版主
Rank: 7Rank: 7Rank: 7



UID 590
Digest Posts 0
Credits 399
Posts 199
点点分 399
Reading Access 100
Registered 2004-11-29
Status Offline
Post at 2007-5-12 21:43  Profile | Blog | P.M.  | QQ
Top
Passion (LiuXiao)
管理员
Rank: 9Rank: 9Rank: 9


UID 359
Digest Posts 19
Credits 6838
Posts 3591
点点分 6838
Reading Access 102
Registered 2004-3-28
Status Offline
Post at 2007-5-13 00:02  Profile | Blog | P.M. 
空气你的shell的bpl找到了没?
Top
 




All times are GMT++8, the time now is 2024-11-22 07:16

    本论坛支付平台由支付宝提供
携手打造安全诚信的交易社区 Powered by Discuz! 5.0.0  © 2001-2006 Comsenz Inc.
Processed in 0.014061 second(s), 8 queries , Gzip enabled

Clear Cookies - Contact Us - CnPack Website - Archiver - WAP