您的位置:首页 > 数据库

2008年10月小记(SQL删除重复记录,生成表结构,字符串特性,statistics io)

2008-10-07 10:23 369 查看
1、删除某字段中的重复记录,Table1006表中有Id和Phone字段,Id为不重复的标字段,但是Phone含有重复字段,现在需要重复Phone记录行删除掉,只保留最新一条记录。

static void Main(string[] args)

{

string strA = "abcdef";

string strB = "abcdef";

Console.WriteLine(ReferenceEquals(strA, strB));//字符串的恒定性

string strC = "abc";

string strD = strC + "def";

Console.WriteLine(ReferenceEquals(strA, strD));//对于动态生成的字符串,字符串驻留机制失效

strD = String.Intern(strD);

Console.WriteLine(ReferenceEquals(strA, strD));//使用Intern静态方法,能强制把字符串添加到哈希表中,并返回引用,便可以使字符串驻留。

string strE = "abc" + "def";

Console.WriteLine(ReferenceEquals(strA, strE));//使用+号,编译器会自动将其连接为一个文本常量加载,因此会添加到内部哈希表中。

//不同的线程、进程、AppDomain中字符串驻留都有效

System.Threading.Thread thread = new System.Threading.Thread(delegate(object str)

{

string strF = "abc" + "def";

Console.WriteLine(ReferenceEquals(str, strF));

});

thread.Start(strA);

thread.Join();

string strG = strC + "def";

System.Threading.Thread thread2 = new System.Threading.Thread(delegate(object str)

{

string strF = "abc" + "def";

Console.WriteLine(ReferenceEquals(str, strF));

});

thread2.Start(strG);

thread2.Join();

Console.ReadLine();

//result:

//True

//False

//True

//True

//True

//False

}


4、statistics io

set statistics io on

set statistics io off
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: