﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>C++博客-Welcome to ErranLi's Blog!-随笔分类-Data-base</title><link>http://www.cppblog.com/erran/category/5358.html</link><description /><language>zh-cn</language><lastBuildDate>Thu, 22 May 2008 06:22:54 GMT</lastBuildDate><pubDate>Thu, 22 May 2008 06:22:54 GMT</pubDate><ttl>60</ttl><item><title>转：DBA的选择：几种流行的数据库系统 </title><link>http://www.cppblog.com/erran/archive/2007/10/13/34124.html</link><dc:creator>erran</dc:creator><author>erran</author><pubDate>Sat, 13 Oct 2007 09:34:00 GMT</pubDate><guid>http://www.cppblog.com/erran/archive/2007/10/13/34124.html</guid><wfw:comment>http://www.cppblog.com/erran/comments/34124.html</wfw:comment><comments>http://www.cppblog.com/erran/archive/2007/10/13/34124.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/erran/comments/commentRss/34124.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/erran/services/trackbacks/34124.html</trackback:ping><description><![CDATA[
		<p style="font-size: 10pt; font-family: Arial;">原文：<a href="http://www.cnblogs.com/jplee/archive/2006/10/29/543382.html">http://www.cnblogs.com/jplee/archive/2006/10/29/543382.html</a><br />作者：<a href="http://jplee.cnblogs.com/">不再年轻.NET</a><br /><br /><strong>DBA的选择：几种流行的数据库系统</strong><br /><br /><br />最"容易"的数据库系统-Microsoft SQL Server<br /><br />　　如果你打算做一个DBA，建议你选择那些现在比较流行的数据库系统。这意味着你将有更多的就业机会、交流和培训机会，而且，流行自有流行的理由，你可以因此省心很多。当然，就业竞争压力也比较大。一般的入门者选择Microsoft SQL Server，这是非常适合中小型企业的数据库系统，熟悉Access的读者很容易就能初步使用Microsoft SQL Server，成为一个DBBS。 J<br />Microsoft SQL Server 7.0的报价，5用户版1399美金，增加用户时，127美金每用户。<br /><br />最"难"的数据库-无冕之王Oracle<br /><br />　　如果你有机会接触到Oracle，那可是个好机会。Oracle是目前最看好的数据库厂商，由于其强大的功能和可配置、可管理能力，Oracle DBA的薪资一般比其他数据库管理员的薪资要高。而且，Oracle在大中型企业的关键应用也更加普遍了。Oracle可以运行在Windows NT、Sun Solaris、Linux等平台下。很多情况下要求你不仅仅熟悉NT，还要你熟悉Unix；而且Oracle不太友善的界面和成箱的Oracle产品资料可能也是一个障碍。<br />Oracle 8i标准版的报价，如果运行在Windows NT，附带JServer和interMedia，支持5个并发用户，报价是3925美金每CPU。增加并发用户时，785美金每用户。增加附加的命名用户时，392.5美金每用户。<br /><br />数据库系统的贵族-IBM UDB/DB2<br /><br />　　作为30年数据库研究的成果，IBM DB2确实称得上"数据库系统的贵族"。不管是小型商业系统，还是大的银行系统，用DB2都是可以高枕无忧的。最近推出的新版DB2 6.1， 管理和调节工具更加卓越和便于使用。DB2 可以运行在Intel架构上，也可以运行在IBM的S/390大型计算机上。如果你所在的行业对IBM的机器特别地称道，建议你学习IBM DB2。<br /><br />DB2有两种版本：工作组版和企业版。工作组版999美元每服务器，外加249美元每个并发用户。而企业版是12500美元每个CPU，不限并发用户数量。 </p>
		<p style="font-size: 10pt; font-family: Arial;">以Java为中心的数据库-Sybase Adaptive Server Enterprise(ASE) 12.0<br /><br />　　即将发布的Sybase ASE 12.0，直接面向Java 程序员。这种以Java为中心的数据库系统，为那些准备在Java 平台下构建企业应用的企业来说，将是最好的选择。但是ASE称不上一个数据库领域的领先者，尽管相对于它以前的版本已经改进很多，并支持多个CPU和更多的并发，还有很多的新的特性。但Sybase的风光似乎已经不再。<br /><br />值得期盼的Informix Centaur<br /><br />　　有时候"第一"只是意味着你的对手需要等待更长的时间去赶上你。这正是1997年创立的Informix所面临的。Informix公司是率先将多媒体特性加入到关系数据库系统的大型数据库厂商之一。但是如今，IBM、Oracle、Sybase都已经跨越了这个概念。所以，Informix不得不寻求新的支撑来使自己区别于其他数据库厂商。这就是Informix Centaur的目标。Informix Centaur结合了Informix Dynamic Server 7.3的对象-关系数据库和Informix Universal Data Option 9.1，意在获得更好的适应性和多媒体支持。详情如何，我们拭目以待！<br /><br />DBA的薪资<br /><br />有很多因素影响到你作为DBA的薪资：</p>
		<ol>
				<ol>
						<li>你的经验和能力所决定的DBA等级
        </li>
						<li>你所熟悉的数据库系统
        </li>
						<li>你的个性特点和潜力 </li>
				</ol>
		</ol>
		<p style="font-size: 10pt; font-family: Arial;">
				<br />　　下面的表说明了国内DBA人员的基本薪资状况，并说明了DAB等级和你所熟悉的数据库系统怎样影响到DBA的薪资。当然，这只是我个人掌握的情况，只能在一定程度上代表行业的平均水平。<br /></p>
		<table bgcolor="#003366" border="0" cellpadding="0" cellspacing="1" width="100%">
				<tbody>
						<tr align="center">
								<td style="font-size: 10pt; font-family: Arial;">
										<p style="font-size: 10pt; font-family: Arial;">DBA等级数据库系统</p>
								</td>
								<td style="font-size: 10pt; font-family: Arial;">
										<p style="font-size: 10pt; font-family: Arial;">初级DBA年薪(万元)</p>
								</td>
								<td style="font-size: 10pt; font-family: Arial;">
										<p style="font-size: 10pt; font-family: Arial;">中级DBA年薪(万元)</p>
								</td>
								<td style="font-size: 10pt; font-family: Arial;">
										<p style="font-size: 10pt; font-family: Arial;">高级DBA年薪(万元)</p>
								</td>
						</tr>
						<tr bgcolor="#ffffff">
								<td style="font-size: 10pt; font-family: Arial;">
										<p style="font-size: 10pt; font-family: Arial;">Oracle</p>
								</td>
								<td style="font-size: 10pt; font-family: Arial;">
										<p style="font-size: 10pt; font-family: Arial;">4 </p>
								</td>
								<td style="font-size: 10pt; font-family: Arial;">
										<p style="font-size: 10pt; font-family: Arial;">8</p>
								</td>
								<td style="font-size: 10pt; font-family: Arial;">
										<p style="font-size: 10pt; font-family: Arial;">11</p>
								</td>
						</tr>
						<tr bgcolor="#ffffff">
								<td style="font-size: 10pt; font-family: Arial;">
										<p style="font-size: 10pt; font-family: Arial;">Microsoft SQL Server</p>
								</td>
								<td style="font-size: 10pt; font-family: Arial;">
										<p style="font-size: 10pt; font-family: Arial;">3</p>
								</td>
								<td style="font-size: 10pt; font-family: Arial;">
										<p style="font-size: 10pt; font-family: Arial;">5</p>
								</td>
								<td style="font-size: 10pt; font-family: Arial;">
										<p style="font-size: 10pt; font-family: Arial;">8</p>
								</td>
						</tr>
						<tr bgcolor="#ffffff">
								<td style="font-size: 10pt; font-family: Arial;">
										<p style="font-size: 10pt; font-family: Arial;">IBM DB2</p>
								</td>
								<td style="font-size: 10pt; font-family: Arial;">
										<p style="font-size: 10pt; font-family: Arial;">4</p>
								</td>
								<td style="font-size: 10pt; font-family: Arial;">
										<p style="font-size: 10pt; font-family: Arial;">8</p>
								</td>
								<td style="font-size: 10pt; font-family: Arial;">
										<p style="font-size: 10pt; font-family: Arial;">10</p>
								</td>
						</tr>
						<tr bgcolor="#ffffff">
								<td style="font-size: 10pt; font-family: Arial;">
										<p style="font-size: 10pt; font-family: Arial;">Sybase</p>
								</td>
								<td style="font-size: 10pt; font-family: Arial;">
										<p style="font-size: 10pt; font-family: Arial;">3.5</p>
								</td>
								<td style="font-size: 10pt; font-family: Arial;">
										<p style="font-size: 10pt; font-family: Arial;">6</p>
								</td>
								<td style="font-size: 10pt; font-family: Arial;">
										<p style="font-size: 10pt; font-family: Arial;">8</p>
								</td>
						</tr>
						<tr bgcolor="#ffffff">
								<td style="font-size: 10pt; font-family: Arial;">
										<p style="font-size: 10pt; font-family: Arial;">Informix</p>
								</td>
								<td style="font-size: 10pt; font-family: Arial;">
										<p style="font-size: 10pt; font-family: Arial;">4</p>
								</td>
								<td style="font-size: 10pt; font-family: Arial;">
										<p style="font-size: 10pt; font-family: Arial;">7</p>
								</td>
								<td style="font-size: 10pt; font-family: Arial;">
										<p style="font-size: 10pt; font-family: Arial;">10</p>
								</td>
						</tr>
				</tbody>
		</table>
		<p style="font-size: 10pt; font-family: Arial;">注：每年按13个月计算。表内数字为平均年薪。 </p>
<img src ="http://www.cppblog.com/erran/aggbug/34124.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/erran/" target="_blank">erran</a> 2007-10-13 17:34 <a href="http://www.cppblog.com/erran/archive/2007/10/13/34124.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>转：关于SQLServer的若干注意事项 </title><link>http://www.cppblog.com/erran/archive/2007/10/13/34122.html</link><dc:creator>erran</dc:creator><author>erran</author><pubDate>Sat, 13 Oct 2007 09:27:00 GMT</pubDate><guid>http://www.cppblog.com/erran/archive/2007/10/13/34122.html</guid><wfw:comment>http://www.cppblog.com/erran/comments/34122.html</wfw:comment><comments>http://www.cppblog.com/erran/archive/2007/10/13/34122.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/erran/comments/commentRss/34122.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/erran/services/trackbacks/34122.html</trackback:ping><description><![CDATA[
		<p style="font-size: 10pt; color: rgb(51, 51, 51);">原文：<a href="http://www.cnblogs.com/jplee/archive/2006/12/05/583174.html"><span style="color: rgb(51, 51, 51);">http://www.cnblogs.com/jplee/archive/2006/12/05/583174.html</span></a><br /><span style="color: rgb(51, 51, 51);">作者：<a href="http://jplee.cnblogs.com/"><font color="#000080">不再年轻.NET</font></a></span><br /><br /><a id="AjaxHolder_ctl01_TitleUrl" href="http://www.cnblogs.com/jplee/archive/2006/12/05/583174.html"><span style="color: rgb(51, 51, 51);"><strong>关于SQLServer的若干注意事项</strong></span></a></p>
		<br />
		<p style="font-size: 10pt; color: rgb(51, 51, 51);">如果你正在负责一个基于SQL Server的项目，或者你刚刚接触SQL Server，你都有可能要面临一些数据库性能的问题，这篇文章会为你提供一些有用的指导（其中大多数也可以用于其它的DBMS）。
</p>
		<p style="font-size: 10pt; color: rgb(51, 51, 51);">        在这里，我不打算介绍使用SQL Server的窍门，也不能提供一个包治百病的方案，我所做的是总结一些经验----关于如何形成一个好的设计。这些经验来自我过去几年中经受的教训，一直来，我看到许多同样的设计错误被一次又一次的重复。</p>
		<p style="font-size: 10pt; color: rgb(51, 51, 51);">
				<strong>
						<font size="4">你了解你的工具吗？</font>
				</strong>
		</p>
		<p style="font-size: 10pt; color: rgb(51, 51, 51);">        不要轻视这一点，这是我在这篇文章中讲述的最关键的一条。也许你也看到有很多的SQL Server程序员没有掌握全部的T-SQL命令和SQL Server提供的那些有用的工具。</p>
		<p style="font-size: 10pt; color: rgb(51, 51, 51);">        “什么？我要浪费一个<font size="2">月</font>的时间来学习那些我永远也不会用到的SQL命令？？？”，你也许会这样说。对的，你不需要这样做。但是你应该用一个周末浏览所有的T-SQL命令。在这里，你的任务是了解，将来，当你设计一个查询时，你会记起来：“对了，这里有一个命令可以完全实现我需要的功能”，于是，到MSDN查看这个命令的确切语法。</p>
		<p style="font-size: 10pt; color: rgb(51, 51, 51);">
				<strong>
						<font size="4">不要使用游标</font>
				</strong>
		</p>
		<p style="font-size: 10pt; color: rgb(51, 51, 51);">       让我再重复一遍：不要使用游标。如果你想破坏整个系统的性能的话，它们倒是你最有效的首选办法。大多数的初学者都使用游标，而没有意识到它们对性能造成的影响。它们占用内存，还用它们那些不可思议的方式锁定表，另外，它们简直就像蜗牛。而最糟糕的是，它们可以使你的DBA所能做的一切性能优化等于没做。不知你是否知道每执行一次FETCH就等于执行一次SELECT命令？这意味着如果你的游标有10000条记录，它将执行10000次SELECT！如果你使用一组SELECT、UPDATE或者DELETE来完成相应的工作，那将有效率的多。</p>
		<p style="font-size: 10pt; color: rgb(51, 51, 51);">       初学者一般认为使用游标是一种比较熟悉和舒适的编程方式，可很不幸，这会导致糟糕的性能。显然，SQL的总体目的是你要实现什么，而不是怎样实现。</p>
		<p style="font-size: 10pt; color: rgb(51, 51, 51);">       我曾经用T-SQL重写了一个基于游标的存储过程，那个表只有100,000条记录，原来的存储过程用了40分钟才执行完毕，而新的存储过程只用了10秒钟。在这里，我想你应该可以看到一个不称职的程序员究竟在干了什么！！！</p>
		<p style="font-size: 10pt; color: rgb(51, 51, 51);">       我们可以写一个小程序来取得和处理数据并且更新数据库，这样做有时会更有效。记住：对于循环，T-SQL无能为力。</p>
		<p style="font-size: 10pt; color: rgb(51, 51, 51);">        我再重新提醒一下：使用游标没有好处。除了DBA的工作外，我从来没有看到过使用游标可以有效的完成任何工作。</p>
		<p style="font-size: 10pt; color: rgb(51, 51, 51);">
				<strong>
						<font size="4">规范化你的数据表</font>
				</strong>
		</p>
		<p style="font-size: 10pt; color: rgb(51, 51, 51);">       为什么不规范化数据库？大概有两个借口：出于性能的考虑和纯粹因为懒惰。至于第二点，你迟早得为此付出代价。而关于性能的问题，你不需要优化根本就不慢的东西。我经常看到一些程序员“反规范化”数据库，他们的理由是“原来的设计太慢了”，可结果却常常是他们让系统更慢了。DBMS被设计用来处理规范数据库的，因此，记住：按照规范化的要求设计数据库。</p>
		<p style="font-size: 10pt; color: rgb(51, 51, 51);">
				<strong>
						<font size="4">不要使用SELECT *</font>
				</strong>
		</p>
		<p style="font-size: 10pt; color: rgb(51, 51, 51);">        这点不太容易做到，我太了解了，因为我自己就经常这样干。可是，如果在SELECT中指定你所需要的列，那将会带来以下的好处：</p>
		<p style="font-size: 10pt; color: rgb(51, 51, 51);">1 减少内存耗费和网络的带宽</p>
		<p style="font-size: 10pt; color: rgb(51, 51, 51);">2 你可以得到更安全的设计</p>
		<p style="font-size: 10pt; color: rgb(51, 51, 51);">3 给查询优化器机会从索引读取所有需要的列</p>
		<p style="font-size: 10pt; color: rgb(51, 51, 51);">
				<strong>
						<font size="4">了解你将要对数据进行的操作</font>
				</strong>
		</p>
		<p style="font-size: 10pt; color: rgb(51, 51, 51);">       为你的数据库创建一个健壮的索引，那可是功德一件。可要做到这一点简直就是一门艺术。每当你为一个表添加一个索引，SELECT会更快了，可INSERT和DELETE却大大的变慢了，因为创建了维护索引需要许多额外的工作。显然，这里问题的关键是：你要对这张表进行什么样的操作。这个问题不太好把握，特别是涉及DELETE和UPDATE时，因为这些语句经常在WHERE部分包含SELECT命令。</p>
		<p style="font-size: 10pt; color: rgb(51, 51, 51);">
				<strong>
						<font size="4">不要给“性别”列创建索引</font>
				</strong>
		</p>
		<p style="font-size: 10pt; color: rgb(51, 51, 51);">       首先，我们必须了解索引是如何加速对表的访问的。你可以将索引理解为基于一定的标准上对表进行划分的一种方式。如果你给类似于“性别”这样的列创建了一个索引，你仅仅是将表划分为两部分：男和女。你在处理一个有1,000,000条记录的表，这样的划分有什么意义？记住：维护索引是比较费时的。当你设计索引时，请遵循这样的规则：根据列可能包含不同内容的数目从多到少排列，比如：姓名+省份+性别。</p>
		<p style="font-size: 10pt; color: rgb(51, 51, 51);">
				<strong>
						<font size="4">使用事务</font>
				</strong>
		</p>
		<p style="font-size: 10pt; color: rgb(51, 51, 51);">       请使用事务，特别是当查询比较耗时。如果系统出现问题，这样做会救你一命的。一般有些经验的程序员都有体会-----你经常会碰到一些不可预料的情况会导致存储过程崩溃。</p>
		<p style="font-size: 10pt; color: rgb(51, 51, 51);">
				<strong>
						<font size="4">小心死锁</font>
				</strong>
		</p>
		<p style="font-size: 10pt; color: rgb(51, 51, 51);">       按照一定的次序来访问你的表。如果你先锁住表A，再锁住表B，那么在所有的存储过程中都要按照这个顺序来锁定它们。如果你（不经意的）某个存储过程中先锁定表B，再锁定表A，这可能就会导致一个死锁。如果锁定顺序没有被预先详细的设计好，死锁是不太容易被发现的。</p>
		<p style="font-size: 10pt; color: rgb(51, 51, 51);">
				<strong>
						<font size="4">不要打开大的数据集</font>
				</strong>
		</p>
		<p style="font-size: 10pt; color: rgb(51, 51, 51);">       在CSDN技术论坛中 :），一个经常被提出的问题是：我怎样才能迅速的将100000条记录添加到ComboBox中？这是不对的，你不能也不需要这样做。很简单，你的用户要浏览100000条记录才能找到需要的记录，他一定会诅咒你的。在这里，你需要的是一个更好的UI，你需要为你的用户显示不超过100或200条记录。</p>
		<p style="font-size: 10pt; color: rgb(51, 51, 51);">
				<strong>
						<font size="4">不要使用服务器端游标</font>
				</strong>
		</p>
		<p style="font-size: 10pt; color: rgb(51, 51, 51);">       与服务器端游标比起来，客户端游标可以减少服务器和网络的系统开销，并且还减少锁定时间。</p>
		<p style="font-size: 10pt; color: rgb(51, 51, 51);">
				<strong>
						<font size="4">使用参数查询</font>
				</strong>
		</p>
		<p style="font-size: 10pt; color: rgb(51, 51, 51);">       有时，我在CSDN技术论坛看到类似这样的问题：“SELECT * FROM  a WHERE a.id='A'B，因为单引号查询发生异常，我该怎么办？”，而普遍的回答是：用两个单引号代替单引号。这是错误的。这样治标不治本，因为你还会在其他一些字符上遇到这样的问题，更何况这样会导致严重的bug，除此以外，这样做还会使SQL Server的缓冲系统无法发挥应有的作用。使用参数查询， 釜底抽薪，这些问题统统不存在了。</p>
		<p style="font-size: 10pt; color: rgb(51, 51, 51);">
				<strong>
						<font size="4">在程序编码时使用大数据量的数据库</font>
				</strong>
		</p>
		<p style="font-size: 10pt; color: rgb(51, 51, 51);">       程序员在开发中使用的测试数据库一般数据量都不大，可经常的是最终用户的数据量都很大。我们通常的做法是不对的，原因很简单：现在硬盘不是很贵，可为什么性能问题却要等到已经无可挽回的时候才被注意呢？</p>
		<p style="font-size: 10pt; color: rgb(51, 51, 51);">
				<strong>
						<font size="4">不要使用INSERT导入大批的数据</font>
				</strong>
		</p>
		<p style="font-size: 10pt; color: rgb(51, 51, 51);">       请不要这样做，除非那是必须的。使用UTS或者BCP，这样你可以一举而兼得灵活性和速度。</p>
		<p style="font-size: 10pt; color: rgb(51, 51, 51);">
				<strong>
						<font size="4">注意超时问题</font>
				</strong>
		</p>
		<p style="font-size: 10pt; color: rgb(51, 51, 51);">       查询数据库时，一般数据库的缺省都比较小，比如15秒或者30秒。而有些查询运行时间要比这长，特别是当数据库的数据量不断变大时。</p>
		<p style="font-size: 10pt; color: rgb(51, 51, 51);">
				<strong>
						<font size="4">不要忽略同时修改同一记录的问题</font>
				</strong>
		</p>
		<p style="font-size: 10pt; color: rgb(51, 51, 51);">       有时候，两个用户会同时修改同一记录，这样，后一个修改者修改了前一个修改者的操作，某些更新就会丢失。处理这种情况不是很难：创建一个timestamp字段，在写入前检查它，如果允许，就合并修改，如果存在冲突，提示用户。</p>
		<p style="font-size: 10pt; color: rgb(51, 51, 51);">
				<strong>
						<font size="4">在细节表中插入纪录时，不要在主表执行SELECT MAX(ID)</font>
				</strong>
		</p>
		<p style="font-size: 10pt; color: rgb(51, 51, 51);">       这是一个普遍的错误，当两个用户在同一时间插入数据时，这会导致错误。你可以使用<font face="宋体">SCOPE_IDENTITY，<code>IDENT_CURRENT</code>和<code>@@IDENTITY。如果可能，不要使用<font face="宋体">@@IDENTITY，因为在有触发器的情况下，它会引起一些问题（详见这里的<a href="http://expert.csdn.net/Expert/topic/1147/1147612.xml?temp=.3728754"><font color="#000080">讨论</font></a>）。</font></code></font></p>
		<p style="font-size: 10pt; color: rgb(51, 51, 51);">
				<code>
						<font face="宋体" size="4">
								<strong>避免将列设为NULLable</strong>
						</font>
				</code>
		</p>
		<p style="font-size: 10pt; color: rgb(51, 51, 51);">
				<code>
						<font face="宋体">    如果可能的话，你应该避免将列设为NULLable。系统会为NULLable列的每一行分配一个额外的字节，查询时会带来更多的系统开销。另外，将列设为NULLable使编码变得复杂，因为每一次访问这些列时都必须先进行检查。</font>
				</code>
		</p>
		<p style="font-size: 10pt; color: rgb(51, 51, 51);">
				<code>
						<font face="宋体">    我并不是说NULLS是麻烦的根源，尽管有些人这样认为。我认为如果你的业务规则中允许“空数据”，那么，将列设为NULLable有时会发挥很好的作用，但是，如果在类似下面的情况中使用NULLable，那简直就是自讨苦吃。</font>
				</code>
		</p>
		<p style="font-size: 10pt; color: rgb(51, 51, 51);">
				<code>CustomerName1<br />CustomerAddress1<br />CustomerEmail1<br />CustomerName2<br />CustomerAddress2<br />CustomerEmail3<br />CustomerName1<br />CustomerAddress2<br />CustomerEmail3</code>
		</p>
		<p style="font-size: 10pt; color: rgb(51, 51, 51);">
				<code>   如果出现这种情况，你需要规范化你的表了。</code>
		</p>
		<p style="font-size: 10pt; color: rgb(51, 51, 51);">
				<code>
						<strong>
								<font size="4">尽量不要使用TEXT数据类型</font>
						</strong>
				</code>
		</p>
		<p style="font-size: 10pt; color: rgb(51, 51, 51);">
				<code>   除非你使用TEXT处理一个很大的数据，否则不要使用它。因为它不易于查询，速度慢，用的不好还会浪费大量的空间。一般的，VARCHAR可以<font face="新宋体">更好的</font>处理你的数据。</code>
		</p>
		<p style="font-size: 10pt; color: rgb(51, 51, 51);">
				<code>
						<strong>
								<font size="4">尽量不要使用临时表</font>
						</strong>
				</code>
		</p>
		<p style="font-size: 10pt; color: rgb(51, 51, 51);">
				<code>   尽量不要使用临时表，除非你必须这样做。一般使用子查询可以代替临时表。使用临时表会带来系统开销，如果你是用COM+进行编程，它还会给你带来很大的麻烦，因为COM+使用数据库连接池而临时表却自始至终都存在。SQL Server提供了一些替代方案，比如Table数据类型。</code>
		</p>
		<p style="font-size: 10pt; color: rgb(51, 51, 51);">
				<code>
						<strong>
								<font size="4">学会分析查询</font>
						</strong>
				</code>
		</p>
		<p style="font-size: 10pt; color: rgb(51, 51, 51);">
				<code>SQL Server查询分析器是你的好伙伴，通过它你可以了解查询和索引是如何影响性能的。</code>
		</p>
		<p style="font-size: 10pt; color: rgb(51, 51, 51);">
				<code>
						<strong>
								<font size="4">使用参照完整性</font>
						</strong>
				</code>
		</p>
		<p style="font-size: 10pt; color: rgb(51, 51, 51);">
				<code>定义主健、唯一性约束和外键，这样做可以节约大量的时间。</code>
		</p>
<img src ="http://www.cppblog.com/erran/aggbug/34122.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/erran/" target="_blank">erran</a> 2007-10-13 17:27 <a href="http://www.cppblog.com/erran/archive/2007/10/13/34122.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>