sqlserver2005自动创建数据表和自动添加某个字段索引
天地龙魂漫画,李乐基,幽默小笑话大全
创建数据表的sql语句如下:
string tatlename = "t_useruid";//定义一个变量。用于自动创建数据表的名称,当前表名为:t_useruid
string sql = "create table [dbo].[" + tatlename + "]([cid] [int] identity(1,1) not null,[uid] [nchar](32) collate chinese_prc_ci_as null,constraint [pk_" + tatlename + "] primary key clustered ([cid] asc)with (ignore_dup_key = off) on [primary]) on [primary]";
给这个数据表:t_useruid 的uid字段增加一个索引
string sql = "create unique index pk_t_useruid_u on t_useruid (uid)";
分析sql:create unique index 索引名称 on 数据表名称 (字段名称)
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!!
点击进行留言回复
相关文章:
-
-
详解SQL游标的用法
类型: 1.普通游标 只有next操作 2.滚动游标 有多种操作1.普通游标declare @username varchar(20),@userid varc...
[阅读全文]
-
-
-
-
-
-
-
-
-
网友评论