关于SQL主键GUID和Identity的看法(2)

2019-02-21 01:41

91

92 ///

93 /// 数据记录行数测试 94 ///

95 private void Id_Count() 96 {

97 string ReadSql = \d\;

98 using (SqlConnection conn = new SqlConnection(Connnection)) 99 {

100 SqlCommand com = new SqlCommand(ReadSql, conn);

101 conn.Open();

102 object CountResult = com.ExecuteScalar(); 103 conn.Close();

104 Console.WriteLine(\数据记录数为:{0}\,CountResult);

105 } 106 } 107

108 ///

109 /// 根据id查询; 110 ///

111 private void Id_SelectById() 112 {

113 string ReadSql = \e Id=\+300000;

114 using (SqlConnection conn = new SqlConnection(Connnection)) 115 {

116 SqlCommand com = new SqlCommand(ReadSql, conn);

117 conn.Open();

118 object IdResult = com.ExecuteScalar(); 119 Console.WriteLine(\为{0}\, IdResult); 120 conn.Close(); 121 } 122 } 123

124 ///

125 /// Guid测试; 126 ///

127 private void Guid_InsertTest(int count) 128 {

129 string InsertSql = \alue]) values ({0})\;

130 using (SqlConnection conn = new SqlConnection(Connnection)) 131 {

132 conn.Open();

133 SqlCommand com = new SqlCommand(); 134 for (int i = 0; i < count; i++) 135 {

136 com.Connection = conn;

137 com.CommandText = string.Format(InsertSql, i);

138 com.ExecuteNonQuery(); 139 } 140 } 141 } 142

143 ///

144 /// Guid格式将数据库读到Table 145 ///

146 private void Guid_ReadToTable(int count) 147 {

148 string ReadSql = \+count.ToString()

+\;

149 using (SqlConnection conn = new SqlConnection(Connnection)) 150 {

151 SqlCommand com = new SqlCommand(ReadSql, conn);

152 SqlDataAdapter adapter = new SqlDataAdapter(com);

153 DataSet ds = new DataSet(); 154 adapter.Fill(ds);

155 Console.WriteLine(\数据记录为:{0}\, ds.Tables[0].Rows.Count); 156 } 157 } 158

159 ///

160 /// 数据记录行数测试 161 ///

162 private void Guid_Count() 163 {

164 string ReadSql = %uid\;

165 using (SqlConnection conn = new SqlConnection(Connnection)) 166 {

167 SqlCommand com = new SqlCommand(ReadSql, conn);

168 conn.Open();

169 object CountResult = com.ExecuteScalar(); 170 conn.Close();

171 Console.WriteLine(\数据记录为:{0}\, CountResult);

172 } 173 }

174

175 ///

176 /// 根据Guid查询; 177 ///

178 private void Guid_SelectById() 179 {

180 string ReadSql = \re Guid='C1763624-036D-4DB9-A1E4-7E16318C30DE'\;

181 using (SqlConnection conn = new SqlConnection(Connnection)) 182 {

183 SqlCommand com = new SqlCommand(ReadSql, conn);

184 conn.Open();

185 object IdResult = com.ExecuteScalar(); 186 Console.WriteLine(\为{0}\, IdResult); 187 conn.Close(); 188 } 189 } 190 } 191 192} 193

3.数据库的插入测试 测试1

数据库量为:100条 运行结果

测试2

数据库量为:10000条 运行结果

测试3

数据库量为:100000条 运行结果


关于SQL主键GUID和Identity的看法(2).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:外研小学英语五年级上册Module 10Unit单元测试卷试卷(一)

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: