﻿<?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>BlogJava-cuiyi's blog（崔毅 crazycy）-随笔分类-DBMS</title><link>http://www.blogjava.net/crazycy/category/8596.html</link><description>记录点滴 鉴往事之得失 以资于发展 </description><language>zh-cn</language><lastBuildDate>Thu, 06 Mar 2014 16:02:08 GMT</lastBuildDate><pubDate>Thu, 06 Mar 2014 16:02:08 GMT</pubDate><ttl>60</ttl><item><title>Database-001 MySQL存储引擎MyISAM与InnoDB的主要区别对比 (转）</title><link>http://www.blogjava.net/crazycy/archive/2014/03/06/410673.html</link><dc:creator>crazycy</dc:creator><author>crazycy</author><pubDate>Thu, 06 Mar 2014 03:09:00 GMT</pubDate><guid>http://www.blogjava.net/crazycy/archive/2014/03/06/410673.html</guid><wfw:comment>http://www.blogjava.net/crazycy/comments/410673.html</wfw:comment><comments>http://www.blogjava.net/crazycy/archive/2014/03/06/410673.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/crazycy/comments/commentRss/410673.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/crazycy/services/trackbacks/410673.html</trackback:ping><description><![CDATA[<p style="padding: 0px; margin: 1.2em 0px; line-height: 1.5em; color: #002200; font-family: georgia; font-size: 15px;">本文整理了<a title="Mysql" href="http://www.ha97.com/category/database/mysql-database" style="padding: 0px; margin: 0px; color: #006600; text-decoration: none; border-bottom-width: 1px; border-bottom-style: dashed; border-bottom-color: #006600;">Mysql</a>&nbsp;两大常用的存储引擎<a title="MyISAM" href="http://www.ha97.com/tag/myisam" style="padding: 0px; margin: 0px; color: #006600; text-decoration: none; border-bottom-width: 1px; border-bottom-style: dashed; border-bottom-color: #006600;">MyISAM</a>，<a title="InnoDB" href="http://www.ha97.com/tag/innodb" style="padding: 0px; margin: 0px; color: #006600; text-decoration: none; border-bottom-width: 1px; border-bottom-style: dashed; border-bottom-color: #006600;">InnoDB</a>的六大常见区别，来源于<a title="Mysql" href="http://www.ha97.com/tag/mysql" style="padding: 0px; margin: 0px; color: #006600; text-decoration: none; border-bottom-width: 1px; border-bottom-style: dashed; border-bottom-color: #006600;">Mysql</a>手册以及互联网的资料。</p><table border="1" cellspacing="0" cellpadding="0" style="padding: 0px; margin: 0px; color: #002200; font-family: georgia; font-size: 15px;"><tbody style="padding: 0px; margin: 0px;"><tr style="padding: 0px; margin: 0px;"><td colspan="3" width="568" valign="top" style="padding: 0px; margin: 0px;"><strong style="padding: 0px; margin: 0px;">InnoDB</strong><strong style="padding: 0px; margin: 0px;">与</strong><strong style="padding: 0px; margin: 0px;">Myisam</strong><strong style="padding: 0px; margin: 0px;">的六大区别</strong></td></tr><tr style="padding: 0px; margin: 0px;"><td width="121" valign="top" style="padding: 0px; margin: 0px;"></td><td width="273" valign="top" style="padding: 0px; margin: 0px;"><strong style="padding: 0px; margin: 0px;">MyISAM</strong></td><td width="175" valign="top" style="padding: 0px; margin: 0px;"><strong style="padding: 0px; margin: 0px;">InnoDB</strong></td></tr><tr style="padding: 0px; margin: 0px;"><td width="121" valign="top" style="padding: 0px; margin: 0px;"><strong style="padding: 0px; margin: 0px;">构 成上的区别：</strong></td><td width="273" valign="top" style="padding: 0px; margin: 0px;">每个MyISAM在磁盘上存储成三个文件。第一个 文件的名字以表的名字开始，扩展名指出文件类型。<p style="padding: 0px; margin: 1.2em 0px; line-height: 1.5em;"></p><p style="padding: 0px; margin: 1.2em 0px; line-height: 1.5em;">.frm文件存储表定义。<br /><span style="line-height: 1.5em;">数据文件的扩 展名为.MYD (MYData)。</span><span style="line-height: 1.5em;">索引文件的扩 展名是.MYI (MYIndex)。</span></p></td><td width="175" valign="top" style="padding: 0px; margin: 0px;">基于磁盘的资源是InnoDB表空间数据文件和它的日志文件，InnoDB&nbsp;表的 大小只受限于操作系统文件的大小，一般为&nbsp;2GB</td></tr><tr style="padding: 0px; margin: 0px;"><td width="121" valign="top" style="padding: 0px; margin: 0px;"><strong style="padding: 0px; margin: 0px;">事务处理上方面</strong><strong style="padding: 0px; margin: 0px;">:</strong></td><td width="273" valign="top" style="padding: 0px; margin: 0px;">MyISAM类型的表强调的是性能，其执行数 度比InnoDB类型更快，但是不提供事务支持</td><td width="175" valign="top" style="padding: 0px; margin: 0px;">InnoDB提供事务支持事务(commit, rollback, crash recovery capability)，外部键等高级 数据库功能<br /><br /></td></tr><tr style="padding: 0px; margin: 0px;"><td width="121" valign="top" style="padding: 0px; margin: 0px;"><strong style="padding: 0px; margin: 0px;">SELECT<a title="UPDATE" href="http://www.ha97.com/tag/update" style="padding: 0px; margin: 0px; color: #006600; text-decoration: none; border-bottom-width: 1px; border-bottom-style: dashed; border-bottom-color: #006600;">UPDATE</a>,INSERT</strong><strong style="padding: 0px; margin: 0px;">，</strong><strong style="padding: 0px; margin: 0px;">Delete</strong><strong style="padding: 0px; margin: 0px;">操 作</strong><strong style="padding: 0px; margin: 0px;"></strong></td><td width="273" valign="top" style="padding: 0px; margin: 0px;">如果执行大量的SELECT，MyISAM是更好的选择</td><td width="175" valign="top" style="padding: 0px; margin: 0px;"><strong style="padding: 0px; margin: 0px;">1.</strong>如果你的数据执行大量的<strong style="padding: 0px; margin: 0px;">INSERT</strong><strong style="padding: 0px; margin: 0px;">或</strong><strong style="padding: 0px; margin: 0px;">UPDATE</strong>，出于性能方面的考虑，应该使用InnoDB表<p style="padding: 0px; margin: 1.2em 0px; line-height: 1.5em;"></p><p style="padding: 0px; margin: 1.2em 0px; line-height: 1.5em;"><strong style="padding: 0px; margin: 0px;">2.DELETE FROM table</strong>时，InnoDB不会重新建立表，而是一行一行的 删除。</p><p style="padding: 0px; margin: 1.2em 0px; line-height: 1.5em;"><strong style="padding: 0px; margin: 0px;">3.LOAD TABLE FROM MASTER</strong>操作对InnoDB是不起作用的，解决方法是首先把InnoDB表改成MyISAM表，导入数据后再改成InnoDB表，但是对于使用的额外的InnoDB特性（例如外键）的表不适用</p></td></tr><tr style="padding: 0px; margin: 0px;"><td width="121" valign="top" style="padding: 0px; margin: 0px;"><strong style="padding: 0px; margin: 0px;">对</strong><strong style="padding: 0px; margin: 0px;">AUTO_INCREMENT</strong><strong style="padding: 0px; margin: 0px;">的 操作</strong><p style="padding: 0px; margin: 1.2em 0px; line-height: 1.5em;"></p><p style="padding: 0px; margin: 1.2em 0px; line-height: 1.5em;"><strong style="padding: 0px; margin: 0px;"></strong></p></td><td width="273" valign="top" style="padding: 0px; margin: 0px;">每表一个AUTO_INCREMEN列的内部处理。<p style="padding: 0px; margin: 1.2em 0px; line-height: 1.5em;"></p><p style="padding: 0px; margin: 1.2em 0px; line-height: 1.5em;"><strong style="padding: 0px; margin: 0px;">MyISAM</strong><strong style="padding: 0px; margin: 0px;">为</strong><strong style="padding: 0px; margin: 0px;">INSERT</strong><strong style="padding: 0px; margin: 0px;">和</strong><strong style="padding: 0px; margin: 0px;">UPDATE</strong><strong style="padding: 0px; margin: 0px;">操 作自动更新这一列</strong>。这使得AUTO_INCREMENT列更快（至少10%）。在序列顶的值被删除之后就不 能再利用。(当AUTO_INCREMENT列被定义为多列索引的最后一列， 可以出现重使用从序列顶部删除的值的情况）。</p><p style="padding: 0px; margin: 1.2em 0px; line-height: 1.5em;">AUTO_INCREMENT值可用ALTER TABLE或myisamch来重置</p><p style="padding: 0px; margin: 1.2em 0px; line-height: 1.5em;">对于AUTO_INCREMENT类型的字段，InnoDB中必须包含只有该字段的索引，但 是在MyISAM表中，可以和其他字段一起建立联 合索引</p><p style="padding: 0px; margin: 1.2em 0px; line-height: 1.5em;">更好和更快的auto_increment处理</p></td><td width="175" valign="top" style="padding: 0px; margin: 0px;">如果你为一个表指定AUTO_INCREMENT列，在数据词典里的InnoDB表句柄包含一个名为自动增长计数 器的计数器，它被用在为该列赋新值。<p style="padding: 0px; margin: 1.2em 0px; line-height: 1.5em;"></p><p style="padding: 0px; margin: 1.2em 0px; line-height: 1.5em;">自动增长计数 器仅被存储在主内存中，而不是存在磁盘上</p><p style="padding: 0px; margin: 1.2em 0px; line-height: 1.5em;">关于该计算器 的算法实现，请参考</p><p style="padding: 0px; margin: 1.2em 0px; line-height: 1.5em;"><strong style="padding: 0px; margin: 0px;">AUTO_INCREMENT</strong><strong style="padding: 0px; margin: 0px;">列 在</strong><strong style="padding: 0px; margin: 0px;">InnoDB</strong><strong style="padding: 0px; margin: 0px;">里 如何工作</strong></p></td></tr><tr style="padding: 0px; margin: 0px;"><td width="121" valign="top" style="padding: 0px; margin: 0px;"><strong style="padding: 0px; margin: 0px;">表的具体行数</strong><strong style="padding: 0px; margin: 0px;"></strong></td><td width="273" valign="top" style="padding: 0px; margin: 0px;">select count(*) from table,MyISAM只要简单的读出保存好的行数，注意的是，当count(*)语句包含&nbsp;where条件时，两种表的操作是一样的</td><td width="175" valign="top" style="padding: 0px; margin: 0px;">InnoDB&nbsp;中不 保存表的具体行数，也就是说，执行select count(*) from table时，InnoDB要扫描一遍整个表来计算有多少行<br /><br /><strong><span style="color: red;">improved in V</span><span style="color: red;">5.6</span><br /></strong><br /></td></tr><tr style="padding: 0px; margin: 0px;"><td width="121" valign="top" style="padding: 0px; margin: 0px;"><strong style="padding: 0px; margin: 0px;">锁</strong><strong style="padding: 0px; margin: 0px;"></strong></td><td width="273" valign="top" style="padding: 0px; margin: 0px;">表锁</td><td width="175" valign="top" style="padding: 0px; margin: 0px;">提供行锁(locking on row level)，提供与 Oracle&nbsp;类型一致的不加锁读取(non-locking read in<br style="padding: 0px; margin: 0px;" />SELECTs);<br /><br />另外，InnoDB表的行锁也不是绝对的，如果在执 行一个SQL语句时MySQL不能确定要扫描的范围，InnoDB表同样会锁全表，例如update table set num=1 where&nbsp;<a title="name" href="http://www.ha97.com/tag/name" style="padding: 0px; margin: 0px; color: #006600; text-decoration: none; border-bottom-width: 1px; border-bottom-style: dashed; border-bottom-color: #006600;">name</a>&nbsp;like &#8220;%aaa%&#8221;</td></tr><tr style="padding: 0px; margin: 0px;"><td colspan="3" width="568" valign="top" style="padding: 0px; margin: 0px;">本文原出处为&nbsp;www.dbahacker<a title=".com" href="http://www.ha97.com/tag/com" style="padding: 0px; margin: 0px; color: #006600; text-decoration: none; border-bottom-width: 1px; border-bottom-style: dashed; border-bottom-color: #006600;">.com</a>转载烦请保留 链接</td></tr></tbody></table><img src ="http://www.blogjava.net/crazycy/aggbug/410673.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/crazycy/" target="_blank">crazycy</a> 2014-03-06 11:09 <a href="http://www.blogjava.net/crazycy/archive/2014/03/06/410673.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>index study - 001</title><link>http://www.blogjava.net/crazycy/archive/2014/01/22/409191.html</link><dc:creator>crazycy</dc:creator><author>crazycy</author><pubDate>Tue, 21 Jan 2014 19:02:00 GMT</pubDate><guid>http://www.blogjava.net/crazycy/archive/2014/01/22/409191.html</guid><wfw:comment>http://www.blogjava.net/crazycy/comments/409191.html</wfw:comment><comments>http://www.blogjava.net/crazycy/archive/2014/01/22/409191.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/crazycy/comments/commentRss/409191.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/crazycy/services/trackbacks/409191.html</trackback:ping><description><![CDATA[<h1><div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />-->Source:http://programmerinterview.com/index.php/java-questions/java-introduction</div>How do database indexes work? And, how do indexes help? Provide a tutorial on database indexes.</h1><p style="margin-bottom: 18px; color: #444444; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; text-align: justify; background-color: #ffffff;">Let&#8217;s start out our tutorial and explanation of why you would need a database index by going through a very simple example. Suppose that we have a database table called Employee with three columns &#8211; Employee_Name, Employee_Age, and Employee_Address. Assume that the Employee table has thousands of rows.</p><p style="margin-bottom: 18px; color: #444444; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; text-align: justify; background-color: #ffffff;">Now, let&#8217;s say that we want to run a query to find all the details of any employees who are named &#8216;Jesus&#8217;? So, we decide to run a simple query like this:</p><pre style="font-size: 13px; font-family: 'courier new'; background-color: #ffffff; outline: #d4d4d4 solid 1px; border: 6px solid #eaeaea; padding: 15px; line-height: 18px; position: relative; overflow: auto; width: 510px; color: #444444;">SELECT * FROM Employee  WHERE Employee_Name = 'Jesus'  </pre><h2>What would happen without an index on the table?</h2><p style="margin-bottom: 18px; color: #444444; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; text-align: justify; background-color: #ffffff;"></p><table align="left" border="0" cellspacing="0" cellpadding="10" style="color: #444444; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; text-align: justify; background-color: #ffffff;"><tbody><tr><td><div id="adsensetextimage"><iframe width="300" height="250" frameborder="0" marginwidth="0" marginheight="0" vspace="0" hspace="0" allowtransparency="true" scrolling="no" id="aswift_1" name="aswift_1" style="left: 0px; position: absolute; top: 0px;"></iframe></div></td></tr></tbody></table><p style="margin-bottom: 18px; color: #444444; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; text-align: justify; background-color: #ffffff;"></p><p style="margin-bottom: 18px; color: #444444; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; text-align: justify; background-color: #ffffff;">Once we run that query, what exactly goes on behind the scenes to find employees who are named Jesus? Well, the database software would literally have to look at every single row in the Employee table to see if the Employee_Name for that row is &#8216;Jesus&#8217;. And, because we want every row with the name &#8216;Jesus&#8217; inside it, we can not just stop looking once we find just one row with the name &#8216;Jesus&#8217;, because there could be other rows with the name Jesus. So, every row up until the last row must be searched &#8211; which means thousands of rows in this scenario will have to be examined by the database to find the rows with the name &#8216;Jesus&#8217;. This is what is called a&nbsp;<a href="http://www.programmerinterview.com/index.php/database-sql/sql-full-table-scan/">full table scan</a>.</p><h2>How a database index can help performance</h2><p style="margin-bottom: 18px; color: #444444; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; text-align: justify; background-color: #ffffff;">You might be thinking that doing a full table scan sounds inefficient for something so simple &#8211; shouldn&#8217;t software be smarter? It&#8217;s almost like looking through the entire table with the human eye &#8211; very slow and not at all sleek. But, as you probably guessed by the title of this article, this is where indexes can help a great deal.&nbsp;<strong>The whole point of having an index is to speed up search queries by essentially cutting down the number of records/rows in a table that need to be examined.</strong></p><h2>What is an index?</h2><p style="margin-bottom: 18px; color: #444444; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; text-align: justify; background-color: #ffffff;">So, what is an index? Well, an index is a data structure (most commonly a B- tree) that stores the values for a specific column in a table. An index is created on a column of a<em>table</em>. So, the key points to remember are that an index consists of column values from one table, and that those values are stored in a data structure. The index is a data structure &#8211; remember that.</p><h2>What kind of data structure is an index?</h2><p style="margin-bottom: 18px; color: #444444; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; text-align: justify; background-color: #ffffff;">B- trees are the most commonly used data structures for indexes. The reason B- trees are the most popular data structure for indexes is due to the fact that they are time efficient &#8211; because look-ups, deletions, and insertions can all be done in logarithmic time. And, another major reason B- trees are more commonly used is because the data that is stored inside the B- tree can be&nbsp;<strong>sorted</strong>. The RDBMS typically determines which data structure is actually used for an index. But, in some scenarios with certain RDBMS&#8217;s, you can actually specify which data structure you want your database to use when you create the index itself.</p><h2>How does a hash table index work?</h2><p style="margin-bottom: 18px; color: #444444; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; text-align: justify; background-color: #ffffff;">Hash tables are another data structure that you may see being used as indexes &#8211; these indexes are commonly referred to as hash indexes. The reason hash indexes are used is because hash tables are extremely efficient when it comes to just looking up values. So, queries that compare for equality to a string can retrieve values very fast if they use a hash index. For instance, the query we discussed earlier (SELECT * FROM Employee WHERE Employee_Name = &#8216;Jesus&#8217;) could benefit from a hash index created on the Employee_Name column. The way a hash index would work is that the column value will be the key into the hash table and the actual value mapped to that key would just be a pointer to the row data in the table. Since a hash table is basically an associative array, a typical entry would look something like &#8220;Jesus =&gt; 0&#215;28939&#8243;, where 0&#215;28939 is a reference to the table row where Jesus is stored in memory. Looking up a value like &#8220;Jesus&#8221; in a hash table index and getting back a reference to the row in memory is obviously a lot faster than scanning the table to find all the rows with a value of &#8220;Jesus&#8221; in the Employee_Name column.</p><p style="margin-bottom: 18px; color: #444444; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; text-align: justify; background-color: #ffffff;"></p><div style="color: #444444; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; background-color: #ffffff;"><iframe width="336" height="280" frameborder="0" marginwidth="0" marginheight="0" vspace="0" hspace="0" allowtransparency="true" scrolling="no" id="aswift_2" name="aswift_2" style="left: 0px; position: absolute; top: 0px;"></iframe></div><p style="margin-bottom: 18px; color: #444444; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; text-align: justify; background-color: #ffffff;"></p><h2>The disadvantages of a hash index</h2><p style="margin-bottom: 18px; color: #444444; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; text-align: justify; background-color: #ffffff;">Hash tables are&nbsp;<strong>not</strong>&nbsp;<em>sorted</em>&nbsp;data structures, and there are many types of queries which hash indexes can not even help with. For instance, suppose you want to find out all of the employees who are less than 40 years old. How could you do that with a hash table index? Well, it&#8217;s not possible because a hash table is only good for looking up key value pairs &#8211; which means queries that check for equality (like &#8220;WHERE name = &#8216;Jesus&#8217;&#8221;). What is implied in the key value mapping in a hash table is the concept that the keys of a hash table are not sorted or stored in any particular&nbsp;<strong><em>order</em></strong>. This is why hash indexes are usually not the default type of data structure used by database indexes &#8211; because they aren&#8217;t as flexible as B- trees when used as the index data structure. Also see:&nbsp;<a href="http://www.programmerinterview.com/index.php/data-structures/hash-tables-versus-binary-search-trees/">Binary trees versus Hash Tables</a>.</p><h2>What are some other types of indexes?</h2><p style="margin-bottom: 18px; color: #444444; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; text-align: justify; background-color: #ffffff;">Indexes that use a R- tree data structure are commonly used to help with spatial problems. For instance, a query like &#8220;Find all of the Starbucks within 2 kilometers of me&#8221; would be the type of query that could show enhanced performance if the database table uses a R- tree index.</p><p style="margin-bottom: 18px; color: #444444; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; text-align: justify; background-color: #ffffff;">Another type of index is a bitmap index, which work well on columns that contain Boolean values (like true and false), but many instances of those values &#8211; basically columns with low&nbsp;<a href="http://www.programmerinterview.com/index.php/database-sql/selectivity-in-sql-databases/">selectivity</a>.</p><h2>How does an index improve performance?</h2><p style="margin-bottom: 18px; color: #444444; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; text-align: justify; background-color: #ffffff;"></p><table align="left" border="0" cellspacing="0" cellpadding="10" style="color: #444444; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; text-align: justify; background-color: #ffffff;"><tbody><tr><td><div id="adsense1"><iframe width="300" height="250" frameborder="0" marginwidth="0" marginheight="0" vspace="0" hspace="0" allowtransparency="true" scrolling="no" id="aswift_3" name="aswift_3" style="left: 0px; position: absolute; top: 0px;"></iframe></div></td></tr></tbody></table><p style="margin-bottom: 18px; color: #444444; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; text-align: justify; background-color: #ffffff;"></p><p style="margin-bottom: 18px; color: #444444; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; text-align: justify; background-color: #ffffff;">Because an index is basically a data structure that is used to store column values, looking up those values becomes much faster. And, if an index is using the most commonly used data structure type &#8211; a B- tree &#8211; then the data structure is also<strong><em>sorted</em></strong>. Having the column values be sorted can be a major performance enhancement &#8211; read on to find out why.</p><p style="margin-bottom: 18px; color: #444444; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; text-align: justify; background-color: #ffffff;">Let&#8217;s say that we create a B- tree index on the Employee_Name column This means that when we search for employees named &#8220;Jesus&#8221; using the SQL we showed earlier, then the entire Employee table does not have to be searched to find employees named &#8220;Jesus&#8221;. Instead, the database will use the index to find employees named Jesus, because the index will presumably be sorted alphabetically by the Employee&#8217;s name. And, because it is sorted, it means searching for a name is a lot faster because all names starting with a &#8220;J&#8221; will be right next to each other in the index! It&#8217;s also important to note that the index also stores pointers to the table row so that other column values can be retrieved &#8211; read on for more details on that.</p><h2>What exactly is inside a database index?</h2><p style="margin-bottom: 18px; color: #444444; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; text-align: justify; background-color: #ffffff;">So, now you know that a database index is created on a column in a table, and that the index stores the values in that specific column. But, it is important to understand that a database index does not store the values in the other columns of the same table. For example, if we create an index on the Employee_Name column, this means that the Employee_Age and Employee_Address column values are&nbsp;<strong>not</strong>&nbsp;also stored in the index. If we did just store all the other columns in the index, then it would be just like creating another copy of the entire table &#8211; which would take up way too much space and would be very inefficient.</p><h2>An index also stores a pointer to the table row</h2><p style="margin-bottom: 18px; color: #444444; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; text-align: justify; background-color: #ffffff;">So, the question is if the value that we are looking for is found in an index (like &#8216;Jesus&#8217;) , how does it find the other values that are in the same row (like the address of Jesus and his age)? Well, it&#8217;s quite simple &#8211; database indexes also store&nbsp;<strong>pointers</strong>&nbsp;to the corresponding rows in the table. A pointer is just a reference to a place in memory where the row data is stored on disk. So, in addition to the column value that is stored in the index, a pointer to the row in the table where that value lives is also stored in the index. This means that one of the values (or nodes) in the index for an Employee_Name could be something like (&#8220;Jesus&#8221;, 0&#215;82829), where 0&#215;82829 is the address on disk (the pointer) where the row data for &#8220;Jesus&#8221; is stored. Without that pointer all you would have is a single value, which would be meaningless because you would not be able to retrieve the other values in the same row &#8211; like the address and the age of an employee.</p><h2>How does a database know when to use an index?</h2><p style="margin-bottom: 18px; color: #444444; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; text-align: justify; background-color: #ffffff;">When a query like &#8220;SELECT * FROM Employee WHERE Employee_Name = &#8216;Jesus&#8217; &#8221; is run, the database will check to see if there is an index on the column(s) being queried. Assuming the Employee_Name column does have an index created on it, the database will have to decide whether it actually makes sense to use the index to find the values being searched &#8211; because there are some scenarios where it is actually less efficient to use the database index, and more efficient just to scan the entire table. Read this article to understand more about those scenarios:&nbsp;<a href="http://www.programmerinterview.com/index.php/database-sql/selectivity-in-sql-databases/">Selectivity in SQL</a>.</p><h2>Can you force the database to use an index on a query?</h2><p style="margin-bottom: 18px; color: #444444; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; text-align: justify; background-color: #ffffff;">Generally, you will not tell the database when to actually use an index &#8211; that decision will be made by the database itself. Although it is worth noting that in most databases (like Oracle and MySQL), you can actually specify that you want the index to be used.</p><h2>How to create an index in SQL:</h2><p style="margin-bottom: 18px; color: #444444; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; text-align: justify; background-color: #ffffff;">Here&#8217;s what the actual SQL would look like to create an index on the Employee_Name column from our example earlier:<span style="font-family: verdana, 'courier new'; font-size: 14px; line-height: 21px;">CREATE INDEX name_index ON Employee (Employee_Name)&nbsp;</span></p><h2>How to create a multi-column index in SQL:</h2><p style="margin-bottom: 18px; color: #444444; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; text-align: justify; background-color: #ffffff;">We could also create an index on two of the columns in the Employee table , as shown in this SQL:<span style="font-family: verdana, 'courier new'; font-size: 14px; line-height: 21px;">CREATE INDEX name_index ON Employee (Employee_Name, Employee_Age)</span></p><p style="margin-bottom: 18px; color: #444444; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; text-align: justify; background-color: #ffffff;"></p><h2>What is a good analogy for a database index?</h2><p style="margin-bottom: 18px; color: #444444; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; text-align: justify; background-color: #ffffff;">A very good analogy is to think of a database index as an index in a book. If you have a book about dogs and you are looking for the section on Golden Retrievers, then why would you flip through the entire book &#8211; which is the equivalent of a full table scan in database terminology &#8211; when you can just go to the index at the back of the book, which will tell you the exact pages where you can find information on Golden Retrievers. Similarly, as a book index contains a page number, a database index contains a pointer to the row containing the value that you are searching for in your SQL.</p><h2>What is the cost of having a database index?</h2><p style="margin-bottom: 18px; color: #444444; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; text-align: justify; background-color: #ffffff;">So, what are some of the disadvantages of having a database index? Well, for one thing it takes up space &#8211; and the larger your table, the larger your index. Another performance hit with indexes is the fact that whenever you add, delete, or update rows in the corresponding table, the same operations will have to be done to your index. <strong>Remember that an index needs to contain the same up to the minute data as whatever is in the table column(s) that the index covers</strong>.</p><p style="margin-bottom: 18px; color: #444444; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px; text-align: justify; background-color: #ffffff;">As a general rule, <strong>an index should only be created on a table if the data in the indexed column will be queried frequently.</strong></p><img src ="http://www.blogjava.net/crazycy/aggbug/409191.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/crazycy/" target="_blank">crazycy</a> 2014-01-22 03:02 <a href="http://www.blogjava.net/crazycy/archive/2014/01/22/409191.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>NoSQL学习（九）﻿ 2014年八大最热门的大数据工作</title><link>http://www.blogjava.net/crazycy/archive/2014/01/19/409098.html</link><dc:creator>crazycy</dc:creator><author>crazycy</author><pubDate>Sat, 18 Jan 2014 18:20:00 GMT</pubDate><guid>http://www.blogjava.net/crazycy/archive/2014/01/19/409098.html</guid><wfw:comment>http://www.blogjava.net/crazycy/comments/409098.html</wfw:comment><comments>http://www.blogjava.net/crazycy/archive/2014/01/19/409098.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/crazycy/comments/commentRss/409098.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/crazycy/services/trackbacks/409098.html</trackback:ping><description><![CDATA[<div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />-->2014年八大最热门的大数据工作<br />作者：张霖&nbsp;1月&nbsp;16,&nbsp;2014<br />http://www.ctocio.com/ccnews/14565.html<br /><a href="http://www.ctocio.com/ccnews/14565.html" title="2014年八大最热门的大数据工作" style="font-size: 1em; outline: 0px; padding: 0px; margin: 0px; border: 0px; text-decoration: none; vertical-align: baseline; color: #004276;">原文链接</a>： 文章来自<a href="http://www.ctocio.com/" title="IT经理网" style="font-size: 1em; outline: 0px; padding: 0px; margin: 0px; border: 0px; text-decoration: none; vertical-align: baseline; color: #004276;">IT经理网</a></div><p style="font-family: 'Microsoft Yahei', Arial, 'Trebuchet MS', Verdana, Tahoma; outline: 0px; padding: 0px; margin: 0px 0px 10px; border: 0px; vertical-align: baseline; line-height: 1.8em; color: #555555; background-color: #ffffff;">大数据时代，数据过剩，人才短缺，越来越多的IT专业人士希望能够进入充满机遇的大数据领域，但是，到底哪些具体的大数据专业岗位和人才最为吃香呢？人力资源公司Kforce近日发布了一份报告根据<a href="http://www.kforce.com/salary-guide-request-form/2014/technology-infographic.aspx" style="font-size: 1em; outline: 0px; padding: 0px; margin: 0px; border: 0px; text-decoration: none; vertical-align: baseline; color: #004276;">IT职业薪酬水平</a>给出了2014年最热门的十大大数据工作职位（年薪）：</p><p style="font-family: 'Microsoft Yahei', Arial, 'Trebuchet MS', Verdana, Tahoma; outline: 0px; padding: 0px; margin: 0px 0px 10px; border: 0px; vertical-align: baseline; line-height: 1.8em; color: #555555; background-color: #ffffff;">一、ETL开发者（11-13万美元）<br /><span style="line-height: 1.8em;">随着数据种类的不断增加，企业对数据整合专业人才的需求越来越旺盛。ETL开发者与不同的数据来源和组织打交道，从不同的源头抽取数据，转换并导入数据仓库以满足企业的需要。</span></p><p style="font-family: 'Microsoft Yahei', Arial, 'Trebuchet MS', Verdana, Tahoma; outline: 0px; padding: 0px; margin: 0px 0px 10px; border: 0px; vertical-align: baseline; line-height: 1.8em; color: #555555; background-color: #ffffff;">ETL软件行业相对成熟，相关岗位的工作生命周期比较长，通常由内部员工和外包合同商之间通力完成。ETL人才在大数据时代炙手可热的原因之一是：在企业大数据应用的早期阶段，<a href="http://www.ctocio.com/ccnews/12345.html" style="font-size: 1em; outline: 0px; padding: 0px; margin: 0px; border: 0px; text-decoration: none; vertical-align: baseline; color: #004276;">Hadoop只是穷人的ETL</a>。<br /><br /><span style="line-height: 1.8em;">二、Hadoop开发者（15-17.5万美元）<br /></span><span style="line-height: 1.8em;">Hadoop是基于Java的开源框架，随着数据集规模不断增大，而传统BI的数据处理成本过高，企业对</span><strong style="line-height: 1.8em; color: red;">Hadoop及相关的廉价数据处理技术如Hive、HBase、MapReduce、Pig等的需求将持续增长</strong><span style="line-height: 1.8em;">。如今具备Hadoop框架经验的技术人员是最抢手的大数据人才。<br /><br /></span><span style="line-height: 1.8em;">三、大数据可视化工具开发者（15-17.5万美元）<br /></span><span style="line-height: 1.8em;">海量数据的分析是个大挑战，而</span><strong style="line-height: 1.8em; color: red;">新型数据可视化工具如Spotifre，Qlikview和Tableau可以直观高效地展示数据</strong><span style="line-height: 1.8em;">。过去，数据可视化属于商业智能开发者类别，但是随着Hadoop的崛起，数据可视化已经成了一项独立的专业技能和岗位。<br /><br /></span><span style="line-height: 1.8em;">四、数据科学家（12-14万美元）<br /></span><span style="line-height: 1.8em;">过去也称数据架构师，数据科学家是一个全新的工种，能够将企业的数据和技术转化为企业的商业价值。数据科学家首先应当具备优秀的沟通技能，能够同时将数据分析结果解释给IT部门和业务部门领导。</span></p><p style="font-family: 'Microsoft Yahei', Arial, 'Trebuchet MS', Verdana, Tahoma; outline: 0px; padding: 0px; margin: 0px 0px 10px; border: 0px; vertical-align: baseline; line-height: 1.8em; color: #555555; background-color: #ffffff;">总的来说，数据科学家是分析师、艺术家的合体，需要具备多种交叉科学和商业技能。<br /><br /><span style="line-height: 1.8em;">五、OLAP开发者（9.8-11.6万美元）<br /></span><span style="line-height: 1.8em;">OLAP在线联机分析开发者，<strong>负责将数据从关系型或非关系型数据源中抽取出来建立模型，然后创建数据访问的用户界面，提供高性能的预定义查询功能。</strong><br /><br /></span><span style="line-height: 1.8em;">六、数据仓库一体机专家（9.8-12.4万美元）<br /></span><span style="line-height: 1.8em;">此类专家</span><strong style="line-height: 1.8em;">熟悉Teradata、Neteeza和Exadata等公司的大数据一体机</strong><span style="line-height: 1.8em;">。能够在这些一体机上完成数据集成、管理和性能优化等工作。<br /><br /></span><span style="line-height: 1.8em;">七、预测分析开发者（10-13万美元）<br /></span><span style="line-height: 1.8em;">营销部门经常使用预测分析预测用户行为或锁定目标用户。预测分析开发者有些场景看上有有些类似数据科学家，即在企业历史数据的基础上通过假设来测试阈值并预测未来的表现。<br /><br /></span><span style="line-height: 1.8em;">八、信息架构师（11.4-13.5万美元）<br /></span><span style="line-height: 1.8em;">大数据重新激发了主数据管理的热潮。充分开发利用企业数据并支持决策需要非常专业的技能。信息架构师必须了解如何定义和存档关键元素，确保以最有效的方式进行数据管理和利用。信息架构师的关键技能包括主数据管理、业务知识和数据建模等。</span></p><img src ="http://www.blogjava.net/crazycy/aggbug/409098.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/crazycy/" target="_blank">crazycy</a> 2014-01-19 02:20 <a href="http://www.blogjava.net/crazycy/archive/2014/01/19/409098.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>NoSQL学习（八）﻿ 大数据要“落地”，还缺些什么？</title><link>http://www.blogjava.net/crazycy/archive/2014/01/19/409097.html</link><dc:creator>crazycy</dc:creator><author>crazycy</author><pubDate>Sat, 18 Jan 2014 17:59:00 GMT</pubDate><guid>http://www.blogjava.net/crazycy/archive/2014/01/19/409097.html</guid><wfw:comment>http://www.blogjava.net/crazycy/comments/409097.html</wfw:comment><comments>http://www.blogjava.net/crazycy/archive/2014/01/19/409097.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/crazycy/comments/commentRss/409097.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/crazycy/services/trackbacks/409097.html</trackback:ping><description><![CDATA[<div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />-->大数据要&#8220;落地&#8221;，还缺些什么<br />http://www.pingwest.com/bigdata2/</div><p style="margin:0in;margin-bottom:.0001pt;background:white;vertical-align: baseline"><span style="font-size:11.0pt;font-family:宋体;color:#3F484F">&#8220;</span><span style="font-size:11.0pt;font-family:宋体;color:#3F484F">大数据</span><span style="font-size:11.0pt; font-family:宋体;color:#3F484F">&#8221;</span><span style="font-size:11.0pt;font-family:宋体;color:#3F484F">是在</span><span style="font-size:11.0pt; font-family:宋体;color:#3F484F">2013</span><span style="font-size:11.0pt;font-family:宋体;color:#3F484F">年被用滥了的词汇，但实际上，</span><span style="font-size: 11pt; font-family: 宋体; color: #0000ff;">由于数据量缺失、大数据清洗和分析能力不足，以及数据可视化瓶颈等问题</span><span style="font-size:11.0pt;font-family:宋体;color:#3F484F">，</span><span style="font-size:11.0pt;font-family:宋体;color:#3F484F">&#8220;</span><span style="font-size:11.0pt;font-family:宋体;color:#3F484F">大数据</span><span style="font-size:11.0pt; font-family:宋体;color:#3F484F">&#8221;</span><span style="font-size:11.0pt;font-family:宋体;color:#3F484F">一直未能迟迟落地。伴随着基础设施的发展，意味着大数据的发展又走到新的一个新的临界点。系统软件供应商</span><span style="font-size:11.0pt;font-family:宋体;color:#3F484F">Software AG</span><span style="font-size:11.0pt;font-family:宋体;color:#3F484F">的</span><span style="font-size:11.0pt; font-family:宋体;color:#3F484F">Gagan Mehra</span><span style="font-size:11.0pt;font-family:宋体;color:#3F484F">，在</span><span style="font-size:11.0pt; font-family:宋体;color:#3F484F"><a href="http://venturebeat.com/2013/12/28/big-data-2-0-the-next-generation-of-big-data/" style="font-size:inherit;font-style:inherit;font-variant:inherit;font-weight: inherit;line-height:inherit;transition: 0.1s;-webkit-transition: 0.1s"><span style="color:#F36119;border:none windowtext 1.0pt; padding:0in;text-decoration:none;text-underline:none">Venturebeat</span></a></span><span style="font-size:11.0pt;font-family:宋体;color:#3F484F">网站阐述了他对于大数据接下来发展的认识，他认为更快地数据处理、更可靠的数据质量，以及更加细分的应用市场，是大数据</span><span style="font-size:11.0pt;font-family:宋体;color:#3F484F">2.0</span><span style="font-size:11.0pt;font-family:宋体;color:#3F484F">时代的重要特征。<br /><br /></span></p>  <p style="margin: 0in 0in 0.0001pt; background-color: white; vertical-align: baseline; background-position: initial initial; background-repeat: initial initial;"><strong style="font-size:inherit;font-style:inherit; font-variant:inherit;line-height:inherit"><span style="font-size: 11.0pt;font-family:宋体; color:#3F484F;border:none windowtext 1.0pt; padding:0in">更快的数据处理速度</span></strong></p>  <p style="margin: 0in 0in 0.0001pt; background-color: white; vertical-align: baseline; background-position: initial initial; background-repeat: initial initial;"><span style="font-size:11.0pt;font-family:宋体;color:#3F484F">由于数据量指数型增长，使得</span><span style="font-size: 11pt; font-family: 宋体; color: #0000ff;"><strong>对于数据的快速分析的需要</strong></span><span style="font-size:11.0pt;font-family:宋体;color:#3F484F">已经变得比以往任何时候都要迫切。几乎每家大数据厂商，都想要兜售比别家处理速度更快的产品。</span><span style="font-size: 11pt; font-family: 宋体; color: #0000ff;">Hadoop</span><span style="font-size: 11pt; font-family: 宋体; color: #0000ff;">发布的新品</span><span style="font-size: 11pt; font-family: 宋体; color: #0000ff;">Hadoop 2.0 / YARN</span><span style="font-size: 11pt; font-family: 宋体; color: #0000ff;">，几乎能实时分析数据。而下一代大数据的计算牵引框架</span><span style="font-size: 11pt; font-family: 宋体; color: #0000ff;">Apache Spark</span><span style="font-size: 11pt; font-family: 宋体; color: #0000ff;">，它的速度比</span><span style="font-size: 11pt; font-family: 宋体; color: #0000ff;">Hadoop</span><span style="font-size: 11pt; font-family: 宋体; color: #0000ff;">快</span><span style="font-size: 11pt; font-family: 宋体; color: #0000ff;">100</span><span style="font-size: 11pt; font-family: 宋体; color: #0000ff;">倍。</span><span style="font-size:11.0pt;font-family:宋体;color:#3F484F">硅谷风险投资机构</span><span style="font-size: 11.0pt;font-family:宋体; color:#3F484F">Andreessen Horowitz</span><span style="font-size: 11.0pt;font-family:宋体; color:#3F484F">，已经以</span><span style="font-size:11.0pt;font-family:宋体;color:#3F484F">1400</span><span style="font-size:11.0pt;font-family:宋体;color:#3F484F">万美元的价格，领投了一家以</span><span style="font-size:11.0pt;font-family:宋体;color:#3F484F">Apache Spark</span><span style="font-size:11.0pt;font-family:宋体;color:#3F484F">为业务核心的初创企业</span><span style="font-size: 11.0pt;font-family:宋体; color:#3F484F">Databricks</span><span style="font-size:11.0pt; font-family:宋体;color:#3F484F">。不久前，</span><span style="font-size: 11pt; font-family: 宋体; color: #0000ff;">亚马逊也</span><span style="font-size:11.0pt;font-family:宋体;color:#3F484F"><a href="http://www.pingwest.com/amazon-kinesis/" target="_blank" style="font-size:inherit;font-style:inherit;font-variant:inherit;font-weight: inherit;line-height:inherit;transition: 0.1s;-webkit-transition: 0.1s"><span style="color: #0000ff; border: 1pt none windowtext; padding: 0in; text-decoration: none;">上线了实时流数据服务</span><span style="color: #0000ff; border: 1pt none windowtext; padding: 0in; text-decoration: none;">Kinesis</span></a></span><span style="font-size: 11pt; font-family: 宋体; color: #0000ff;">，来帮助没有数据处理能力的公司解决这一问题。<br /><br /></span></p>  <p style="margin: 0in 0in 0.0001pt; background-color: white; vertical-align: baseline; background-position: initial initial; background-repeat: initial initial;"><span style="font-size: 11pt; font-family: 宋体; color: #0000ff;"><strong>许多分析供应商都已经认识到了数据处理速度的重要性</strong></span><span style="font-size:11.0pt;font-family:宋体;color:#3F484F">，并建立了能够每秒处理</span><span style="font-size:11.0pt;font-family:宋体;color:#3F484F">TB</span><span style="font-size:11.0pt;font-family:宋体;color:#3F484F">数据的产品。</span><span style="font-size: 12pt; font-family: 宋体; color: #ff0000;"><strong>传感器数据分析、物联网在工业和消费级市场快速发展的势头，驱动了这次变革。</strong></span><span style="font-size:11.0pt;font-family:宋体;color:#3F484F">比如</span><strong><span style="font-size: 11pt; font-family: 宋体; color: #800000;">一家企业的传感器，能够每秒产生出数百次的事件，实时处理这些数据难度很高。特别是当实时处理的传感器数据，激增到一天</span><span style="font-size: 11pt; font-family: 宋体; color: #800000;">5TB</span><span style="font-size: 11pt; font-family: 宋体; color: #800000;">的时候，速度，就成了尤为关键的指标。</span></strong></p>  <p style="margin: 0in 0in 0.0001pt; background-color: white; vertical-align: baseline; background-position: initial initial; background-repeat: initial initial;"><span style="font-size:11.0pt;font-family:宋体;color:#3F484F"><br />同时，尽管数据存储成本已经累年下降，但数据存储的费用还是不小的一笔支出。部分商家相比存储完整数据流而言，更倾向于保存过滤掉噪音的数据。<br /><br /></span></p>  <p style="margin: 0in 0in 0.0001pt; background-color: white; vertical-align: baseline; background-position: initial initial; background-repeat: initial initial;"><strong style="font-size:inherit;font-style:inherit; font-variant:inherit;line-height:inherit"><span style="font-size: 11.0pt;font-family:宋体; color:#3F484F;border:none windowtext 1.0pt; padding:0in">智能清洗</span></strong><strong><span style="font-size:11.0pt; font-family:宋体;color:#3F484F;border:none windowtext 1.0pt;padding:0in">&#8220;</span></strong><strong><span style="font-size:11.0pt;font-family:宋体;color:#3F484F;border:none windowtext 1.0pt;padding:0in">垃圾数据</span></strong><strong><span style="font-size:11.0pt;font-family:宋体; color:#3F484F;border:none windowtext 1.0pt; padding:0in">&#8221;</span></strong></p>  <p style="margin: 0in 0in 0.0001pt; background-color: white; vertical-align: baseline; background-position: initial initial; background-repeat: initial initial;"><span style="font-size: 11pt; font-family: 宋体; color: #0000ff;">在本就难以计数的数据量继续以指数模型激增时，对于数据质量的强化，便摆上了许多数据供应商的议程。</span><span style="font-size:11.0pt;font-family:宋体;color:#3F484F">换句话说，在庞大数据面前，即使计算机能够高效的处理它们，但大量无用的</span><span style="font-size:11.0pt;font-family:宋体;color:#3F484F">&#8220;</span><span style="font-size:11.0pt;font-family:宋体;color:#3F484F">垃圾</span><span style="font-size:11.0pt; font-family:宋体;color:#3F484F">&#8221;</span><span style="font-size:11.0pt;font-family:宋体;color:#3F484F">数据，只会给系统带来负担，并增添存储、主机等设备成本。</span><span style="font-size: 11pt; font-family: 宋体; color: #0000ff;">这就需要数据处理过程中，根据特定的规则和参数，对涌进数据流进行</span><span style="font-size: 11pt; font-family: 宋体; color: #0000ff;">&#8220;</span><span style="font-size: 11pt; font-family: 宋体; color: #0000ff;">清洗</span><span style="font-size: 11pt; font-family: 宋体; color: #0000ff;">&#8221;</span><span style="font-size: 11pt; font-family: 宋体; color: #0000ff;">和分析，并自动决策该去处理哪些数据，这一切不再需要人工去干预。</span><span style="font-size:11.0pt;font-family:宋体;color:#3F484F"><br /><br /></span></p>  <p style="margin: 0in 0in 0.0001pt; background-color: white; vertical-align: baseline; background-position: initial initial; background-repeat: initial initial;"><span style="font-size:11.0pt;font-family:宋体;color:#3F484F">在这样的环境下，如果选择了一个坏的数据，就会像病毒一样，可能引发连续的错误决策，甚至让企业蒙受经济损失。</span><span style="font-size: 11pt; font-family: 宋体; color: #0000ff;"><strong>一个例子就是利用算法去进行股票交易，以毫秒计数股票市场中，任何一点小的差错，都有可能引发无法巨大的损失。</strong></span><span style="font-size:11.0pt;font-family:宋体;color:#3F484F"><br /></span><span style="font-size: 11pt; font-family: 宋体; color: #3f484f;"><br />所以，数据质量已成为服务级别协议（</span><span style="font-size: 11pt; font-family: 宋体; color: #3f484f;">service level agreements</span><span style="font-size: 11pt; font-family: 宋体; color: #3f484f;">）最重要的参数之一。无法屏蔽劣质的数据的供应商，会因此被列入行业的黑名单，以及面临严重的经济处罚。</span><span style="font-size: 11pt; font-family: 宋体; color: #3f484f;">B2B</span><span style="font-size: 11pt; font-family: 宋体; color: #3f484f;">行业为早期数据质量的入局者，他们非常重视数据的质量，来保持商业运作时的稳定性。甚至，许多企业计划为数据质量部署实时的警告系统，这些警告会被发送于负责相应问题的专员，由他们提供问题的解决方案。<br /><br /></span></p>  <p style="margin: 0in 0in 0.0001pt; background-color: white; vertical-align: baseline; background-position: initial initial; background-repeat: initial initial;"><span style="font-size:11.0pt;font-family:宋体;color:#3F484F">机器学习是另一项需要保证数据质量的领域。机器学习系统部署在一个闭环的生态中，通过模式分析与其他的数据分析技术，细化原来的数据质量规则。而高质量的数据，能够保证机器进行正确的行为模式分析。</span></p>  <p style="margin: 0in 0in 0.0001pt; background-color: white; vertical-align: baseline; background-position: initial initial; background-repeat: initial initial;"><strong style="font-size:inherit;font-style:inherit; font-variant:inherit;line-height:inherit"><span style="font-size: 11.0pt;font-family:宋体; color:#3F484F;border:none windowtext 1.0pt; padding:0in"><br />越来越多的基础应用</span></strong></p>  <p style="margin: 0in 0in 0.0001pt; background-color: white; vertical-align: baseline; background-position: initial initial; background-repeat: initial initial;"><span style="font-size:11.0pt;font-family:宋体;color:#3F484F">大数据带来的变革，使得每一个人都想要利用它，但技术上门槛又让许多人不得已只能充当一个看客。而应用将有助于人们去克服这一困难。在接下来的几年中，我们将会看到成千上万的解决</span><span style="font-size: 11pt; font-family: 宋体; color: #0000ff;"><strong>某一垂直领域的专业应用</strong></span><span style="font-size:11.0pt;font-family:宋体;color:#3F484F">，以应对来自各行各业的大数据挑战。<br /><br /></span></p>  <p style="margin: 0in 0in 0.0001pt; background-color: white; vertical-align: baseline; background-position: initial initial; background-repeat: initial initial;"><span style="font-size:11.0pt;font-family:宋体;color:#3F484F">目前，已经小有成就的数据分析公司包括</span><span style="font-size:11.0pt;font-family:宋体;color:#3F484F">eHarmony</span><span style="font-size:11.0pt;font-family:宋体;color:#3F484F">、</span><span style="font-size:11.0pt; font-family:宋体;color:#3F484F"> Roambi</span><span style="font-size:11.0pt;font-family:宋体;color:#3F484F">、</span><span style="font-size:11.0pt;font-family:宋体;color:#3F484F"> Climate Corporation</span><span style="font-size:11.0pt;font-family:宋体;color:#3F484F">等等。未来，甚至许多小企业，既不用依赖特定基础设备，也不要雇佣专业的数据科学家，就能受益于对大数据分析利用。<br /><br /></span></p>  <p style="margin: 0in 0in 0.0001pt; background-color: white; vertical-align: baseline; background-position: initial initial; background-repeat: initial initial;"><span style="font-size:11.0pt;font-family:宋体;color:#3F484F">比如，一些应用将从各种渠道，收集关联的客户数据，以更好地了解客户的需求。从而企业能够为特定的目标客户，提供特定需求的产品，更有针对性地赚到钱。当这些应用走进人们日常的吃喝玩乐、医疗保健等领域，生活也会因此而更美好。</span></p>  <p style="margin-bottom:0in;margin-bottom:.0001pt;line-height: normal">&nbsp;</p><img src ="http://www.blogjava.net/crazycy/aggbug/409097.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/crazycy/" target="_blank">crazycy</a> 2014-01-19 01:59 <a href="http://www.blogjava.net/crazycy/archive/2014/01/19/409097.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>NoSQL学习（七）Hadoop是数据仓库的终结者吗?</title><link>http://www.blogjava.net/crazycy/archive/2014/01/19/409096.html</link><dc:creator>crazycy</dc:creator><author>crazycy</author><pubDate>Sat, 18 Jan 2014 17:27:00 GMT</pubDate><guid>http://www.blogjava.net/crazycy/archive/2014/01/19/409096.html</guid><wfw:comment>http://www.blogjava.net/crazycy/comments/409096.html</wfw:comment><comments>http://www.blogjava.net/crazycy/archive/2014/01/19/409096.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/crazycy/comments/commentRss/409096.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/crazycy/services/trackbacks/409096.html</trackback:ping><description><![CDATA[<div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />-->Hadoop是数据仓库的终结者吗?<br />2014年01月13日　|　作者：邹铮编译　|　来源：网界网<br />http://news.cnw.com.cn/news-international/htm2014/20140113_289451.shtml<p style="margin:0in;margin-bottom:.0001pt;text-indent:21.0pt;line-height:19.5pt; background:white"><strong><span style="font-size:10.5pt;font-family: 宋体;color:#313131">【</span></strong><strong><span style="font-size:10.5pt; font-family:宋体;color:#313131">CNW.com.cn独家译稿】</span></strong><span style="font-size:10.5pt;font-family:宋体;color:#313131">在过去三年，</span><span style="font-size:10.5pt;font-family:宋体;color:#313131">Hadoop生态系统已经大范围扩展，很多主要IT供应商都推出了Hadoop连接器，以增强Hadoop的顶层架构或是供应商自己使用的Hadoop发行版。鉴于Hadoop的部署率呈指数级的增长，以及其生态系统不断地深入而广泛地发展，我们很想知道Hadoop的崛起是否会导致传统数据仓库解决方案的终结呢。</span></p>  <p style="margin: 0in 0in 0.0001pt; text-indent: 21pt; line-height: 19.5pt; background-color: white; background-position: initial initial; background-repeat: initial initial;"><span style="font-size:10.5pt;font-family:宋体; color:#313131">我们也可以将这个问题放到一个更大的环境中去讨论：在何种程度上，大数据会改变传统数据分析的环境</span><span style="font-size:10.5pt;font-family:宋体;color:#313131">?</span></p>  <p style="margin: 0in 0in 0.0001pt; text-indent: 21pt; line-height: 19.5pt; background-color: white; background-position: initial initial; background-repeat: initial initial;"><span style="font-size:10.5pt;font-family:宋体; color:#313131">数据仓库是技术和软件套件，它能够从操作系统收集数据，并将这些数据整合，并统一到中央数据库中，然后对数据仪表盘上指标进行分析、可视化和追踪关键性能处理。</span></p>  <p style="margin: 0in 0in 11.25pt; text-indent: 21pt; line-height: 19.5pt; background-color: white; background-position: initial initial; background-repeat: initial initial;"><strong><span style="font-size:10.5pt; font-family:宋体;color:red">数据仓库和</span></strong><strong><span style="font-size:10.5pt;font-family:宋体;color:red">Hadoop之间的主要区别是：数据仓库通常部署在单个关系数据库中，而这个数据库则起到中央存储的作用。相比之下，Hadoop及其Hadoop文件系统是跨多个机器，并用来处理海量数据的，而这是任何单台机器都达不到的能力。</span></strong></p>  <p style="margin: 0in 0in 0.0001pt; text-indent: 21pt; line-height: 19.5pt; background-color: white; background-position: initial initial; background-repeat: initial initial;"><span style="font-size:10.5pt;font-family:宋体; color:#313131">此外，</span><strong><span style="font-size:10.5pt;font-family:宋体;color:red">Hadoop生态系统包括构建在Hadoop核心之上的数据仓库层/服务，而Hadoop上层服务包括SQL(Presto)、SQL-Like(Hive)和NoSQL(Hbase)类型的数据存储</span></strong><span style="font-size:10.5pt;font-family:宋体;color:#313131">。相比之下，<strong>在过去的十年中，大型数据仓库转移到使用自定义多处理器设备来扩展数据量</strong>，像</span><span style="font-size:10.5pt;font-family:宋体;color:#313131">Netezza(被IBM收购)和Teradata所提供的数据仓库。然而，这些设备都非常昂贵，大多数中小企业都负担不起。</span></p>  <p style="margin: 0in 0in 11.25pt; text-indent: 21pt; line-height: 19.5pt; background-color: white; background-position: initial initial; background-repeat: initial initial;"><span style="font-size:10.5pt;font-family:宋体;color:#313131">在这种背景下，我们很自然地要问：</span><span style="font-size:10.5pt;font-family:宋体;color:#313131">Hadoop是否是数据仓库的终结者?</span></p>  <p style="margin: 0in 0in 11.25pt; text-indent: 21pt; line-height: 19.5pt; background-color: white; background-position: initial initial; background-repeat: initial initial;"><span style="font-size:10.5pt;font-family:宋体;color:#313131">为了回答这个问题，我们需要将数据仓库技术与数据仓库部署分开来看。</span><strong><span style="font-size:10.5pt;font-family: 宋体;color:#313131">Hadoop(和NoSQL数据库的出现)将预示着数据仓库设备和传统数据仓库单一数据库部署的消亡</span></strong><span style="font-size:10.5pt;font-family:宋体;color:#313131">。</span></p>  <p style="margin: 0in 0in 0.0001pt; text-indent: 21pt; line-height: 19.5pt; background-color: white; background-position: initial initial; background-repeat: initial initial;"><span style="font-size:10.5pt;font-family:宋体; color:#313131">而在这方面就有过实例。</span><span style="font-size:10.5pt;font-family: 宋体;color:#313131">Hadoop供应商Cloudera将其平台作为&#8220;企业数据枢纽&#8221;，这在本质上将传统数据管理解决方案的纳入了需求。ReadWrite.com在最近发表的一篇题为&#8220;为什么专有大数据技术没有希望与Hadoop竞争&#8221;的文章中也发表了类似的看法。同样地，最近一篇华尔街日报文章描述了Hadoop如何挑战甲骨文和Teradata。</span></p>  <p style="margin: 0in 0in 0.0001pt; text-indent: 21pt; line-height: 19.5pt; background-color: white; background-position: initial initial; background-repeat: initial initial;"><span style="font-size:10.5pt;font-family:宋体;color:#313131">Hadoop或NoSQL生态系统仍将继续发展。很多大数据环境开始选择NoSQL、SQL甚至是NewSQL数据仓库的混合方法。此外，<strong>MapReduce并行处理引擎也有变化和改进，例如Apache的Spark项目</strong>。虽然这个故事还远远没有结束，<strong>但可以说，传统的单一服务器关系型数据库或数据库设备并不是大数据或数据仓储的未来</strong>。</span></p>  <p style="margin: 0in 0in 11.25pt; text-indent: 21pt; line-height: 19.5pt; background-color: white; background-position: initial initial; background-repeat: initial initial;"><span style="font-size:10.5pt;font-family:宋体;color:#313131">另一方面，数据仓库技术</span><span style="font-size:10.5pt;font-family:宋体;color:#313131">(包括提取&#8212;转换&#8212;和&#8212;加载、三维建模和商业智能)将会应用到新的Hadoop/NoSQL环境。此外，这些技术也将变身来支持更多的混合环境。主要原则是因为并不是所有数据都是平等的，所以IT经理们应该选择数据存储和访问机制来适应数据的使用。混合环境将包括关键价值存储、关系型数据库、图形存储、文档存储、柱状存储、XML数据库、元数据目录等等。</span></p>  <p style="margin: 0in 0in 11.25pt; text-indent: 21pt; line-height: 19.5pt; background-color: white; background-position: initial initial; background-repeat: initial initial;"><span style="font-size:10.5pt;font-family:宋体;color:#313131">正如你所看到的，这并不是一个简单的问题，也不可能简单地得出一个答案。然而，一般情况下，虽然大数据在未来五年内将会改变数据仓库的部署，但它不会导致数据仓库的概念和做法过时。</span></p>  <p style="margin: 0in 0in 11.25pt; text-indent: 21pt; line-height: 19.5pt; background-color: white; background-position: initial initial; background-repeat: initial initial;"><span style="font-size:10.5pt;font-family:宋体;color:#313131">对于向数据仓库投入巨资的联邦政府这意味着什么呢</span><span style="font-size:10.5pt;font-family:宋体;color:#313131">?</span></p>  <p style="margin: 0in 0in 0.0001pt; text-indent: 21pt; line-height: 19.5pt; background-color: white; background-position: initial initial; background-repeat: initial initial;"><span style="font-size:10.5pt;font-family:宋体; color:#313131">首先，当现有数据仓库的容量不够时，数据仓库将被转移到基于</span><span style="font-size:10.5pt; font-family:宋体;color:#313131">Hadoop、多机器或云托管的解决方案。其次，企业并不会选择&#8220;放之四海而皆准&#8221;的做法，而会将目光转向适合其企业内部数据容量的混合存储方法。（邹铮编译）</span></p>  <p>&nbsp;</p></div><img src ="http://www.blogjava.net/crazycy/aggbug/409096.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/crazycy/" target="_blank">crazycy</a> 2014-01-19 01:27 <a href="http://www.blogjava.net/crazycy/archive/2014/01/19/409096.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>NoSQL学习（六）﻿ 2014年大数据分析趋势展望(转)</title><link>http://www.blogjava.net/crazycy/archive/2014/01/18/409091.html</link><dc:creator>crazycy</dc:creator><author>crazycy</author><pubDate>Sat, 18 Jan 2014 13:51:00 GMT</pubDate><guid>http://www.blogjava.net/crazycy/archive/2014/01/18/409091.html</guid><wfw:comment>http://www.blogjava.net/crazycy/comments/409091.html</wfw:comment><comments>http://www.blogjava.net/crazycy/archive/2014/01/18/409091.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/crazycy/comments/commentRss/409091.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/crazycy/services/trackbacks/409091.html</trackback:ping><description><![CDATA[<div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all">2014年大数据分析趋势展望<br />Posted&nbsp;on&nbsp;2014年01月8日&nbsp;by&nbsp;DinK&nbsp;in&nbsp;行业资讯&nbsp;<br />http://www.199it.com/archives/185758.html</div><br /><p style="margin-top:0in;margin-right:0in;margin-bottom:.25in;margin-left:0in; text-indent:24.0pt;background:white;vertical-align:baseline"><span style="font-size:10.0pt;font-family:宋体; color:#333333">市场研究公司</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">IDC预测，2015年大数据市场规模将从2010年的32亿美元增长到170亿美元，复合年增长率为40%。大数据是一个庞大的新的领域，其中的数据集可以增长的非常庞大，以至于使用传统的数据库管理工具也很难处理。处理这种问题所需要的新工具、框架、硬件、软件和服务是一个巨大的市场机会。随着企业用户越来越多地需要连续不断地访问数据，好的大数据工具集将以最低的成本和接近实时的速度提供可伸缩的、高性能的分析。通过分析这种数据，企业可得到更大的智能以及竞争优势。下面是Hadoop和大数据专业厂商MapR共同创始人和首席执行官约翰&#183;施罗德（John&nbsp;Schroeder）对2014大数据市场的预测。</span></p>  <p style="margin: 0in 0in 0.0001pt; text-indent: 24pt; background-color: white; vertical-align: baseline; background-position: initial initial; background-repeat: initial initial;"><strong style="color:inherit"><span style="font-size:10.0pt; font-family:宋体;color:#333333;border:none windowtext 1.0pt;padding:0in">1.&nbsp;SQL拥有大数据的最大潜力</span></strong></p>  <p style="margin: 0in 0in 0.25in; text-indent: 24pt; background-color: white; vertical-align: baseline; background-position: initial initial; background-repeat: initial initial;"><span style="font-size:10.0pt;font-family:宋体; color:#333333">用于</span><span style="font-size:10.0pt;font-family:宋体;color:#333333"> Hadoop（分布式计算）的SQL的发展能够让商业分析师利用自己的技能和选择的SQL工具执行大数据项目。开发人员可以选择Hive、Drill和 Impala等Apache项目，以及选择Hadapt、HAWQ和Splice&nbsp;Machine等公司的专有技术。</span></p>  <p style="margin: 0in 0in 0.0001pt; text-indent: 24pt; background-color: white; vertical-align: baseline; background-position: initial initial; background-repeat: initial initial;"><strong style="color:inherit"><span style="font-size:10.0pt; font-family:宋体;color:#333333;border:none windowtext 1.0pt;padding:0in">2.&nbsp;尽管如此&nbsp;SQL还面临挑战</span></strong></p>  <p style="margin: 0in 0in 0.25in; text-indent: 24pt; background-color: white; vertical-align: baseline; background-position: initial initial; background-repeat: initial initial;"><span style="font-size:10.0pt;font-family:宋体; color:#333333">SQL需要数据结构。而集中的结构化数据可引起延迟并且需要人工管理。SQL还限制分析类型。过分强调SQL将延迟机构全面利用其数据价值的努力和延迟反应。</span></p>  <p style="margin: 0in 0in 0.0001pt; text-indent: 24pt; background-color: white; vertical-align: baseline; background-position: initial initial; background-repeat: initial initial;"><strong style="color:inherit"><span style="font-size:10.0pt; font-family:宋体;color:#333333;border:none windowtext 1.0pt;padding:0in">3.&nbsp;身份识别是主要的数据安全问题</span></strong></p>  <p style="margin: 0in 0in 0.25in; text-indent: 24pt; background-color: white; vertical-align: baseline; background-position: initial initial; background-repeat: initial initial;"><span style="font-size:10.0pt;font-family:宋体; color:#333333">随着</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">Hadoop（分布式计算）中提供的接入控制能力的猛烈攻击，机构迅速认识到线路级身份识别是必要的基础。没有充分的身份识别，任何更高级的控制都很容易被绕过，妨碍预定的安全计划。</span></p>  <p style="margin: 0in 0in 0.0001pt; text-indent: 24pt; background-color: white; vertical-align: baseline; background-position: initial initial; background-repeat: initial initial;"><strong style="color:inherit"><span style="font-size:10.0pt; font-family:宋体;color:#333333;border:none windowtext 1.0pt;padding:0in">4.&nbsp;数据错误变成学习机会</span></strong></p>  <p style="margin: 0in 0in 0.25in; text-indent: 24pt; background-color: white; vertical-align: baseline; background-position: initial initial; background-repeat: initial initial;"><span style="font-size:10.0pt;font-family:宋体; color:#333333">2014年机构将出现许多数据错误。数据错误将表明基础的来源系统的问题吗？数据错误是在下游分析中出现偏差导致的数据提取问题吗？数据错误将表明定义差异或者缺少跨部门和业务部门的一致性吗？2014年将看到解决数据异常问题。</span></p>  <p style="margin: 0in 0in 0.0001pt; text-indent: 24pt; background-color: white; vertical-align: baseline; background-position: initial initial; background-repeat: initial initial;"><strong style="color:inherit"><span style="font-size:10.0pt; font-family:宋体;color:#333333;border:none windowtext 1.0pt;padding:0in">5.&nbsp;出现可运行的Hadoop</span></strong></p>  <p style="margin: 0in 0in 0.25in; text-indent: 24pt; background-color: white; vertical-align: baseline; background-position: initial initial; background-repeat: initial initial;"><span style="font-size:10.0pt;font-family:宋体; color:#333333">2014年将看到Hadoop在各个行业中的生产部署显著增加。这将显示出Hadoop在运营中的实力。在那里，生产应用与分析结合在一起能够提供可以衡量的商业优势，如在客户化零售建议、诈骗检测和试验传感器数据进行规范的维护等应用中提供这些优势。</span></p>  <p style="margin: 0in 0in 0.0001pt; text-indent: 24pt; background-color: white; vertical-align: baseline; background-position: initial initial; background-repeat: initial initial;"><strong style="color:inherit"><span style="font-size:10.0pt; font-family:宋体;color:#333333;border:none windowtext 1.0pt;padding:0in">6.&nbsp;更多的数据仓库将部署企业数据中心</span></strong></p>  <p style="margin: 0in 0in 0.25in; text-indent: 24pt; background-color: white; vertical-align: baseline; background-position: initial initial; background-repeat: initial initial;"><span style="font-size:10.0pt;font-family:宋体; color:#333333">数据中心把数据提取处理和数据从企业数据仓库卸载到</span><span style="font-size:10.0pt; font-family:宋体;color:#333333">Hadoop。作为一个核心的中心企业中心，数据中心要便宜10倍，能够对额外的处理或者新的应用进行更多的分析。</span></p>  <p style="margin: 0in 0in 0.0001pt; text-indent: 24pt; background-color: white; vertical-align: baseline; background-position: initial initial; background-repeat: initial initial;"><strong style="color:inherit"><span style="font-size:10.0pt; font-family:宋体;color:#333333;border:none windowtext 1.0pt;padding:0in">7.&nbsp;新的以数据为中心的应用将成为强制性的</span></strong></p>  <p style="margin: 0in 0in 0.25in; text-indent: 24pt; background-color: white; vertical-align: baseline; background-position: initial initial; background-repeat: initial initial;"><span style="font-size:10.0pt;font-family:宋体; color:#333333">利用大数据的能力将在</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">2014年成为竞争的武器。更多的公司将使用大数据和Hadoop准确地针对个人消费者的偏爱追逐赚钱的追加销售和交叉销售的机会，更好地缓解风险以及减少生产和开销成本。</span></p>  <p style="margin: 0in 0in 0.0001pt; text-indent: 24pt; background-color: white; vertical-align: baseline; background-position: initial initial; background-repeat: initial initial;"><strong style="color:inherit"><span style="font-size:10.0pt; font-family:宋体;color:#333333;border:none windowtext 1.0pt;padding:0in">8.&nbsp;数据成为数据中心的核心</span></strong></p>  <p style="margin: 0in 0in 0.25in; text-indent: 24pt; background-color: white; vertical-align: baseline; background-position: initial initial; background-repeat: initial initial;"><span style="font-size:10.0pt;font-family:宋体; color:#333333">机构将从开发者过渡到大数据计划中。</span><span style="font-size:10.0pt; font-family:宋体;color:#333333">IT部门将越来越多地担负定义支持多种应用的数据基础设施的任务，把重点集中在部署、处理和保护一个机构的核心资产所需要的基础设施方面。</span></p>  <p style="margin: 0in 0in 0.0001pt; text-indent: 24pt; background-color: white; vertical-align: baseline; background-position: initial initial; background-repeat: initial initial;"><strong style="color:inherit"><span style="font-size:10.0pt; font-family:宋体;color:#333333;border:none windowtext 1.0pt;padding:0in">9.&nbsp;搜索将成为非结构化的查询语言</span></strong></p>  <p style="margin: 0in 0in 0.25in; text-indent: 24pt; background-color: white; vertical-align: baseline; background-position: initial initial; background-repeat: initial initial;"><span style="font-size:10.0pt;font-family:宋体; color:#333333">2013年有大量的用于Hadoop的SQL计划。2014年将是这种非结构化查询语言成为重点的一年。把搜索集成到Hadoop将为查找重要信息的企业用户提供一种简单和直观的方法。搜索引擎还是包括推荐引擎在内的许多发现和分析应用的核心。</span></p>  <p style="margin: 0in 0in 0.0001pt; text-indent: 24pt; background-color: white; vertical-align: baseline; background-position: initial initial; background-repeat: initial initial;"><strong style="color:inherit"><span style="font-size:10.0pt; font-family:宋体;color:#333333;border:none windowtext 1.0pt;padding:0in">10.&nbsp;Hadoop将获得地位</span></strong></p>  <p style="margin: 0in 0in 0.25in; text-indent: 24pt; background-color: white; vertical-align: baseline; background-position: initial initial; background-repeat: initial initial;"><span style="font-size:10.0pt;font-family:宋体; color:#333333">Hadoop将继续取代其它IT开支，颠覆企业数据仓库和企业存储。例如，甲骨文的主要营收目标在过去的10个季度里有5个季度没有实现。Teradata在过去的5个季度有4个季度没有实现营收和利润目标。</span></p>  <p style="margin: 0in 0in 0.0001pt; text-indent: 24pt; background-color: white; vertical-align: baseline; background-position: initial initial; background-repeat: initial initial;"><strong style="color:inherit"><span style="font-size:10.0pt; font-family:宋体;color:#333333;border:none windowtext 1.0pt;padding:0in">11.&nbsp;Hadoop仍需要帮助才能成为主流应用</span></strong></p>  <p style="margin: 0in 0in 0.25in; text-indent: 24pt; background-color: white; vertical-align: baseline; background-position: initial initial; background-repeat: initial initial;"><span style="font-size:10.0pt;font-family:宋体; color:#333333">更多的机构认识到</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">Apache&nbsp;Hadoop本身还没有准备好在企业应用。Apache&nbsp;Hadoop不是为系统管理或者灾难恢复等统一企业IT流程设计的。企业将继续推进混合的解决方案，把架构技术创新与Apache&nbsp;Hadoop的开源软件结合在一起。</span></p>  <div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />-->英文http://www.cio.com.au/slideshow/534054/pictures_12_big_data_predictions_2014/?image=3<br /><br />译文http://www.csdn.net/article/2013-12-25/2817926-pictures-12-big-data-predictions-2014<br />2014的12个大数据趋势：Hadoop继续升温，R将进入主流</div><p style="margin:0in;margin-bottom:.0001pt;background:white"><span lang="ZH-CN" style="font-size:10.0pt;font-family:宋体;mso-ascii-theme-font:minor-fareast;
mso-fareast-theme-font:minor-fareast;mso-hansi-theme-font:minor-fareast;
mso-bidi-font-family:宋体;color:#333333">当下，</span><span style="font-size:10.0pt;
font-family:宋体;mso-ascii-theme-font:minor-fareast;mso-fareast-theme-font:minor-fareast;
mso-hansi-theme-font:minor-fareast;mso-bidi-font-family:Helvetica;color:#333333">&#8220;</span><span lang="ZH-CN" style="font-size:10.0pt;font-family:宋体;mso-ascii-theme-font:minor-fareast;
mso-fareast-theme-font:minor-fareast;mso-hansi-theme-font:minor-fareast;
mso-bidi-font-family:宋体;color:#333333">大数据</span><span style="font-size:10.0pt;
font-family:宋体;mso-ascii-theme-font:minor-fareast;mso-fareast-theme-font:minor-fareast;
mso-hansi-theme-font:minor-fareast;mso-bidi-font-family:Helvetica;color:#333333">&#8221;</span><span lang="ZH-CN" style="font-size:10.0pt;font-family:宋体;mso-ascii-theme-font:minor-fareast;
mso-fareast-theme-font:minor-fareast;mso-hansi-theme-font:minor-fareast;
mso-bidi-font-family:宋体;color:#333333">已成为</span><span style="font-size:10.0pt;
font-family:宋体;mso-ascii-theme-font:minor-fareast;mso-fareast-theme-font:minor-fareast;
mso-hansi-theme-font:minor-fareast;mso-bidi-font-family:Helvetica;color:#333333">2013</span><span lang="ZH-CN" style="font-size:10.0pt;font-family:宋体;mso-ascii-theme-font:minor-fareast;
mso-fareast-theme-font:minor-fareast;mso-hansi-theme-font:minor-fareast;
mso-bidi-font-family:宋体;color:#333333">年最火的技术词汇之一；而在过去一年，这个市场的增速和改变也不可谓不大。同时，我们还看到了</span><span style="font-size:10.0pt;font-family:宋体;mso-ascii-theme-font:minor-fareast;
mso-fareast-theme-font:minor-fareast;mso-hansi-theme-font:minor-fareast;
mso-bidi-font-family:Helvetica;color:#333333">Hadoop</span><span lang="ZH-CN" style="font-size:10.0pt;font-family:宋体;mso-ascii-theme-font:minor-fareast;
mso-fareast-theme-font:minor-fareast;mso-hansi-theme-font:minor-fareast;
mso-bidi-font-family:宋体;color:#333333">及其生态系统的使用门槛从顶尖技术人才到数据科学家的改变。越来越多的企业拥抱大数据技术，并将其运用到生产环境中。那么，在</span><span style="font-size:10.0pt;font-family:宋体;mso-ascii-theme-font:minor-fareast;
mso-fareast-theme-font:minor-fareast;mso-hansi-theme-font:minor-fareast;
mso-bidi-font-family:Helvetica;color:#333333">2014</span><span lang="ZH-CN" style="font-size:10.0pt;font-family:宋体;mso-ascii-theme-font:minor-fareast;
mso-fareast-theme-font:minor-fareast;mso-hansi-theme-font:minor-fareast;
mso-bidi-font-family:宋体;color:#333333">年大数据的发展趋势又会如何，这里不妨看一下来自</span><span style="font-size:10.0pt;font-family:宋体;mso-ascii-theme-font:minor-fareast;
mso-fareast-theme-font:minor-fareast;mso-hansi-theme-font:minor-fareast;
mso-bidi-font-family:Helvetica;color:#333333">CIO</span><span lang="ZH-CN" style="font-size:10.0pt;font-family:宋体;mso-ascii-theme-font:minor-fareast;
mso-fareast-theme-font:minor-fareast;mso-hansi-theme-font:minor-fareast;
mso-bidi-font-family:宋体;color:#333333">的</span><span style="font-size:10.0pt;
font-family:宋体;mso-ascii-theme-font:minor-fareast;mso-fareast-theme-font:minor-fareast;
mso-hansi-theme-font:minor-fareast;mso-bidi-font-family:Helvetica;color:#333333">12</span><span lang="ZH-CN" style="font-size:10.0pt;font-family:宋体;mso-ascii-theme-font:minor-fareast;
mso-fareast-theme-font:minor-fareast;mso-hansi-theme-font:minor-fareast;
mso-bidi-font-family:宋体;color:#333333">项预测：</span><span style="font-size:10.0pt;
font-family:宋体;mso-ascii-theme-font:minor-fareast;mso-fareast-theme-font:minor-fareast;
mso-hansi-theme-font:minor-fareast;mso-bidi-font-family:Helvetica;color:#333333"><o:p></o:p></span></p><p style="line-height:normal"><strong style="line-height: 21px;"><span style="font-size:10.0pt;font-family:宋体;color:#333333">1. </span></strong><strong style="line-height: 21px;"><span style="font-size:10.0pt;font-family:宋体;color:#333333">人们不再止步于大数据的谈论</span></strong><span style="line-height: 21px; font-size: 10pt; font-family: 宋体; color: #333333;"><a href="http://cms.csdnimg.cn/article/201312/25/52ba972c8dcfc.jpg" target="_blank">&nbsp;</a></span></p><p style="margin: 0in 0in 0.0001pt; background-color: white; background-position: initial initial; background-repeat: initial initial;"><span style="font-size:10.0pt;font-family:宋体;color:#333333"> 2014</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">年，大数据止于说的情况将发生改变，人们将致力于从中获益，所有大数据的炒作也将</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">&#8220;</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">烟消云散</span><span style="font-size:10.0pt; font-family:宋体;color:#333333">&#8221;</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">。从</span><span style="font-size:10.0pt; font-family:宋体;color:#333333">Gainsight</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">了解到，大数据本身也将成为桌面上的筹码，</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">Gainsight</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">在其</span><span style="font-size:10.0pt; font-family:宋体;color:#333333">IaaS</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">平台中利用大数据分析被其称之为</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">&#8220;customer success management&#8221;</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">的服务。</span><span style="font-size:10.0pt; font-family:宋体;color:#333333">Gainsight</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">认为，在</span><span style="font-size:10.0pt; font-family:宋体;color:#333333">2014</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">年，每家云应用程序提供商都将会让其后端基础设施支持大数据。</span></p>  <p style="margin:0in;margin-bottom:.0001pt;background:white"><strong><span style="font-size:10.0pt;font-family:宋体;color:#333333"><br />2. Hadoop</span></strong><strong><span style="font-size:10.0pt;font-family:宋体;color:#333333">将成为企业的关键组件</span></strong><span style="font-size:10.0pt;font-family:宋体;color:#333333"><br /> Hadoop</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">将普及，大数据也不会再继续止步于云服务。</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">Alteryx</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">认为，</span><span style="font-size:10.0pt; font-family:宋体;color:#333333">2014</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">年，</span><span style="font-size:10.0pt; font-family:宋体;color:#333333">Hadoop</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">的适用场景将超越批处理和存储，将成为企业数据架构中通用的核心组件，这意味着数据分析将继续成为大数据的首要用例。</span></p>  <p style="margin:0in;margin-bottom:.0001pt;background:white"><strong><span style="font-size:10.0pt;font-family:宋体;color:#333333"><br />3. </span></strong><strong><span style="font-size:10.0pt;font-family:宋体;color:#333333">企业将更加钟情于用户数据</span></strong><span style="font-size:10.0pt;font-family:宋体;color:#333333"><br /> </span><span style="font-size:10.0pt;font-family:宋体;color:#333333">从</span><span style="font-size:10.0pt; font-family:宋体;color:#333333">Gainsight</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">了解到，各个机构将对用户数据充满热情，企业将充分利用客户与其在线产品或服务交互产生的数据，并从中获取价值。为了实现这点，数据分析能力将比</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">BI</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">团队更受重视，为企业提供更多的价值。</span></p>  <p style="margin:0in;margin-bottom:.0001pt;background:white"><strong><span style="font-size:10.0pt;font-family:宋体;color:#333333"><br />4. </span></strong><strong><span style="font-size:10.0pt;font-family:宋体;color:#333333">大数据玩转市场决策</span></strong><span style="font-size:10.0pt;font-family:宋体;color:#333333"><br /> Alteryx</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">认为，在</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">2014</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">年，大数据将首次正式登陆市场营销，用于市场营销的大数据技术将在这一年扮演重要角色</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">&#8212;&#8212;</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">影响着广告、产品推销和消费者行为，</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">World Cup</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">及</span><span style="font-size:10.0pt; font-family:宋体;color:#333333">Winter Olympics</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">将是其最大的舞台。</span></p>  <p style="margin:0in;margin-bottom:.0001pt;background:white"><strong><span style="font-size:10.0pt;font-family:宋体;color:#333333"><br />5. </span></strong><strong><span style="font-size:10.0pt;font-family:宋体;color:#333333">海量的数据将超越数据科学家的意识</span></strong><span style="font-size:10.0pt;font-family:宋体;color:#333333"><br /> lteryx</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">认为，新型的数据分析需求将超越人力可为，有些情况下大数据技术将堪比成千上万的数据科学家。该公司预测，这将会毫无疑问的拉低数据科学家薪酬。</span></p>  <p style="margin:0in;margin-bottom:.0001pt;background:white"><strong><span style="font-size:10.0pt;font-family:宋体;color:#333333"><br />6. </span></strong><strong><span style="font-size:10.0pt;font-family:宋体;color:#333333">物联网将进军网络</span></strong><span style="font-size:10.0pt;font-family:宋体;color:#333333"><br /> IEEE</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">的专业协会认为，</span><span style="font-size: 10.0pt;font-family:宋体; color:#333333">2014</span><span style="font-size:10.0pt;font-family: 宋体;color:#333333">年，可识别事物将无缝的连接到信息网络，实现真正意义上的</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">Web of Things</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">。</span><span style="font-size:10.0pt; font-family:宋体;color:#333333">The Web of Things</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">将会充分利用移动设备和传感器的监控能力，增强现实世界中的物体与</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">Web</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">副本之间的协同性。</span></p>  <p style="margin:0in;margin-bottom:.0001pt;background:white"><span style="font-size:10.0pt;font-family:宋体;color:#333333">The Web of Things</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">将会生成大量与现实世界相关的数据，因而会需求智能化的解决方案在现实世界与相对应的数字世界资源之间赋予连接性、网际互连和相关性。</span></p>  <p style="margin:0in;margin-bottom:.0001pt;background:white"><strong><span style="font-size:10.0pt;font-family:宋体;color:#333333"><br />7. </span></strong><strong><span style="font-size:10.0pt;font-family:宋体;color:#333333">从大数据到海量数据</span></strong><span style="font-size:10.0pt;font-family:宋体;color:#333333"><br /> </span><span style="font-size:10.0pt;font-family:宋体;color:#333333">数据的体积、速度和类型（</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">volume</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">、</span><span style="font-size:10.0pt; font-family:宋体;color:#333333">velocity</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">和</span><span style="font-size:10.0pt; font-family:宋体;color:#333333">variety</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">）在</span><span style="font-size:10.0pt; font-family:宋体;color:#333333">2014</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">年将会继续呈指数级增长，因此需要更简单的分析工具来驾驭这些</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">&#8220;</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">数据洪流</span><span style="font-size:10.0pt; font-family:宋体;color:#333333">&#8221;</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">。</span><span style="font-size:10.0pt; font-family:宋体;color:#333333"><br /> <br /> IEEE</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">称，</span><span style="font-size:10.0pt; font-family:宋体;color:#333333">&#8220;</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">不止是</span><span style="font-size:10.0pt; font-family:宋体;color:#333333">3</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">个</span><span style="font-size:10.0pt; font-family:宋体;color:#333333">V</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">让大数据成了非常难以制服的老虎，数据科学家及行业所需简单工具也是个难题，许多行业尚无独立提取数据价值的能力。当前已出现的海量数据时代更需求数据管理和分析上新的范式和实践。</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">2014</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">年，这个领域将上演群雄争霸。</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">&#8221;</span></p>  <p style="margin:0in;margin-bottom:.0001pt;background:white"><strong><span style="font-size:10.0pt;font-family:宋体;color:#333333"><br />8. R</span></strong><strong><span style="font-size:10.0pt;font-family:宋体;color:#333333">语言将取代传统</span></strong><strong><span style="font-size:10.0pt;font-family:宋体;color:#333333">SAS</span></strong><strong><span style="font-size:10.0pt;font-family:宋体;color:#333333">解决方案</span></strong><span style="font-size: 10.0pt;font-family:宋体; color:#333333"><br /> Alteryx</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">认为，基于</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">R</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">编程语言的分析将数据科学家</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">&#8220;</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">御用</span><span style="font-size:10.0pt; font-family:宋体;color:#333333">&#8221;</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">模式，这种分析在</span><span style="font-size: 10.0pt;font-family:宋体; color:#333333">2014</span><span style="font-size:10.0pt;font-family: 宋体;color:#333333">年将成为主流，将替代传统的</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">SAS</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">及</span><span style="font-size:10.0pt; font-family:宋体;color:#333333">SPSS</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">模式。</span><span style="font-size:10.0pt; font-family:宋体;color:#333333">Alteryx</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">说道：</span><span style="font-size:10.0pt; font-family:宋体;color:#333333">&#8220;</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">超过</span><span style="font-size:10.0pt; font-family:宋体;color:#333333">200</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">万用户和</span><span style="font-size:10.0pt; font-family:宋体;color:#333333">300</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">万的分析师都在寻找更好的解决方案，</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">R</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">恰逢其时。</span><span style="font-size:10.0pt; font-family:宋体;color:#333333">&#8221;</span></p>  <p style="margin:0in;margin-bottom:.0001pt;background:white"><strong><span style="font-size:10.0pt;font-family:宋体;color:#333333"><br />9. Hadoop</span></strong><strong><span style="font-size:10.0pt;font-family:宋体;color:#333333">将增加实时特性</span></strong><span style="font-size:10.0pt;font-family:宋体;color:#333333"><br /> SQL-on-Hadoop</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">供应商</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">Splice Machine</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">共同创始人兼</span><span style="font-size: 10.0pt;font-family:宋体; color:#333333">CEO Monte Zweben</span><span style="font-size:10.0pt; font-family:宋体;color:#333333">指出，未来</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">1</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">年建立在</span><span style="font-size:10.0pt; font-family:宋体;color:#333333">Hadoop</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">平台上的交互式应用程序将呈爆发式增长，其中包括</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">Web</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">应用、移动应用和社交应用，人们可以与之进行实时的交互。</span></p>  <p style="margin:0in;margin-bottom:.0001pt;background:white"><span style="font-size:10.0pt;font-family:宋体;color:#333333">Zweben</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">说道：</span><span style="font-size:10.0pt; font-family:宋体;color:#333333">&#8220;2014</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">将带来实时大数据应用程序平台，企业将不会只能像当下一样分析历史数据，你将有能力分析</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">5</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">分钟，甚至是</span><span style="font-size: 10.0pt;font-family:宋体; color:#333333">1</span><span style="font-size:10.0pt;font-family: 宋体;color:#333333">分钟之内的数据；企业将拥有交互式应用程序，以便实时的制定决策。</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">&#8221;</span></p>  <p style="margin: 0in 0in 0.0001pt; background-color: white; background-position: initial initial; background-repeat: initial initial;"><strong><span style="font-size:10.0pt;font-family:宋体;color:#333333"><br />10. Hadoop</span></strong><strong><span style="font-size:10.0pt;font-family:宋体;color:#333333">将得到企业级强化</span></strong><span style="font-size:10.0pt;font-family:宋体;color:#333333"><br /> Splice Machine</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">的</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">Zweben</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">说：</span><span style="font-size:10.0pt; font-family:宋体;color:#333333">&#8220;</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">毋庸置疑，</span><span style="font-size:10.0pt; font-family:宋体;color:#333333">Hadoop</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">是个了不起的平台，但是仍然有许多工作要做。</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">&#8221;</span></p>  <p style="margin:0in;margin-bottom:.0001pt;background:white"><span style="font-size:10.0pt;font-family:宋体;color:#333333">他认为，在</span><span style="font-size:10.0pt; font-family:宋体;color:#333333">2014</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">，你将看到</span><span style="font-size:10.0pt; font-family:宋体;color:#333333">Hadoop</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">向安全、运营管理、资源管理及多站点响应方向发展。</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">Zweben</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">补充道：</span><span style="font-size:10.0pt; font-family:宋体;color:#333333">&#8220;</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">你将看到所有的企业级需求，我认为这些将是未来主要的焦点。</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">&#8221;</span></p>  <p style="margin: 0in 0in 0.0001pt; background-color: white; background-position: initial initial; background-repeat: initial initial;"><strong><span style="font-size:10.0pt;font-family:宋体;color:#333333"><br />11. &nbsp;2014</span></strong><strong><span style="font-size:10.0pt;font-family:宋体;color:#333333">年底，至少有一家</span></strong><strong><span style="font-size:10.0pt;font-family:宋体;color:#333333">NoSQL IPO</span></strong><span style="font-size:10.0pt;font-family:宋体;color:#333333"><br /> </span><span style="font-size:10.0pt;font-family:宋体;color:#333333">大数据及云环境安全解决方案</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">Gazzang</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">董事长兼</span><span style="font-size:10.0pt; font-family:宋体;color:#333333">CEO Larry Warnock</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">预测，在</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">2014</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">，至少有一家</span><span style="font-size: 10.0pt;font-family:宋体; color:#333333">Hadoop</span><span style="font-size:10.0pt; font-family:宋体;color:#333333">或者</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">NoSQL</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">供应商会</span><span style="font-size:10.0pt; font-family:宋体;color:#333333">IPO</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">，这标志着大数据平台已被广泛认可。</span></p>  <p style="margin:0in;margin-bottom:.0001pt;background:white"><span style="font-size:10.0pt;font-family:宋体;color:#333333">Warnock</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">说道：</span><span style="font-size:10.0pt; font-family:宋体;color:#333333">&#8220;</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">我不会去预测哪家会</span><span style="font-size: 10.0pt;font-family:宋体; color:#333333">IPO</span><span style="font-size:10.0pt;font-family: 宋体;color:#333333">，但是至少会有一家</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">Hadoop</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">或</span><span style="font-size:10.0pt; font-family:宋体;color:#333333">NoSQL</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">供应商</span><span style="font-size:10.0pt; font-family:宋体;color:#333333">IPO</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">。通过</span><span style="font-size:10.0pt; font-family:宋体;color:#333333">Wikibon</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">了解到，在</span><span style="font-size:10.0pt; font-family:宋体;color:#333333">2012</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">年，</span><span style="font-size:10.0pt; font-family:宋体;color:#333333">NoSQL</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">软件和服务创造了</span><span style="font-size: 10.0pt;font-family:宋体; color:#333333">2.86</span><span style="font-size:10.0pt;font-family: 宋体;color:#333333">亿美元的税收，而在</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">2017</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">年，这个数据被预测为</span><span style="font-size: 10.0pt;font-family:宋体; color:#333333">18.25</span><span style="font-size:10.0pt;font-family: 宋体;color:#333333">亿。商场被不断增长的企业需求推动，他们需要灵活、可扩展及负担得起的数据管理解决方案，为新时代的云及大数据设计。</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">&#8221;</span></p>  <p style="margin: 0in 0in 0.0001pt; background-color: white; background-position: initial initial; background-repeat: initial initial;"><strong><span style="font-size:10.0pt;font-family:宋体;color:#333333"><br />12. </span></strong><strong><span style="font-size:10.0pt;font-family:宋体;color:#333333">一个新的分析堆栈将诞生</span></strong><span style="font-size:10.0pt;font-family:宋体;color:#333333"><br /> Alteryx </span><span style="font-size:10.0pt;font-family:宋体;color:#333333">预测，</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">2014</span><span style="font-size:10.0pt;font-family:宋体;color:#333333">年，将出现一个新的数据及分析堆栈，为数据库、分析、可视化提供新的解决方案，这将直接威胁到传统的供应商巨头，而这些供应商也会在匆忙中推出新的解决方案。</span></p>  <p style="margin-bottom:0in;margin-bottom:.0001pt;line-height: normal">&nbsp;</p><img src ="http://www.blogjava.net/crazycy/aggbug/409091.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/crazycy/" target="_blank">crazycy</a> 2014-01-18 21:51 <a href="http://www.blogjava.net/crazycy/archive/2014/01/18/409091.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>NoSQL学习（五）Cassandra vs MongoDB vs CouchDB vs Redis vs Riak vs HBase vs Couchbase vs Neo4j vs Hypertable vs ElasticSearch vs Accumulo vs VoltDB vs Scalaris comparison</title><link>http://www.blogjava.net/crazycy/archive/2014/01/14/408883.html</link><dc:creator>crazycy</dc:creator><author>crazycy</author><pubDate>Mon, 13 Jan 2014 17:34:00 GMT</pubDate><guid>http://www.blogjava.net/crazycy/archive/2014/01/14/408883.html</guid><wfw:comment>http://www.blogjava.net/crazycy/comments/408883.html</wfw:comment><comments>http://www.blogjava.net/crazycy/archive/2014/01/14/408883.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/crazycy/comments/commentRss/408883.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/crazycy/services/trackbacks/408883.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: Cassandra&nbsp;vs&nbsp;MongoDB&nbsp;vs&nbsp;CouchDB&nbsp;vs&nbsp;Redis&nbsp;vs&nbsp;Riak&nbsp;vsHBase&nbsp;vs&nbsp;Couchbase&nbsp;vs&nbsp;Neo4j&nbsp;vs&nbsp;Hypertable&nbsp;vsElasticSearch&nbsp;vs&nbs...&nbsp;&nbsp;<a href='http://www.blogjava.net/crazycy/archive/2014/01/14/408883.html'>阅读全文</a><img src ="http://www.blogjava.net/crazycy/aggbug/408883.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/crazycy/" target="_blank">crazycy</a> 2014-01-14 01:34 <a href="http://www.blogjava.net/crazycy/archive/2014/01/14/408883.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>NoSQL非关系型数据库学习（四）这样对比下HBase, Memcached, MongoDB, Redis和Solr</title><link>http://www.blogjava.net/crazycy/archive/2014/01/14/408880.html</link><dc:creator>crazycy</dc:creator><author>crazycy</author><pubDate>Mon, 13 Jan 2014 16:27:00 GMT</pubDate><guid>http://www.blogjava.net/crazycy/archive/2014/01/14/408880.html</guid><wfw:comment>http://www.blogjava.net/crazycy/comments/408880.html</wfw:comment><comments>http://www.blogjava.net/crazycy/archive/2014/01/14/408880.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/crazycy/comments/commentRss/408880.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/crazycy/services/trackbacks/408880.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: Sourcehttp://db-engines.com/en/system/HBase%3BMemcached%3BRedis%3BSolr     Name      HBase&nbsp;&nbsp;       Memcached&nbsp;       MongoDB&nbsp;&nbsp;       Redis&nbsp;&n...&nbsp;&nbsp;<a href='http://www.blogjava.net/crazycy/archive/2014/01/14/408880.html'>阅读全文</a><img src ="http://www.blogjava.net/crazycy/aggbug/408880.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/crazycy/" target="_blank">crazycy</a> 2014-01-14 00:27 <a href="http://www.blogjava.net/crazycy/archive/2014/01/14/408880.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>NoSQL非关系型数据库学习（三）NoSQL与RDBMS：何时使用，何时不使用</title><link>http://www.blogjava.net/crazycy/archive/2014/01/13/408845.html</link><dc:creator>crazycy</dc:creator><author>crazycy</author><pubDate>Mon, 13 Jan 2014 04:12:00 GMT</pubDate><guid>http://www.blogjava.net/crazycy/archive/2014/01/13/408845.html</guid><wfw:comment>http://www.blogjava.net/crazycy/comments/408845.html</wfw:comment><comments>http://www.blogjava.net/crazycy/archive/2014/01/13/408845.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/crazycy/comments/commentRss/408845.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/crazycy/services/trackbacks/408845.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: NoSQL数据库面临的挑战NoSQL vs RDBMS: Why and why not to use NoSQL over RDBMS?&nbsp;  Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->Naresh&nbsp;Kumar3&nbsp;J...&nbsp;&nbsp;<a href='http://www.blogjava.net/crazycy/archive/2014/01/13/408845.html'>阅读全文</a><img src ="http://www.blogjava.net/crazycy/aggbug/408845.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/crazycy/" target="_blank">crazycy</a> 2014-01-13 12:12 <a href="http://www.blogjava.net/crazycy/archive/2014/01/13/408845.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>NoSQL非关系型数据库学习（二）</title><link>http://www.blogjava.net/crazycy/archive/2014/01/13/408844.html</link><dc:creator>crazycy</dc:creator><author>crazycy</author><pubDate>Mon, 13 Jan 2014 04:03:00 GMT</pubDate><guid>http://www.blogjava.net/crazycy/archive/2014/01/13/408844.html</guid><wfw:comment>http://www.blogjava.net/crazycy/comments/408844.html</wfw:comment><comments>http://www.blogjava.net/crazycy/archive/2014/01/13/408844.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/crazycy/comments/commentRss/408844.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/crazycy/services/trackbacks/408844.html</trackback:ping><description><![CDATA[<p style="margin:0in;margin-bottom:.0001pt;line-height:18.75pt;background:white"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;Times New Roman&quot;;">Gartner</span><span style="font-size:11.0pt;font-family:宋体;Times New Roman&quot;;">分析师</span><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;Times New Roman&quot;;">Merv Adrian</span><span style="font-size:11.0pt;font-family:宋体;Times New Roman&quot;;">在</span><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;Times New Roman&quot;;">Twitter</span><span style="font-size:11.0pt;font-family:宋体;Times New Roman&quot;;">上</span><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;Times New Roman&quot;;">RT</span><span style="font-size: 11.0pt;font-family:宋体;Times New Roman&quot;;">了一条关于</span><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;Times New Roman&quot;;">NoSQL</span><span style="font-size: 11.0pt;font-family:宋体;Times New Roman&quot;;">数据库评选的消息，他认为这就像是在对比你更喜欢苹果、鸡尾酒还是西兰花，它们都有不同的应用场景，对比</span><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;Times New Roman&quot;;">NoSQL</span><span style="font-size: 11.0pt;font-family:宋体;Times New Roman&quot;;">产品是没有意义的。比如</span><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;Times New Roman&quot;;">MongoDB</span><span style="font-size:11.0pt;font-family:宋体;Times New Roman&quot;;">和</span><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;Times New Roman&quot;;">Cassandra</span><span style="font-size:11.0pt;font-family:宋体;Times New Roman&quot;;">就没有什么可比性，<strong>它们的共同点只是都叫做</strong></span><strong><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;Times New Roman&quot;;">NoSQL</span></strong><strong><span style="font-size:11.0pt;font-family:宋体;Times New Roman&quot;;">数据库而已，它们的应用场景非常不同。</span></strong><strong></strong></p>  <p style="margin:0in;margin-bottom:.0001pt;line-height:18.75pt;background:white"><strong>&nbsp;</strong></p>  <p><span style="font-family:宋体;">下面还是根据学习，对现在比较热门的MangoDB和Memcached以及Redis做个简单的学习：</span></p>  <p><strong>MangoDB<span style="font-family:宋体;">是</span>(document database, <span style="font-family:宋体;">硬盘型</span>)</strong><br /> a.&nbsp;<span style="font-family:宋体;">基于磁盘的数据库，只是缓存热点数据在内存中。</span><br /> b. <span style="font-family:宋体;">文档型的非关系型数据库，</span><br /> &nbsp;&nbsp;&nbsp; <span style="font-family: 宋体;">优势是查询功能强大，可存储海量数据。</span><br /> c. <span style="font-family:宋体;">可替换</span>MySQL<span style="font-family:宋体;">等关系型数据库</span>; <br /> &nbsp;&nbsp;&nbsp; <span style="font-family: 宋体;">在内存足够的情况下，读写性能不错，可省去</span>Cache<span style="font-family:宋体;">这一层<br /><br /></span></p>  <p><strong>Memcached<span style="font-family:宋体;">和</span>Redis<span style="font-family:宋体;">是</span>(key value store, <span style="font-family:宋体;">内存型</span>)</strong><br /> a.<span style="font-family:宋体;">内存型数据库，数据保存在内存中，通过</span>TCP<span style="font-family:宋体;">直接存取；</span> <span style="font-family:宋体;">或者说是全内存</span>Cache<span style="font-family:宋体;">。</span><br /> &nbsp;&nbsp; <span style="font-family: 宋体;">优势是速度快，并发高，缺点是数据类型有限，查询功能不强，一般做缓存。</span><br /> b. Key Value Store<br /> c. 全内存<br /><br /></p>  <p><strong>Memcached vs Redis</strong><br /> a. 都是Key Vale, Memory Cache<br /> b. Memecahced是 multiple-thread; <span style="font-family:宋体;">适合多核</span>CPU<span style="font-family:宋体;">的应用。</span><br /> &nbsp;&nbsp;&nbsp; Redis是 single-thread.<br /> &nbsp;&nbsp;&nbsp; <span style="font-family: 宋体;">如果再多数据结构基础上支持多线程，加锁可能是个问题</span><span style="font-family: 宋体; color: red;"><strong>（待深入学习验证）</strong></span>。<br /> c. Redis<span style="font-family:宋体;">具有持久化机制，可以定期将内存的数据持久化到硬盘上</span> <br /> d. Redis<span style="font-family:宋体;">支持的数据类型更多</span><br /> e. Redis <span style="font-family:宋体;">具备</span>binlog<span style="font-family:宋体;">功能，将所有操作写入日志，以便</span>redis<span style="font-family:宋体;">出现故障时，可通过</span>binlog<span style="font-family:宋体;">进行恢复。</span><br /> f. Redis<span style="font-family:宋体;">支持</span>Virtual Memory<span style="font-family:宋体;">，可限定内存大小，当数据超出阀值，就通过类似</span>LRU<span style="font-family:宋体;">的算法将最不常用的数据保存到硬盘的页面问题中。</span></p>  <p style="margin:0in;margin-bottom:.0001pt;line-height:18.75pt;background:white">&nbsp;</p><img src ="http://www.blogjava.net/crazycy/aggbug/408844.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/crazycy/" target="_blank">crazycy</a> 2014-01-13 12:03 <a href="http://www.blogjava.net/crazycy/archive/2014/01/13/408844.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>NoSQL非关系型数据库学习（一）</title><link>http://www.blogjava.net/crazycy/archive/2014/01/13/408842.html</link><dc:creator>crazycy</dc:creator><author>crazycy</author><pubDate>Mon, 13 Jan 2014 03:53:00 GMT</pubDate><guid>http://www.blogjava.net/crazycy/archive/2014/01/13/408842.html</guid><wfw:comment>http://www.blogjava.net/crazycy/comments/408842.html</wfw:comment><comments>http://www.blogjava.net/crazycy/archive/2014/01/13/408842.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.blogjava.net/crazycy/comments/commentRss/408842.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/crazycy/services/trackbacks/408842.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 在2008年的时候，我还是只知道DB2,Oracle, MS SQLServer, Sybase, MySQL, PostgreSQL,&nbsp; Firebird等主流商业或者开源数据库。当汲取知识于网络之际，突然发现很多新的名词鱼跃而出，什么 SQLite, Memcached,&nbsp; FastDB, MongoDB,Solr, Redis, HBase, &nbsp;Cass...&nbsp;&nbsp;<a href='http://www.blogjava.net/crazycy/archive/2014/01/13/408842.html'>阅读全文</a><img src ="http://www.blogjava.net/crazycy/aggbug/408842.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/crazycy/" target="_blank">crazycy</a> 2014-01-13 11:53 <a href="http://www.blogjava.net/crazycy/archive/2014/01/13/408842.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>sqlserver: Invalid use of a side-effecting operator within a function (Print/Raiserror)</title><link>http://www.blogjava.net/crazycy/archive/2013/10/25/405643.html</link><dc:creator>crazycy</dc:creator><author>crazycy</author><pubDate>Fri, 25 Oct 2013 10:24:00 GMT</pubDate><guid>http://www.blogjava.net/crazycy/archive/2013/10/25/405643.html</guid><wfw:comment>http://www.blogjava.net/crazycy/comments/405643.html</wfw:comment><comments>http://www.blogjava.net/crazycy/archive/2013/10/25/405643.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/crazycy/comments/commentRss/405643.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/crazycy/services/trackbacks/405643.html</trackback:ping><description><![CDATA[写函数的时候遇到了这样的问题<br /><div style="background-color: #eeeeee; font-size: 13px; border: 1px solid #cccccc; padding: 4px 5px 4px 4px; width: 98%; word-break: break-all;"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />-->使用<br />raiserror('enter&nbsp;this&nbsp;line',&nbsp;16,&nbsp;-1)&nbsp;with&nbsp;log<br />print('enter&nbsp;this&nbsp;line')<br /><br />分别遇到了<br />Invalid&nbsp;use&nbsp;of&nbsp;a&nbsp;side-effecting&nbsp;operator&nbsp;'Print'&nbsp;within&nbsp;a&nbsp;function<br />Invalid&nbsp;use&nbsp;of&nbsp;a&nbsp;side-effecting&nbsp;operator&nbsp;'Raiserror'&nbsp;within&nbsp;a&nbsp;function</div><br />原来，在函数中使用DML还真不能太随意，SELECT可以；UPDATE/DELTE/INSERT还真不可以。<br />网上google了下，还真是不少类似的案例<br />1. Functions are used to return data: scalar-value or table-value.<br />2.&nbsp;<br /><div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all">Invalid&nbsp;use&nbsp;of&nbsp;side-effecting&nbsp;or&nbsp;time-dependent&nbsp;operator&nbsp;in&nbsp;&#8216;newid&#8217;&nbsp;within&nbsp;a&nbsp;function.<br />It&nbsp;states&nbsp;that&nbsp;the&nbsp;use&nbsp;of&nbsp;<strong>side-effecting</strong>&nbsp;and&nbsp;<strong>time-dependent</strong>&nbsp;operators&nbsp;is&nbsp;not&nbsp;allowed&nbsp;within&nbsp;a&nbsp;function.&nbsp;<br /><br /><br /><strong style="font-size: 12pt;">Side-Effecting&nbsp;Operators</strong><br />A&nbsp;side-effecting&nbsp;operator&nbsp;is&nbsp;basically&nbsp;what&nbsp;it&nbsp;says.&nbsp;&nbsp;<br /><strong>It&nbsp;is&nbsp;an&nbsp;operator&nbsp;that&nbsp;affects&nbsp;anything&nbsp;outside&nbsp;the&nbsp;function.&nbsp;&nbsp;</strong><br />This&nbsp;could&nbsp;be&nbsp;seen&nbsp;when&nbsp;trying&nbsp;to&nbsp;create&nbsp;an&nbsp;object&nbsp;or&nbsp;insert&nbsp;or&nbsp;update&nbsp;a&nbsp;table.&nbsp;&nbsp;<br /><br />Functions&nbsp;should&nbsp;be&nbsp;self-contained.&nbsp;&nbsp;<br />They&nbsp;can&nbsp;use&nbsp;data&nbsp;from&nbsp;the&nbsp;database,&nbsp;but&nbsp;should&nbsp;not&nbsp;affect&nbsp;data&nbsp;in&nbsp;the&nbsp;database.&nbsp;&nbsp;<br /><strong>In&nbsp;other&nbsp;words,&nbsp;functions&nbsp;should&nbsp;be&nbsp;read-only.</strong><br /><br />There&nbsp;is&nbsp;a&nbsp;list&nbsp;of&nbsp;side-effecting&nbsp;operators, which&nbsp;include&nbsp;INSERT,&nbsp;CREATE,&nbsp;UPDATE,&nbsp;OPEN,&nbsp;CLOSE,&nbsp;DELETE,&nbsp;SELECT&nbsp;&#8230;&nbsp;INTO,&nbsp;and&nbsp;more.&nbsp;&nbsp;<br />You&nbsp;cannot&nbsp;use&nbsp;these&nbsp;inside&nbsp;a&nbsp;function.&nbsp;&nbsp;<br />If&nbsp;you&nbsp;<span style="color: #0000FF; ">do</span>,&nbsp;you&nbsp;will&nbsp;receive&nbsp;a&nbsp;slightly&nbsp;different&nbsp;message.&nbsp;&nbsp;The&nbsp;message&nbsp;will&nbsp;not&nbsp;mention&nbsp;time-dependent&nbsp;operators.&nbsp;&nbsp;It&nbsp;will&nbsp;look&nbsp;like&nbsp;<span style="color: #0000FF; ">this</span>.<br />Msg&nbsp;443,&nbsp;Level&nbsp;16,&nbsp;State&nbsp;15,&nbsp;Procedure&nbsp;FN_TEST,&nbsp;Line&nbsp;9<br />Invalid&nbsp;use&nbsp;of&nbsp;a&nbsp;side-effecting&nbsp;operator&nbsp;&#8216;INSERT&#8217;&nbsp;within&nbsp;a&nbsp;function.&nbsp;<br /><br />To&nbsp;get&nbsp;around&nbsp;some&nbsp;of&nbsp;the&nbsp;side-effecting&nbsp;operator&nbsp;rules&nbsp;shown&nbsp;by&nbsp;Msg&nbsp;443,&nbsp;we&nbsp;can&nbsp;use&nbsp;a&nbsp;table&nbsp;variable.&nbsp;&nbsp;<br />Below&nbsp;is&nbsp;an&nbsp;example&nbsp;on&nbsp;a&nbsp;table&nbsp;valued&nbsp;function.&nbsp;&nbsp;It&nbsp;returns&nbsp;a&nbsp;table&nbsp;variable.&nbsp;&nbsp;<br />In&nbsp;the&nbsp;function&nbsp;we&nbsp;insert,&nbsp;update,&nbsp;and&nbsp;delete&nbsp;from&nbsp;the&nbsp;table&nbsp;variable.&nbsp;&nbsp;<br /><strong>You&nbsp;cannot&nbsp;create&nbsp;a&nbsp;temp&nbsp;table,&nbsp;but&nbsp;table&nbsp;variables&nbsp;are&nbsp;OK.</strong><br /><br />CREATE&nbsp;FUNCTION&nbsp;FN_TEST()<br />RETURNS&nbsp;@table&nbsp;TABLE&nbsp;(<br />&nbsp;i&nbsp;<span style="color: #0000FF; ">int</span>,<br />&nbsp;j&nbsp;<span style="color: #0000FF; ">int</span>)<br />AS<br />BEGIN<br />&nbsp;<br />&nbsp;INSERT&nbsp;INTO&nbsp;@table<br />&nbsp;SELECT&nbsp;1,&nbsp;0<br />&nbsp;UNION&nbsp;ALL<br />&nbsp;SELECT&nbsp;2,&nbsp;2<br />&nbsp;&nbsp;<br />&nbsp;UPDATE&nbsp;@table<br />&nbsp;SET&nbsp;j&nbsp;=&nbsp;1<br />&nbsp;&nbsp;<br />&nbsp;DELETE&nbsp;@table<br />&nbsp;WHERE&nbsp;i&nbsp;=&nbsp;1<br />&nbsp;&nbsp;<br />&nbsp;RETURN<br />&nbsp;&nbsp;<br />END<br /><br />If&nbsp;you&nbsp;<span style="color: #0000FF; ">try</span>&nbsp;<span style="color: #0000FF; ">this</span>&nbsp;function&nbsp;yourself,&nbsp;you&nbsp;will&nbsp;see&nbsp;that&nbsp;it&nbsp;compiles&nbsp;and&nbsp;executes&nbsp;with&nbsp;no&nbsp;problem.&nbsp;<br /><strong>Operators&nbsp;used&nbsp;on&nbsp;table&nbsp;variables&nbsp;are&nbsp;not&nbsp;considered&nbsp;side-effecting&nbsp;operators.</strong><br /><br /><strong style="font-size: 12pt;">Time-Dependent&nbsp;Operators</strong><br />You&nbsp;will&nbsp;also&nbsp;receive&nbsp;Msg&nbsp;443&nbsp;<span style="color: #0000FF; ">if</span>&nbsp;you&nbsp;use&nbsp;time-dependent&nbsp;operators&nbsp;in&nbsp;a&nbsp;function.&nbsp;&nbsp;<br />Time-dependent&nbsp;operators&nbsp;are&nbsp;those&nbsp;which&nbsp;<span style="color: #0000FF; ">return</span>&nbsp;a&nbsp;value&nbsp;based&nbsp;on&nbsp;the&nbsp;time.&nbsp;&nbsp;<br />This&nbsp;include,&nbsp;but&nbsp;are&nbsp;not&nbsp;limited&nbsp;to&nbsp;GETDATE(),&nbsp;SYSDATETIME(),&nbsp;NEWID(),&nbsp;and&nbsp;RAND().&nbsp;&nbsp;<br />This&nbsp;is&nbsp;because&nbsp;functions&nbsp;should&nbsp;to&nbsp;<span style="color: #0000FF; ">return</span>&nbsp;the&nbsp;same&nbsp;value&nbsp;when&nbsp;provided&nbsp;with&nbsp;the&nbsp;same&nbsp;set&nbsp;of&nbsp;inputs.&nbsp;&nbsp;<br />Since&nbsp;these&nbsp;functions&nbsp;<span style="color: #0000FF; ">return</span>&nbsp;a&nbsp;different&nbsp;value&nbsp;each&nbsp;time,&nbsp;they&nbsp;are&nbsp;not&nbsp;allowed.&nbsp;<br />There&nbsp;is&nbsp;one&nbsp;solution&nbsp;to&nbsp;part&nbsp;of&nbsp;<span style="color: #0000FF; ">this</span>&nbsp;problem.&nbsp;&nbsp;If&nbsp;you&nbsp;wish&nbsp;to&nbsp;use&nbsp;a&nbsp;date&nbsp;or&nbsp;an&nbsp;id,&nbsp;you&nbsp;can&nbsp;provide&nbsp;it&nbsp;to&nbsp;the&nbsp;function.&nbsp;&nbsp;<br />You&nbsp;could&nbsp;pass&nbsp;NEWID()&nbsp;or&nbsp;GETDATE()&nbsp;as&nbsp;the&nbsp;value&nbsp;of&nbsp;a&nbsp;parameter&nbsp;sent&nbsp;to&nbsp;the&nbsp;function.&nbsp;&nbsp;<br />If&nbsp;you&nbsp;need&nbsp;to&nbsp;use&nbsp;time-dependent&nbsp;operators&nbsp;multiple&nbsp;times,&nbsp;you&nbsp;can&#8217;t&nbsp;use&nbsp;a&nbsp;function.</div><img src ="http://www.blogjava.net/crazycy/aggbug/405643.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/crazycy/" target="_blank">crazycy</a> 2013-10-25 18:24 <a href="http://www.blogjava.net/crazycy/archive/2013/10/25/405643.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>The database principal owns a schema in the database, and cannot be dropped</title><link>http://www.blogjava.net/crazycy/archive/2013/07/11/401471.html</link><dc:creator>crazycy</dc:creator><author>crazycy</author><pubDate>Thu, 11 Jul 2013 09:34:00 GMT</pubDate><guid>http://www.blogjava.net/crazycy/archive/2013/07/11/401471.html</guid><wfw:comment>http://www.blogjava.net/crazycy/comments/401471.html</wfw:comment><comments>http://www.blogjava.net/crazycy/archive/2013/07/11/401471.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/crazycy/comments/commentRss/401471.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/crazycy/services/trackbacks/401471.html</trackback:ping><description><![CDATA[Use UI to configure database, also checked some items in schema;<br />while delete this user, an error encounter like this:&nbsp;<span style="color: #ff0000; font-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif; line-height: 22.99715805053711px; text-align: justify; background-color: #ffffff;">The database principal owns a schema in the database, and cannot be dropped. (Microsoft SQL Server, Error: 15138)</span><br />&nbsp;<br />but use the below script, I successfully removed;<br /><div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><span style="color: #0000FF; ">SELECT</span>&nbsp;s.name<br /><span style="color: #0000FF; ">FROM</span>&nbsp;sys.schemas&nbsp;s<br /><span style="color: #0000FF; ">WHERE</span>&nbsp;s.principal_id&nbsp;<span style="color: #808080; ">=</span>&nbsp;<span style="color: #FF00FF; ">USER_ID</span>(<span style="color: #FF0000; ">'</span><span style="color: #FF0000; ">YourUserID</span><span style="color: #FF0000; ">'</span>);</div><br />find all the schemas to be removed<br /><div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><span style="color: #0000FF; ">ALTER</span>&nbsp;<span style="color: #0000FF; ">AUTHORIZATION</span>&nbsp;<span style="color: #0000FF; ">ON</span>&nbsp;<span style="color: #0000FF; ">SCHEMA</span>::YourSchemaName&nbsp;<span style="color: #0000FF; ">TO</span>&nbsp;dbo;</div><img src ="http://www.blogjava.net/crazycy/aggbug/401471.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/crazycy/" target="_blank">crazycy</a> 2013-07-11 17:34 <a href="http://www.blogjava.net/crazycy/archive/2013/07/11/401471.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>SQLServer Create Login/Create User/Grant Privildges to a userName</title><link>http://www.blogjava.net/crazycy/archive/2013/07/11/401448.html</link><dc:creator>crazycy</dc:creator><author>crazycy</author><pubDate>Thu, 11 Jul 2013 04:52:00 GMT</pubDate><guid>http://www.blogjava.net/crazycy/archive/2013/07/11/401448.html</guid><wfw:comment>http://www.blogjava.net/crazycy/comments/401448.html</wfw:comment><comments>http://www.blogjava.net/crazycy/archive/2013/07/11/401448.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/crazycy/comments/commentRss/401448.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/crazycy/services/trackbacks/401448.html</trackback:ping><description><![CDATA[<p style="margin-bottom:12.0pt;text-indent:0cm;line-height: 13.5pt;vertical-align:baseline"><span style="font-size: 10pt; font-family: Verdana, sans-serif;">above refer to&nbsp;<a href="http://stackoverflow.com/questions/3998634/sql-server-2008-how-do-i-grant-privileges-to-a-username"><span style="color:blue">uri<br /> </span></a></span></p>  <p style="margin-bottom:12.0pt;text-indent:0cm;line-height: 13.5pt;vertical-align:baseline"><span style="font-size: 10pt; font-family: Verdana, sans-serif;">If you want to give your user all read permissions, you could use:</span></p>  <p style="margin-bottom:7.5pt;text-indent:0cm;line-height:13.5pt; background:#EEEEEE;vertical-align:baseline"><span style="font-size: 10pt; font-family: Consolas;">EXEC sp_addrolemember N'db_datareader', N'your-user-name'</span></p>  <p style="text-indent:0cm;line-height:13.5pt;vertical-align: baseline"><span style="font-size: 10pt; font-family: Verdana, sans-serif;">That adds the default&nbsp;</span><span style="font-size: 10pt; font-family: Consolas;">db_datareader</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;">&nbsp;role (read permission on all tables) to that user.</span></p>  <p style="text-indent:0cm;line-height:13.5pt;vertical-align: baseline"><span style="font-size: 10pt; font-family: Verdana, sans-serif;">There's also a&nbsp;</span><span style="font-size: 10pt; font-family: Consolas;">db_datawriter</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;">&nbsp;role - which gives your user all WRITE permissions (INSERT, UPDATE, DELETE) on all tables:</span></p>  <p style="margin-bottom:7.5pt;text-indent:0cm;line-height:13.5pt; background:#EEEEEE;vertical-align:baseline"><span style="font-size: 10pt; font-family: Consolas;">EXEC sp_addrolemember N'db_datawriter', N'your-user-name'</span></p>  <p style="text-indent:0cm;line-height:13.5pt;vertical-align: baseline">&nbsp;</p>  <p style="text-indent:0cm;line-height:13.5pt;vertical-align: baseline"><span style="font-size: 10pt; font-family: Verdana, sans-serif;">If you need to be more granular, you can use the&nbsp;</span><span style="font-size: 10pt; font-family: Consolas;">GRANT</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;">&nbsp;command:</span></p>  <p style="margin-bottom:7.5pt;text-indent:0cm;line-height:13.5pt; background:#EEEEEE;vertical-align:baseline"><span style="font-size: 10pt; font-family: Consolas;">GRANT SELECT, INSERT, UPDATE ON dbo.YourTable TO YourUserName <br /> GRANT SELECT, INSERT ON dbo.YourTable2 TO YourUserName <br /> GRANT SELECT, DELETE ON dbo.YourTable3 TO YourUserName</span></p>  <p style="text-indent:0cm;line-height:13.5pt;vertical-align: baseline"><span style="font-size: 10pt; font-family: Verdana, sans-serif;">and so forth - you can granularly give SELECT, INSERT, UPDATE, DELETE permission on specific tables.&nbsp;</span></p>  <p style="margin-bottom:12.0pt;text-indent:0cm;line-height: 13.5pt;vertical-align:baseline"><span style="font-size: 10pt; font-family: Verdana, sans-serif;"><br /> <br /> by me:</span></p>  <p style="margin-bottom:12.0pt;text-indent:0cm;line-height: 13.5pt;vertical-align:baseline"><span style="font-size: 10pt; font-family: Verdana, sans-serif;">If you want to give your user permissions to execute a procedure, you could use:</span></p>  <p style="text-indent:0cm;line-height:13.5pt; background:#EEEEEE;vertical-align:baseline"><span style="font-size: 10pt; font-family: Consolas;">GRANT EXECUTE ON OBJECT::dbo.your_procedure_name TO N'your-user-name';</span></p>  <p style="margin-bottom:12.0pt;text-indent:0cm;line-height: 13.5pt;vertical-align:baseline"><span style="font-size: 10pt; font-family: Verdana, sans-serif;">below is a full step to create a user db_user, and give him permissions to execute a procedure to a table&nbsp;<em>db_tableABC</em>&nbsp;and a procedure<em>proc_get_price_data;</em>&nbsp;assuming the user's&nbsp;loginName is<em>&nbsp;your_user_login_name</em></span></p>  <p style="margin-bottom:7.5pt;text-indent:0cm;line-height:13.5pt; background:#EEEEEE;vertical-align:baseline"><span style="font-size: 10pt; font-family: Consolas;">--<a href="http://msdn.microsoft.com/en-us/library/ms189751.aspx"><span style="color:blue">add a db engine login</span></a></span></p>  <p style="margin-bottom: 7.5pt; text-indent: 0cm; line-height: 13.5pt; background-color: #eeeeee; vertical-align: baseline; background-position: initial initial; background-repeat: initial initial;"><span style="font-size: 10pt; font-family: Consolas;">IF NOT EXISTS(SELECT name FROM sys.server_principals WHERE name='{your_domain\}your_user_login_name') <br /> CREATE LOGIN [{your_domain\}your_user_login_name] WITH PASSWORD='your_user_password'</span><span style="font-size:10.0pt;font-family: Courier;Times New Roman&quot;; color:midnightblue;background:whitesmoke">, DEFAULT_DATABASE = TestDB</span><span style="font-size: 10pt; font-family: Consolas;">;<br /><br /></span><span style="font-family: Consolas; font-size: 10pt; line-height: 13.5pt;">--</span><span style="font-family: Consolas; font-size: 10pt; line-height: 13.5pt; color: blue;"><a href="http://msdn.microsoft.com/en-us/library/ms173463.aspx" style="font-family: Consolas; font-size: 10pt; line-height: 13.5pt;">add a user to current database<br /></a></span><span style="font-family: Consolas; font-size: 10pt; line-height: 13.5pt;">use TestDB;<br /></span><span style="line-height: 13.5pt; font-size: 10pt; font-family: Consolas;">IF NOT EXISTS (SELECT * FROM sys.database_principals WHERE name='db</span><em style="line-height: 13.5pt; font-size: 14px;"><span style="font-size: 10pt; font-family: Verdana, sans-serif;">_user'</span></em><span style="line-height: 13.5pt; font-size: 10pt; font-family: Consolas;">)<br /></span><span style="line-height: 13.5pt; font-size: 10pt; font-family: Consolas;">CREATE USER [db</span><em style="line-height: 13.5pt; font-size: 14px;"><span style="font-size: 10pt; font-family: Verdana, sans-serif;">_user</span></em><span style="line-height: 13.5pt; font-size: 10pt; font-family: Consolas;">] FOR LOGIN [{your_domain\}your_user_login_name];<br /><br /></span><span style="font-family: Consolas; font-size: 10pt; line-height: 13.5pt;">--</span><span style="font-family: Consolas; font-size: 10pt; line-height: 13.5pt; color: blue;"><a href="http://msdn.microsoft.com/en-us/library/ms178640.aspx" style="font-family: Consolas; font-size: 10pt; line-height: 13.5pt;">grant<br /></a></span><span style="line-height: 13.5pt; font-size: 10pt; font-family: Consolas;">GRANT INSERT, UPDATE, SELECT, DELETE ON dbo.</span><em style="line-height: 13.5pt; font-size: 14px;"><span style="font-size: 10pt; font-family: Verdana, sans-serif;">db_tableABC</span></em><span style="line-height: 13.5pt; font-size: 10pt; font-family: Consolas;">&nbsp;TO </span><em style="line-height: 13.5pt; font-size: 14px;"><span style="font-size: 10pt; font-family: Verdana, sans-serif;">your_user</span></em><span style="line-height: 13.5pt; font-size: 10pt; font-family: Consolas;">;<br /></span><span style="line-height: 13.5pt; font-size: 10pt; font-family: Consolas;">GRANT EXECUTE ON OBJECT::dbo.</span><em style="line-height: 13.5pt; font-size: 14px;"><span style="font-size: 10pt; font-family: Verdana, sans-serif;">proc_get_price_data&nbsp;</span></em><span style="line-height: 13.5pt; font-size: 10pt; font-family: Consolas;">TO </span><em style="line-height: 13.5pt; font-size: 14px;"><span style="font-size: 10pt; font-family: Verdana, sans-serif;">your_user</span></em><span style="line-height: 13.5pt; font-size: 10pt; font-family: Consolas;">;<br /></span><br /></p>  <p style="margin-bottom:7.5pt;text-indent:0cm;line-height:13.5pt; background:#EEEEEE;vertical-align:baseline"><span style="font-family: Consolas;">e.g.</span><br /><span style="font-size: 10pt; font-family: Consolas;">assuming a user named domain123\admin1 can access a database;<br /> <br /> IF EXISTS(SELECT name FROM sys.server_principals WHERE name = '[domain123\admin1]') <br /> BEGIN &nbsp;&nbsp; <br /> &nbsp;&nbsp; IF NOT EXISTS (SELECT * FROM sys.database_principals WHERE name = 'admin1') &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br /> &nbsp;&nbsp; BEGIN &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;CREATE USER [admin1] FOR LOGIN [domain123\admin1];&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br /> &nbsp;&nbsp; END<br /> &nbsp;&nbsp; GRANT INSERT, UPDATE, SELECT, DELETE ON dbo.</span><span style="font-size: 10pt; font-family: Verdana, sans-serif;">db_tableABC</span><span style="font-size: 10pt; font-family: Consolas;">&nbsp;TO admin1;&nbsp;&nbsp; <br /> &nbsp;&nbsp; GRANT EXECUTE ON OBJECT::dbo.GET_PRICE_DATA TO admin1; <br /> END</span></p><img src ="http://www.blogjava.net/crazycy/aggbug/401448.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/crazycy/" target="_blank">crazycy</a> 2013-07-11 12:52 <a href="http://www.blogjava.net/crazycy/archive/2013/07/11/401448.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>SQL2008R2: A network error occurred while attempting to read from the file C:..\..\sqlncli.msi</title><link>http://www.blogjava.net/crazycy/archive/2013/06/19/400752.html</link><dc:creator>crazycy</dc:creator><author>crazycy</author><pubDate>Wed, 19 Jun 2013 14:24:00 GMT</pubDate><guid>http://www.blogjava.net/crazycy/archive/2013/06/19/400752.html</guid><wfw:comment>http://www.blogjava.net/crazycy/comments/400752.html</wfw:comment><comments>http://www.blogjava.net/crazycy/archive/2013/06/19/400752.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/crazycy/comments/commentRss/400752.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/crazycy/services/trackbacks/400752.html</trackback:ping><description><![CDATA[客户现场，安装sqlserver 2008R2；因为情景需要，客户指定了一架在用的笔记本在预演。<br /><br />突然遭遇了从来没有的问题：<span style="font-size: 14px;">A network error occurred while attempting to read from the file C:..\..\sqlncli.msi &nbsp;如图。<br /><br />因为距离下班时间很近了，很着急也很恼火，捣鼓来捣鼓去，最后打开了控制面板，一看，妈呀好多SQL Server的东东，挨着删除吧。。。居然就可以安装了了。。。。<br /><br />最终发现如果任何 SQLNCLI或者Native Client存在了，就会出现这个问题。<br />Microsoft大哥居然弄了这么黑的一招。。。<br /><br />同时看到有人遭遇了类似的悲剧：<br /></span><div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />-->Finally&nbsp;got&nbsp;the&nbsp;Client&nbsp;Tools&nbsp;and&nbsp;Mangement&nbsp;Studio&nbsp;installed.&nbsp;What&nbsp;I&nbsp;did&nbsp;was&nbsp;remove&nbsp;Microsoft&nbsp;SQL&nbsp;Server&nbsp;2008&nbsp;Native&nbsp;Client&nbsp;in&nbsp;Add&nbsp;or&nbsp;Remove&nbsp;Programs&nbsp;(before&nbsp;I&nbsp;was&nbsp;just&nbsp;trying&nbsp;to&nbsp;uninstall&nbsp;Microsoft&nbsp;SQL&nbsp;Server&nbsp;2008&nbsp;and&nbsp;it&nbsp;failed).&nbsp;After&nbsp;Native&nbsp;Client&nbsp;was&nbsp;removed,&nbsp;I&nbsp;reinstalled&nbsp;client&nbsp;tools&nbsp;and&nbsp;mangement&nbsp;studio&nbsp;from&nbsp;a&nbsp;dvd&nbsp;(was&nbsp;mounting&nbsp;the&nbsp;iso&nbsp;before).&nbsp;Everything&nbsp;installed&nbsp;perfectly.</div><span style="font-size: 14px;"><br />这个人解释的更多：<br /></span><div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />-->The&nbsp;cause&nbsp;of&nbsp;the&nbsp;error<img src="http://www.blogjava.net/Images/dot.gif" alt="" /><br />I&nbsp;wondered&nbsp;what&nbsp;was&nbsp;different&nbsp;between&nbsp;my&nbsp;clean&nbsp;test-VM&nbsp;and&nbsp;my&nbsp;server&nbsp;that&nbsp;I&nbsp;was&nbsp;now&nbsp;attempting&nbsp;to&nbsp;install&nbsp;SQL-SERVER&nbsp;2008&nbsp;R2&nbsp;Client&nbsp;Tools&nbsp;and&nbsp;SSMS&nbsp;onto.&nbsp;&nbsp;Both&nbsp;were&nbsp;64-Bit&nbsp;OS's&nbsp;and&nbsp;same&nbsp;setup,&nbsp;etc.,&nbsp;but&nbsp;one&nbsp;was&nbsp;a&nbsp;clean&nbsp;VM.&nbsp;&nbsp;This&nbsp;got&nbsp;me&nbsp;thinking<img src="http://www.blogjava.net/Images/dot.gif" alt="" /><br /><br />I&nbsp;had&nbsp;PREVIOUSLY&nbsp;installed&nbsp;JUST&nbsp;the&nbsp;SQLNCLI&nbsp;(SQL-Server&nbsp;Native&nbsp;Client)&nbsp;<span style="color: #0000FF; ">for</span>&nbsp;SQL&nbsp;2008&nbsp;R2&nbsp;onto&nbsp;my&nbsp;physical&nbsp;system,&nbsp;in&nbsp;order&nbsp;to&nbsp;test&nbsp;application&nbsp;connectivity&nbsp;to&nbsp;a&nbsp;SQL2008R2&nbsp;database.&nbsp;&nbsp;So,&nbsp;could&nbsp;that&nbsp;be&nbsp;it!?&nbsp;&nbsp;YES!&nbsp;&nbsp;After&nbsp;uninstalling&nbsp;any&nbsp;previously&nbsp;installed&nbsp;SQLNCLI&nbsp;applications,&nbsp;and&nbsp;re-running&nbsp;the&nbsp;SQL-Server&nbsp;installer,&nbsp;amazingly&nbsp;my&nbsp;"network&nbsp;errors"&nbsp;were&nbsp;gone&nbsp;and&nbsp;the&nbsp;installation&nbsp;was&nbsp;fixed!&nbsp;&nbsp;<br /><br />Microsoft:&nbsp;GIVE&nbsp;MEANINGFUL&nbsp;ERROR&nbsp;MESSAGES!&nbsp;&nbsp;All&nbsp;the&nbsp;installer&nbsp;had&nbsp;to&nbsp;<span style="color: #0000FF; ">do</span>&nbsp;was&nbsp;say&nbsp;that&nbsp;"previous&nbsp;installations&nbsp;of&nbsp;SQLNCLI&nbsp;/&nbsp;native&nbsp;client&nbsp;exist&nbsp;and&nbsp;must&nbsp;be&nbsp;removed&nbsp;before&nbsp;installing"<img src="http://www.blogjava.net/Images/dot.gif" alt="" />&nbsp;in&nbsp;fact,&nbsp;the&nbsp;PREREQUISITES-CHECK&nbsp;SHOULD&nbsp;HAVE&nbsp;TESTED&nbsp;FOR&nbsp;THIS&nbsp;<span style="color: #0000FF; ">if</span>&nbsp;it&nbsp;can&nbsp;cause&nbsp;a&nbsp;total&nbsp;failure&nbsp;to&nbsp;install!&nbsp;&nbsp;</div><img src ="http://www.blogjava.net/crazycy/aggbug/400752.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/crazycy/" target="_blank">crazycy</a> 2013-06-19 22:24 <a href="http://www.blogjava.net/crazycy/archive/2013/06/19/400752.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>数据库触发器Trigger或者存储过程Procedure的调试技巧</title><link>http://www.blogjava.net/crazycy/archive/2013/04/10/397659.html</link><dc:creator>crazycy</dc:creator><author>crazycy</author><pubDate>Wed, 10 Apr 2013 12:05:00 GMT</pubDate><guid>http://www.blogjava.net/crazycy/archive/2013/04/10/397659.html</guid><wfw:comment>http://www.blogjava.net/crazycy/comments/397659.html</wfw:comment><comments>http://www.blogjava.net/crazycy/archive/2013/04/10/397659.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/crazycy/comments/commentRss/397659.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/crazycy/services/trackbacks/397659.html</trackback:ping><description><![CDATA[use Print<br /><div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><span style="color: #0000FF; ">PRINT</span>&nbsp;<span style="color: #FF0000; ">'</span><span style="color: #FF0000; ">testing----</span><span style="color: #FF0000; ">'</span>&nbsp;<span style="color: #0000FF; ">WAITFOR</span>&nbsp;DELAY&nbsp;<span style="color: #FF0000; ">'</span><span style="color: #FF0000; ">00:00:05</span><span style="color: #FF0000; ">'</span>;</div>程序中调用这个procedure或者触发这个trigger，java控制台根本没有这个输出；<br />很生气，后果很严重的让时间飞逝。<br /><br />网上众多大拿推荐使用Raiserror，于是<br /><div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><span style="color: #0000FF; ">raiserror</span>&nbsp;(<span style="color: #FF0000; ">'</span><span style="color: #FF0000; ">test&nbsp;raiserror&nbsp;1---</span><span style="color: #FF0000; ">'</span>,&nbsp;<span style="color: #800000; font-weight: bold; ">10</span>,&nbsp;<span style="color: #808080; ">-</span><span style="color: #800000; font-weight: bold; ">1</span>)&nbsp;<span style="color: #0000FF; ">with</span>&nbsp;<span style="color: #ff00ff;">log</span><br /><br /><span style="color: #0000FF; ">raiserror</span>&nbsp;(<span style="color: #FF0000; ">'</span><span style="color: #FF0000; ">test&nbsp;raiserror&nbsp;2---</span><span style="color: #FF0000; ">'</span>,&nbsp;<span style="color: #800000; font-weight: bold; ">10</span>,&nbsp;<span style="color: #800000; font-weight: bold; ">1</span>)&nbsp;<span style="color: #0000FF; ">with</span>&nbsp;nowait</div>程序中调用这个procedure或者触发这个trigger，java控制台根本没有这个输出；<br />很生气，后果很严重的让时间飞逝。<br /><br />于是，很无语胡乱的测试：<br /><div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><span style="color: #0000FF; ">raiserror</span>&nbsp;(<span style="color: #FF0000; ">'</span><span style="color: #FF0000; ">test&nbsp;raiserror&nbsp;3---</span><span style="color: #FF0000; ">'</span>,&nbsp;<span style="color: #800000; font-weight: bold; ">16</span>,<span style="color: #808080; ">-</span><span style="color: #800000; font-weight: bold; ">1</span>)&nbsp;<span style="color: #0000FF; ">with</span>&nbsp;<span style="color: #FF00FF; ">log</span>;<br /><span style="color: #0000FF; ">raiserror</span>&nbsp;(<span style="color: #FF0000; ">'</span><span style="color: #FF0000; ">test&nbsp;raiserror&nbsp;4---</span><span style="color: #FF0000; ">'</span>,&nbsp;<span style="color: #800000; font-weight: bold; ">16</span>,<span style="color: #808080; ">-</span><span style="color: #800000; font-weight: bold; ">1</span>)&nbsp;<span style="color: #0000FF; ">with</span>&nbsp;nowait;</div>任何一条都输出并且让程序回滚，很好很好<br /><br />我得找到这个原因：<br />翻翻<a href="http://msdn.microsoft.com/en-us/library/ms177497.aspx">MSDN</a>吧：<br /><div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />-->&nbsp;A&nbsp;<span style="color: #0000FF; ">RAISERROR</span>&nbsp;severity&nbsp;<span style="color: #0000FF; ">of</span>&nbsp;<span style="color: #800000; font-weight: bold; ">11</span>&nbsp;<span style="color: #0000FF; ">to</span>&nbsp;<span style="color: #800000; font-weight: bold; ">19</span>&nbsp;executed&nbsp;<span style="color: #808080; ">in</span>&nbsp;the&nbsp;TRY&nbsp;block&nbsp;<span style="color: #0000FF; ">of</span>&nbsp;a&nbsp;TRY&#8230;CATCH&nbsp;construct&nbsp;causes&nbsp;control&nbsp;<span style="color: #0000FF; ">to</span>&nbsp;transfer&nbsp;<span style="color: #0000FF; ">to</span>&nbsp;the&nbsp;associated&nbsp;CATCH&nbsp;block.&nbsp;Specify&nbsp;a&nbsp;severity&nbsp;<span style="color: #0000FF; ">of</span>&nbsp;<span style="color: #800000; font-weight: bold; ">10</span>&nbsp;<span style="color: #808080; ">or</span>&nbsp;<span style="color: #FF00FF; ">lower</span>&nbsp;<span style="color: #0000FF; ">to</span>&nbsp;<span style="color: #0000FF; ">return</span>&nbsp;messages&nbsp;using&nbsp;<span style="color: #0000FF; ">RAISERROR</span>&nbsp;without&nbsp;invoking&nbsp;a&nbsp;CATCH&nbsp;block.&nbsp;<span style="color: #0000FF; ">PRINT</span>&nbsp;does&nbsp;<span style="color: #808080; ">not</span>&nbsp;transfer&nbsp;control&nbsp;<span style="color: #0000FF; ">to</span>&nbsp;a&nbsp;CATCH&nbsp;block.</div>好吧，10以上的数字才会强迫它工作。<br /><br />但是呢，为了不抛错误，我们可以做以下2种方案：<br />方案一：<br /><div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />-->建立tmp表，利用insert保存你要的结果</div>方案二：<br />不知道try catch是不是能帮上忙，就留在下回测试吧。<br /><br />f<div></div><img src ="http://www.blogjava.net/crazycy/aggbug/397659.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/crazycy/" target="_blank">crazycy</a> 2013-04-10 20:05 <a href="http://www.blogjava.net/crazycy/archive/2013/04/10/397659.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>SQL Server: SYSOBJECTS</title><link>http://www.blogjava.net/crazycy/archive/2012/12/31/393651.html</link><dc:creator>crazycy</dc:creator><author>crazycy</author><pubDate>Mon, 31 Dec 2012 05:04:00 GMT</pubDate><guid>http://www.blogjava.net/crazycy/archive/2012/12/31/393651.html</guid><wfw:comment>http://www.blogjava.net/crazycy/comments/393651.html</wfw:comment><comments>http://www.blogjava.net/crazycy/archive/2012/12/31/393651.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/crazycy/comments/commentRss/393651.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/crazycy/services/trackbacks/393651.html</trackback:ping><description><![CDATA[<h3><a href="http://sqlservercode.blogspot.sg/2006/06/use-objectproperty-to-generate-list-of.html">Use OBJECTPROPERTY To Generate A List Of Object Types</a></h3><div style="margin: 0px 0px 0.75em; line-height: 1.6em; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: small; background-color: #ffffff;"><div style="margin: 0px 0px 0.75em; line-height: 1.6em;"><div style="margin: 0px 0px 0.75em; line-height: 1.6em; clear: both;"></div>How do you query the sysobjects system table and get the object type back for every single object<br />You can use the type and xtype columns, these contain the following data<br /><br /><strong>xtype</strong><br />Object type. Can be one of these object types:<br />C = CHECK constraint<br />D = Default or DEFAULT constraint<br />F = FOREIGN KEY constraint<br />L = Log<br />FN = Scalar function<br />IF = Inlined table-function<br />P = Stored procedure<br />PK = PRIMARY KEY constraint (type is K)<br />RF = Replication filter stored procedure<br />S = System table<br />TF = Table function<br />TR = Trigger<br />U = User table<br />UQ = UNIQUE constraint (type is K)<br />V = View<br />X = Extended stored procedure<br /><br /><br /><strong>type</strong><br />Object type. Can be one of these values:<br />C = CHECK constraint<br />D = Default or DEFAULT constraint<br />F = FOREIGN KEY constraint<br />FN = Scalar function<br />IF = Inlined table-function<br />K = PRIMARY KEY or UNIQUE constraint<br />L = Log<br />P = Stored procedure<br />R = Rule<br />RF = Replication filter stored procedure<br />S = System table<br />TF = Table function<br />TR = Trigger<br />U = User table<br />V = View<br />X = Extended stored procedure<br /><br />Or you can use OBJECTPROPERTY. OBJECTPROPERTY is better in my opinion because you can see right away what you are looking for<br />For example OBJECTPROPERTY ( id , 'IsUserTable' ) is much easier to understand than type = 'u'<br /><br />Bu using CASE with OBJECTPROPERTY we can generate a nice report<br /><br /><span style="color: #3333ff;">SELECT</span>&nbsp;name,<span style="color: #cc33cc;">CASE</span><br /><span style="color: #3333ff;">WHEN</span>&nbsp;<span style="color: #cc33cc;">OBJECTPROPERTY</span>&nbsp;( id ,&nbsp;<span style="color: #ff0000;">'IsSystemTable'</span>&nbsp;) =1&nbsp;<span style="color: #3333ff;">THEN</span>&nbsp;<span style="color: #ff0000;">'System Table'</span><br /><span style="color: #3333ff;">WHEN</span>&nbsp;<span style="color: #cc33cc;">OBJECTPROPERTY</span>&nbsp;( id ,&nbsp;<span style="color: #ff0000;">'IsProcedure'&nbsp;</span>) =1&nbsp;<span style="color: #3333ff;">THEN</span>&nbsp;<span style="color: #ff0000;">'Procedure'&nbsp;</span><br /><span style="color: #3333ff;">WHEN</span>&nbsp;<span style="color: #cc33cc;">OBJECTPROPERTY</span>&nbsp;( id ,&nbsp;<span style="color: #ff0000;">'IsPrimaryKey'</span>&nbsp;) =1&nbsp;<span style="color: #3333ff;">THEN</span>&nbsp;<span style="color: #ff0000;">'Primary Key'&nbsp;</span><br /><span style="color: #3333ff;">WHEN</span>&nbsp;<span style="color: #cc33cc;">OBJECTPROPERTY</span>&nbsp;( id ,&nbsp;<span style="color: #ff0000;">'IsDefault'</span>&nbsp;) =1&nbsp;<span style="color: #3333ff;">THEN</span>&nbsp;<span style="color: #ff0000;">'Default'</span><br /><span style="color: #3333ff;">WHEN</span>&nbsp;<span style="color: #cc33cc;">OBJECTPROPERTY</span>&nbsp;( id ,&nbsp;<span style="color: #ff0000;">'IsForeignKey'</span>&nbsp;) =1&nbsp;<span style="color: #3333ff;">THEN</span>&nbsp;<span style="color: #ff0000;">'Foreign Key'</span><br /><span style="color: #3333ff;">WHEN</span>&nbsp;<span style="color: #cc33cc;">OBJECTPROPERTY</span>&nbsp;( id ,&nbsp;<span style="color: #ff0000;">'IsCheckCnst'&nbsp;</span>) =1&nbsp;<span style="color: #3333ff;">THEN</span>&nbsp;<span style="color: #ff0000;">'Check Constraint'</span><br /><span style="color: #3333ff;">WHEN</span>&nbsp;<span style="color: #cc33cc;">OBJECTPROPERTY</span>&nbsp;( id ,&nbsp;<span style="color: #ff0000;">'IsView'&nbsp;</span>) =1&nbsp;<span style="color: #3333ff;">THEN</span>&nbsp;<span style="color: #ff0000;">'View'</span><br /><span style="color: #3333ff;">WHEN</span>&nbsp;<span style="color: #cc33cc;">OBJECTPROPERTY</span>&nbsp;( id ,&nbsp;<span style="color: #ff0000;">'IsConstraint'&nbsp;</span>) =1&nbsp;<span style="color: #3333ff;">THEN</span>&nbsp;<span style="color: #ff0000;">'Constraint'</span><br /><span style="color: #3333ff;">WHEN</span>&nbsp;<span style="color: #cc33cc;">OBJECTPROPERTY</span>&nbsp;( id ,&nbsp;<span style="color: #ff0000;">'IsTrigger'</span>&nbsp;) =1&nbsp;<span style="color: #3333ff;">THEN</span>&nbsp;<span style="color: #ff0000;">'Trigger'</span><br /><span style="color: #3333ff;">WHEN</span>&nbsp;<span style="color: #cc33cc;">OBJECTPROPERTY</span>&nbsp;( id ,&nbsp;<span style="color: #ff0000;">'IsScalarFunction'&nbsp;</span>) =1&nbsp;<span style="color: #3333ff;">THEN</span>&nbsp;<span style="color: #ff0000;">'Scalar Function'</span><br /><span style="color: #3333ff;">WHEN</span>&nbsp;<span style="color: #cc33cc;">OBJECTPROPERTY</span>&nbsp;( id ,&nbsp;<span style="color: #ff0000;">'IsTableFunction'&nbsp;</span>) =1&nbsp;<span style="color: #3333ff;">THEN</span>&nbsp;<span style="color: #ff0000;">'Table Valued Function'</span><br /><span style="color: #3333ff;">WHEN</span>&nbsp;<span style="color: #cc33cc;">OBJECTPROPERTY</span>&nbsp;( id ,&nbsp;<span style="color: #ff0000;">'IsRule'</span>&nbsp;) =1&nbsp;<span style="color: #3333ff;">THEN</span>&nbsp;<span style="color: #ff0000;">'Rule'</span><br /><span style="color: #3333ff;">WHEN</span>&nbsp;<span style="color: #cc33cc;">OBJECTPROPERTY</span>&nbsp;( id ,&nbsp;<span style="color: #ff0000;">'IsExtendedProc'</span>&nbsp;) =1&nbsp;<span style="color: #3333ff;">THEN</span>&nbsp;<span style="color: #ff0000;">'Extended Stored Procedure'</span><br /><span style="color: #3333ff;">WHEN</span>&nbsp;<span style="color: #cc33cc;">OBJECTPROPERTY</span>&nbsp;( id ,&nbsp;<span style="color: #ff0000;">'IsUserTable'&nbsp;</span>) =1&nbsp;<span style="color: #3333ff;">THEN</span>&nbsp;<span style="color: #ff0000;">'User Table'</span><br /><span style="color: #3333ff;">END</span>&nbsp;ObjectType, *<br /><span style="color: #3333ff;">FROM</span>&nbsp;<span style="color: #33cc00;">sysobjects</span><br /><br />And of course there are a bunch of INFORMATION_SCHEMA views that you can use to get some of the same information back<br /><br />SELECT * FROM INFORMATION_SCHEMA.CHECK_CONSTRAINTS<br />SELECT * FROM INFORMATION_SCHEMA.CONSTRAINT_TABLE_USAGE<br />SELECT * FROM INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS<br />SELECT * FROM INFORMATION_SCHEMA.TABLES<br />SELECT * FROM INFORMATION_SCHEMA.VIEWS<br />SELECT * FROM INFORMATION_SCHEMA.COLUMNS<br /><br /><br />for example, want to find a procedure and drop it.<br /><div>if exists (select * from dbo.sysobjects&nbsp;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;where id = object_id('dbo.PROC_HELLOWORLD')&nbsp;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;and OBJECTPROPERTY(id, 'IsProcedure') = 1)</div><div>drop procedure dbo.PROC_HELLOWORLD;</div><div><br />another a bit difficult example, want to find a UDF and drop it.<br /><div>if exists (select * from dbo.sysobjects<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;where id = object_id('dbo.FUN_HELLOWORLD)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; and type in ('FN', 'IF', 'TF', 'FS', 'FT'))</div><div>DROP FUNCTION dbo.FUN_HELLOWORLD</div><br /></div><div></div></div></div><img src ="http://www.blogjava.net/crazycy/aggbug/393651.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/crazycy/" target="_blank">crazycy</a> 2012-12-31 13:04 <a href="http://www.blogjava.net/crazycy/archive/2012/12/31/393651.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>SQLSERVER: ROWS TO COLUMNS 行转列 （二） </title><link>http://www.blogjava.net/crazycy/archive/2012/10/04/389004.html</link><dc:creator>crazycy</dc:creator><author>crazycy</author><pubDate>Wed, 03 Oct 2012 17:33:00 GMT</pubDate><guid>http://www.blogjava.net/crazycy/archive/2012/10/04/389004.html</guid><wfw:comment>http://www.blogjava.net/crazycy/comments/389004.html</wfw:comment><comments>http://www.blogjava.net/crazycy/archive/2012/10/04/389004.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.blogjava.net/crazycy/comments/commentRss/389004.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/crazycy/services/trackbacks/389004.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: Just done by me based on the previous article: SQLServer: Rows to columnsUse table&nbsp;Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->CREATE&nbsp;TA...&nbsp;&nbsp;<a href='http://www.blogjava.net/crazycy/archive/2012/10/04/389004.html'>阅读全文</a><img src ="http://www.blogjava.net/crazycy/aggbug/389004.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/crazycy/" target="_blank">crazycy</a> 2012-10-04 01:33 <a href="http://www.blogjava.net/crazycy/archive/2012/10/04/389004.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>非常有意思的sql排错</title><link>http://www.blogjava.net/crazycy/archive/2008/04/08/191534.html</link><dc:creator>crazycy</dc:creator><author>crazycy</author><pubDate>Tue, 08 Apr 2008 10:30:00 GMT</pubDate><guid>http://www.blogjava.net/crazycy/archive/2008/04/08/191534.html</guid><wfw:comment>http://www.blogjava.net/crazycy/comments/191534.html</wfw:comment><comments>http://www.blogjava.net/crazycy/archive/2008/04/08/191534.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/crazycy/comments/commentRss/191534.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/crazycy/services/trackbacks/191534.html</trackback:ping><description><![CDATA[<div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
--><span style="color: #000000;">1)&nbsp; 你看出区别在哪里了么？ 结果会一样么？<br />
SELECT<br />
(select&nbsp;first&nbsp;</span><span style="color: #000000;">1</span><span style="color: #000000;">&nbsp;longname&nbsp;from&nbsp;ivctrallocpurch&nbsp;a&nbsp;join&nbsp;jcivloc&nbsp;l&nbsp; on&nbsp;a.ivlocid</span><span style="color: #000000;">=</span><span style="color: #000000;">l.ivlocid&nbsp;and&nbsp;a.ctrid</span><span style="color: #000000;">=</span><span style="color: #000000;">A.ctrid)&nbsp;as&nbsp;mill<br />
FROM&nbsp;CTR&nbsp;A<br />
JOIN&nbsp;CTRSMRY&nbsp;CS&nbsp;ON&nbsp;(A.CTRID</span><span style="color: #000000;">=</span><span style="color: #000000;">CS.CTRID)<br />
WHERE&nbsp;A.CTRID</span><span style="color: #000000;">=3161</span><span style="color: #000000;"><br />
</span></div>
和<br />
<div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
--><span style="color: #000000;">SELECT<br />
(select&nbsp;first&nbsp;</span><span style="color: #000000;">1</span><span style="color: #000000;">&nbsp;longname&nbsp;from&nbsp;ivctrallocpurch&nbsp;a&nbsp;join&nbsp;jcivloc&nbsp;l&nbsp;&nbsp;on&nbsp;a.ivlocid</span><span style="color: #000000;">=</span><span style="color: #000000;">l.ivlocid&nbsp;and&nbsp;a.ctrid</span><span style="color: #000000;">=</span><span style="color: #000000;">3161</span><span style="color: #000000;">)&nbsp;as&nbsp;mill<br />
FROM&nbsp;CTR&nbsp;A<br />
JOIN&nbsp;CTRSMRY&nbsp;CS&nbsp;ON&nbsp;(A.CTRID</span><span style="color: #000000;">=</span><span style="color: #000000;">CS.CTRID)<br />
WHERE&nbsp;A.CTRID</span><span style="color: #000000;">=</span><span style="color: #000000;">3161</span></div>
结果为什么不一样呢？<br />
<br />
<br />
2） Integer overflow. The result of an integer operation caused the most significant bit of the result to carry.<br />
<div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
--><span style="color: #000000;">select&nbsp;sum(rcpt.artothome&nbsp;</span><span style="color: #000000;">*</span><span style="color: #000000;"> rate</span><span style="color: #000000;">)&nbsp;as amt<br />
from cashreceipt rcpt<br />
join homerate rate on rcpt.currencyid=rate.currencyid</span></div>
分析：<br />
<div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
--><span style="color: #000000;">artothome&nbsp;@&nbsp;arheader&nbsp;&nbsp;is&nbsp;:&nbsp;numeric(</span><span style="color: #000000;">18</span><span style="color: #000000;">,</span><span style="color: #000000;">4</span><span style="color: #000000;">)<br />
rate&nbsp;@&nbsp;..&nbsp;&nbsp;is&nbsp;:&nbsp;numeric(</span><span style="color: #000000;">10</span><span style="color: #000000;">,</span><span style="color: #000000;">10</span><span style="color: #000000;">)</span></div>
<span style="color: #000000;">改进1 (not work)<br />
</span>
<div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
--><span style="color: #000000;">select&nbsp;sum(cast(rcpt.artothome&nbsp;</span><span style="color: #000000;">*</span><span style="color: #000000;">&nbsp;rate&nbsp;as&nbsp;numeric(</span><span style="color: #000000;">18</span><span style="color: #000000;">,</span><span style="color: #000000;">4</span><span style="color: #000000;">)))&nbsp;as&nbsp;amt<br />
from&nbsp;cashreceipt&nbsp;rcpt<br />
join&nbsp;homerate&nbsp;rate&nbsp;on&nbsp;rcpt.currencyid</span><span style="color: #000000;">=</span><span style="color: #000000;">rate.currencyid</span></div>
<span style="color: #000000;">改进2 (works)<br />
</span>
<div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
--><span style="color: #000000;">select&nbsp;sum(cast(cast(rcpt.artothome as numeric(18,4)) </span><span style="color: #000000;">*</span><span style="color: #000000;"> cast(rate as numeric(18,4)) as&nbsp;numeric(</span><span style="color: #000000;">18</span><span style="color: #000000;">,</span><span style="color: #000000;">4</span><span style="color: #000000;">)))&nbsp;as&nbsp;amt<br />
from&nbsp;cashreceipt&nbsp;rcpt<br />
join&nbsp;homerate&nbsp;rate&nbsp;on&nbsp;rcpt.currencyid</span><span style="color: #000000;">=</span><span style="color: #000000;">rate.currencyid</span></div>
reason, forward from http://www.firebirdfaq.org/faq207/<br />
<div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
--><span style="color: #000000;">Integer&nbsp;overflow.&nbsp;The&nbsp;result&nbsp;of&nbsp;an&nbsp;integer&nbsp;operation&nbsp;caused&nbsp;the&nbsp;most&nbsp;significant&nbsp;bit&nbsp;of&nbsp;the&nbsp;result&nbsp;to&nbsp;carry.<br />
</span><span style="color: #000000;"><br />
Short&nbsp;explanation:<br />
If&nbsp;you&nbsp;use&nbsp;fixed&nbsp;precision&nbsp;datatypes&nbsp;(smallint,&nbsp;integer,&nbsp;bigint,&nbsp;decimal&nbsp;and&nbsp;numeric),&nbsp;it&nbsp;is&nbsp;possible&nbsp;that&nbsp;the&nbsp;result&nbsp;of&nbsp;calculation&nbsp;doesn</span><span style="color: #000000;">'</span><span style="color: #000000;">t&nbsp;fit&nbsp;the&nbsp;datatype.&nbsp;Try&nbsp;casting&nbsp;the&nbsp;values&nbsp;in&nbsp;complex&nbsp;expressions&nbsp;as&nbsp;double&nbsp;precision&nbsp;and&nbsp;see&nbsp;whether&nbsp;the&nbsp;error&nbsp;goes&nbsp;away.&nbsp;If&nbsp;it&nbsp;works&nbsp;and&nbsp;you&nbsp;don</span><span style="color: #000000;">'</span><span style="color: #000000;">t&nbsp;care&nbsp;about&nbsp;being&nbsp;too&nbsp;precise,&nbsp;you&nbsp;can&nbsp;leave&nbsp;it&nbsp;at&nbsp;that.&nbsp;Otherwise&nbsp;you&nbsp;need&nbsp;to&nbsp;check&nbsp;every&nbsp;operation&nbsp;and&nbsp;calculate&nbsp;the&nbsp;result.<br />
<br />
Details:<br />
Here</span><span style="color: #000000;">'</span><span style="color: #000000;">s&nbsp;an&nbsp;example:&nbsp;if&nbsp;you&nbsp;multiply&nbsp;9.12&nbsp;with&nbsp;8.11&nbsp;(both&nbsp;numeric(18,2))&nbsp;you&nbsp;would&nbsp;get&nbsp;73.9632.&nbsp;If&nbsp;Firebird&nbsp;would&nbsp;store&nbsp;that&nbsp;into&nbsp;numeric(18,2)&nbsp;datatype,&nbsp;we&nbsp;would&nbsp;lose&nbsp;0.0032.&nbsp;Doesn</span><span style="color: #000000;">'</span><span style="color: #000000;">t&nbsp;look&nbsp;much,&nbsp;but&nbsp;when&nbsp;you&nbsp;have&nbsp;complex&nbsp;calculations,&nbsp;you&nbsp;can&nbsp;easily&nbsp;loose&nbsp;thousands&nbsp;(dollars&nbsp;or&nbsp;euros).&nbsp;Therefore,&nbsp;the&nbsp;result&nbsp;is&nbsp;stored&nbsp;in&nbsp;numeric(</span><span style="color: #000000;">18</span><span style="color: #000000;">,</span><span style="color: #000000;">4</span><span style="color: #000000;">).<br />
<br />
Problems&nbsp;are&nbsp;rarely&nbsp;seen&nbsp;with&nbsp;such&nbsp;low&nbsp;precision&nbsp;as&nbsp;</span><span style="color: #000000;">2</span><span style="color: #000000;">.&nbsp;Let</span><span style="color: #000000;">'</span><span style="color: #000000;">s&nbsp;use&nbsp;some&nbsp;bigger&nbsp;precision.&nbsp;For&nbsp;example,&nbsp;numeric(18,6)&nbsp;times&nbsp;numeric(18,6)&nbsp;yields&nbsp;numeric(18,12)&nbsp;result,&nbsp;meaning&nbsp;that&nbsp;maximal&nbsp;value&nbsp;it&nbsp;can&nbsp;store&nbsp;is&nbsp;9223372.036854775807.&nbsp;If&nbsp;(for&nbsp;example)&nbsp;you&nbsp;wish&nbsp;to&nbsp;keep&nbsp;only&nbsp;6&nbsp;digits&nbsp;of&nbsp;precision,&nbsp;you&nbsp;could&nbsp;use&nbsp;something&nbsp;like:</span><span style="color: #000000;"><br />
</span><span style="color: #000000;"><br />
cast(value1&nbsp;as&nbsp;numeric(</span><span style="color: #000000;">18</span><span style="color: #000000;">,</span><span style="color: #000000;">3</span><span style="color: #000000;">))&nbsp;</span><span style="color: #000000;">*</span><span style="color: #000000;">&nbsp;cast(value2&nbsp;as&nbsp;numeric(</span><span style="color: #000000;">18</span><span style="color: #000000;">,</span><span style="color: #000000;">3</span><span style="color: #000000;">))<br />
<br />
which&nbsp;would&nbsp;yield&nbsp;numeric(</span><span style="color: #000000;">18</span><span style="color: #000000;">,</span><span style="color: #000000;">6</span><span style="color: #000000;">)&nbsp;result,&nbsp;but&nbsp;it&nbsp;is&nbsp;quite&nbsp;possible&nbsp;that&nbsp;you&nbsp;would&nbsp;get&nbsp;more&nbsp;accurate&nbsp;result&nbsp;by&nbsp;casting&nbsp;to&nbsp;</span><span style="color: #0000ff;">double</span><span style="color: #000000;">:<br />
<br />
cast(cast(value1&nbsp;as&nbsp;</span><span style="color: #0000ff;">double</span><span style="color: #000000;">&nbsp;precision)&nbsp;</span><span style="color: #000000;">*</span><span style="color: #000000;">&nbsp;cast(value2&nbsp;as&nbsp;</span><span style="color: #0000ff;">double</span><span style="color: #000000;">&nbsp;precision)&nbsp;as&nbsp;numeric(</span><span style="color: #000000;">18</span><span style="color: #000000;">,</span><span style="color: #000000;">6</span><span style="color: #000000;">))<br />
<br />
Also,&nbsp;</span><span style="color: #0000ff;">if</span><span style="color: #000000;">&nbsp;you&nbsp;have&nbsp;mixed&nbsp;multiplications&nbsp;and&nbsp;divisions&nbsp;it&nbsp;helps&nbsp;to&nbsp;change&nbsp;the&nbsp;order&nbsp;of&nbsp;operations,&nbsp;so&nbsp;that&nbsp;the&nbsp;overflow&nbsp;doesn</span><span style="color: #000000;">'</span><span style="color: #000000;">t&nbsp;happen. <br />
</span></div>
<br />
<br />
<div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
--><span style="color: #000000;">String sql = "select mbrid from jcmbr where reference4=?";<br />
假如没有记录<br />
DynaBean&nbsp;aBean&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;CxcDataModule.getInstance().getRow(sql,&nbsp;</span><span style="color: #0000ff;">new</span><span style="color: #000000;">&nbsp;Object[]{</span><span style="color: #000000;">reference4</span><span style="color: #000000;">});<br />
如果直接用aBean.get("</span><span style="color: #000000;">reference4"</span><span style="color: #000000;">) 出错；<br />
错误的原因是</span><span style="color: #000000;">aBean&nbsp; </span><span style="color: #000000;">为null</span><br />
<span style="color: #000000;"><br />
Object&nbsp;obj&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;"> {spring jdbctemplate}.queryForObject(sql,&nbsp;</span><span style="color: #0000ff;">new</span><span style="color: #000000;">&nbsp;Object[]{</span><span style="color: #000000;">reference4</span><span style="color: #000000;">},&nbsp;Integer.</span><span style="color: #0000ff;">class</span><span style="color: #000000;">);<br />
</span><span style="color: #0000ff;">if</span><span style="color: #000000;">&nbsp;(obj&nbsp;</span><span style="color: #0000ff;">instanceof</span><span style="color: #000000;">&nbsp;Integer)<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.out.println(</span><span style="color: #000000;">"</span><span style="color: #000000;">(Integer)obj&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;</span><span style="color: #000000;">"</span><span style="color: #000000;">&nbsp;</span><span style="color: #000000;">+</span><span style="color: #000000;">&nbsp;(Integer)obj);<br />
</span><span style="color: #0000ff;">else</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">if</span><span style="color: #000000;">&nbsp;(obj&nbsp;</span><span style="color: #0000ff;">instanceof</span><span style="color: #000000;">&nbsp;Map)<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(</span><span style="color: #000000;">"</span><span style="color: #000000;">(Integer)obj&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;</span><span style="color: #000000;">"</span><span style="color: #000000;">&nbsp;</span><span style="color: #000000;">+</span><span style="color: #000000;">&nbsp;((Map)obj).get(</span><span style="color: #000000;">"REFERENCE4</span><span style="color: #000000;">"</span><span style="color: #000000;">));<br />
真是的流程是 if 分支<br />
如果有数据，这是对的<br />
如果没有数据，直接出错，因为有个假定有Integer值存在<br />
<br />
</span><span style="color: #0000ff;">int</span><span style="color: #000000;">&nbsp;value&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;JcDataModuleUtils.getJdbcTemplate().queryForInt(sql,&nbsp;</span><span style="color: #0000ff;">new</span><span style="color: #000000;">&nbsp;Object[]{</span><span style="color: #000000;">reference4</span><span style="color: #000000;">});</span><span style="color: #000000;"><br />
出错原因是假定一定会有一个int值返回</span><br />
<span style="color: #000000;">15:09:00,438 ERROR [STDERR] Caused by: org.springframework.dao.IncorrectResultSizeDataAccessException: Incorrect result size:<br />
&nbsp;expected 1, actual 0<br />
15:09:00,438 ERROR [STDERR]&nbsp;&nbsp;&nbsp;&nbsp; at org.springframework.dao.support.DataAccessUtils.requiredUniqueResult(DataAccessUtils.java:<br />
66)<br />
15:09:00,469 ERROR [STDERR]&nbsp;&nbsp;&nbsp;&nbsp; at org.springframework.jdbc.core.JdbcTemplate.queryForObject(JdbcTemplate.java:620)<br />
15:09:00,469 ERROR [STDERR]&nbsp;&nbsp;&nbsp;&nbsp; at org.springframework.jdbc.core.JdbcTemplate.queryForObject(JdbcTemplate.java:629)<br />
15:09:00,469 ERROR [STDERR]&nbsp;&nbsp;&nbsp;&nbsp; at org.springframework.jdbc.core.JdbcTemplate.queryForInt(JdbcTemplate.java:656)<br />
</span></div>
<br />
<br />
<br />
<br />
<img src ="http://www.blogjava.net/crazycy/aggbug/191534.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/crazycy/" target="_blank">crazycy</a> 2008-04-08 18:30 <a href="http://www.blogjava.net/crazycy/archive/2008/04/08/191534.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>mysql乱码编码的解决之道(不含分析) </title><link>http://www.blogjava.net/crazycy/archive/2007/12/23/169827.html</link><dc:creator>crazycy</dc:creator><author>crazycy</author><pubDate>Sun, 23 Dec 2007 10:07:00 GMT</pubDate><guid>http://www.blogjava.net/crazycy/archive/2007/12/23/169827.html</guid><wfw:comment>http://www.blogjava.net/crazycy/comments/169827.html</wfw:comment><comments>http://www.blogjava.net/crazycy/archive/2007/12/23/169827.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/crazycy/comments/commentRss/169827.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/crazycy/services/trackbacks/169827.html</trackback:ping><description><![CDATA[mysql的中文乱码,大多是因为mysql的编码选择造成的。<br />
以mysql的两个相同结构的表间进行数据迁移为例，做了三种情况的测试，并提出解决乱码的解决方法如下:<br />
<br />
<p class="MsoNormal">Migration between MySQLs</p>
<p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"><!--[if !supportLists]--><span><span>1)<span style="font-family: &quot;Times New Roman&quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span></span><!--[endif]-->Migration between character set : utf8</p>
<p class="MsoNormal" style="margin-left: 0.5in;">Amend my.ini (2 positions)</p>
<p class="MsoNormal" style="margin-left: 0.5in;">default-character-set=latin1</p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-family: Wingdings;"><span>=&gt;<br />
</span></span></p>
<p class="MsoNormal" style="margin-left: 0.5in;">default-character-set=utf8</p>
<p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"><!--[if !supportLists]--><span><span>2)<span style="font-family: &quot;Times New Roman&quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span></span><!--[endif]-->Migration between character set : origin is utf8 ==&gt;<span style="font-family: Wingdings;"></span>
the
destination is latin1</p>
<p class="MsoNormal" style="margin-left: 0.5in;">Alter destination:</p>
<ul>
    <li><!--[if !supportLists]--><span style="font-family: Wingdings;"><span><span style="font-family: &quot;Times New Roman&quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;">
    </span></span></span><!--[endif]-->alter database [db_name] default character set utf8;<span style="font-family: Wingdings;"></span></li>
    <li><span style="font-family: Wingdings;"><span><span style="font-family: &quot;Times New Roman&quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;">
    </span></span></span><!--[endif]-->alter table [table_name] default character set
    utf8;<span style="font-family: Wingdings;"></span></li>
    <li><span style="font-family: Wingdings;"><span><span style="font-family: &quot;Times New Roman&quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;">&nbsp;</span></span></span>alter table [table_name] change [field_name]
    [field_name] [filed type] varchar(45) character set utf8;</li>
    <ul>
        <li>example</li>
    </ul>
</ul>
<p class="MsoNormal" style="margin-left: 1in;">users(id, user_name)</p>
<p class="MsoNormal" style="margin-left: 1in;">alter table users <span>&nbsp;</span>change user_name user_name varchar(45)
character set utf8;</p>
<p class="MsoNormal" style="margin-left: 1in;"><o:p>&nbsp;</o:p></p>
<p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"><!--[if !supportLists]--><span><span>3)<span style="font-family: &quot;Times New Roman&quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span></span><!--[endif]-->Migration between character set : origin is
latin1 ==&gt;<span style="font-family: Wingdings;"></span>
the destination is utf8</p>
<p class="MsoNormal" style="margin-left: 0.5in;">If the origin is latin1, cannot
insert Chinese Character. </p>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<br />
<img src ="http://www.blogjava.net/crazycy/aggbug/169827.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/crazycy/" target="_blank">crazycy</a> 2007-12-23 18:07 <a href="http://www.blogjava.net/crazycy/archive/2007/12/23/169827.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>firebird技巧和错误分析与总结</title><link>http://www.blogjava.net/crazycy/archive/2007/11/03/157940.html</link><dc:creator>crazycy</dc:creator><author>crazycy</author><pubDate>Sat, 03 Nov 2007 09:06:00 GMT</pubDate><guid>http://www.blogjava.net/crazycy/archive/2007/11/03/157940.html</guid><wfw:comment>http://www.blogjava.net/crazycy/comments/157940.html</wfw:comment><comments>http://www.blogjava.net/crazycy/archive/2007/11/03/157940.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/crazycy/comments/commentRss/157940.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/crazycy/services/trackbacks/157940.html</trackback:ping><description><![CDATA[1）<br />
<strong>Cmd </strong>&gt;&gt; isql localhost/3050:path/cxcdata.fdb -user sysdba -pass masterkey<br />
<strong>Error </strong>&gt;&gt; <br />
Statement failed, SQLCODE = -902<br />
<br />
Unable to complete network request to host "localhost".<br />
-Failed to establish a connection.<br />
-No connection could be made because the target machine actively refused it.<br />
<br />
Use CONNECT or CREATE DATABASE to specify a database<br />
<strong>Solution</strong>&gt;&gt;<br />
check whether service or application of firebird start or not<br />
<br />
2) <br />
<strong>Scenario</strong>&gt;&gt;Using EMS Data Export for Interbase/Firebird<br />
<strong>Error</strong>&gt;&gt; <br />
<img src="file:///C:/Users/cuiyi/AppData/Local/Temp/moz-screenshot.jpg" alt="" /><img src="file:///C:/Users/cuiyi/AppData/Local/Temp/moz-screenshot-2.jpg" alt="" /><img alt="" src="http://www.blogjava.net/images/blogjava_net/crazycy/firebird/gds_error.jpg" height="182" width="482" /><br />
<strong>Solution</strong>&gt;&gt;windows\system32\drivers\etc目录下的services文件中添加<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; gds_db 3050/tcp<br />
<br />
3) windows下firebird对db路径要求：与firebird直接交互的fdb文件必须增加前缀：localhost/3050:[driver]/{[path]/}[.fdb file]<br />
&nbsp;&nbsp;&nbsp; 无论是isql 还是 gbak<br />
&nbsp;&nbsp;&nbsp; 比如 test.fdb 在d:\dbfile\firebird\test.fdb<br />
&nbsp;&nbsp;&nbsp; connect db: cmd&gt;&gt; isql localhost/3050:d:/dbfile/firebird/test.fdb -user [username] -pass [userpass]<br />
&nbsp;&nbsp;&nbsp; backup db: cmd&gt;&gt; gbak -B localhost/3050:d:/dbfile/firebird/test.fdb test.fbk -user [username] -pass [userpass]<br />
&nbsp;&nbsp;&nbsp; restore db: cmd&gt;&gt; gbak -C test.fbk localhost/3050:d:/dbfile/firebird/test.fdb -user [username] -pass [userpass]<br />
&nbsp;&nbsp;&nbsp; NOTE: only the fdb file should add the localhost constraint<br />
&nbsp;&nbsp;&nbsp; <img alt="" src="http://www.blogjava.net/images/blogjava_net/crazycy/firebird/isql.jpg" height="150" width="593" /><br />
&nbsp;&nbsp;&nbsp; <br />
4) db installed in d:/dbfile/firebird/test.fdb<br />
&nbsp;&nbsp;&nbsp; connect way 1&gt;&gt;&nbsp; isql localhost/3050:d:/dbfile/firebird/test.fdb -user [username] -pass [userpass]<br />
&nbsp;&nbsp;&nbsp; connect way 2&gt;&gt; isql localhost/3050:db -user [username] -pass [userpass] <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; add this line : db = d:/dbfile/firebird/test.fdb&nbsp; in aliases.conf, no need restart firebird service<br />
<br />
5）about amention of db's path for different customer<br />
we offten configure db path in apps using jdbc:firebird:localhost:[path]/[db file]&nbsp;&nbsp; like jdbc:firebird:localhost: d:/dbfile/firebird/test.fdb<br />
As you know, in most time we install db in different folder for different customers; so we must keep re-compile apps or modify war/jar/ear every time.<br />
<br />
So basis on this issue,&nbsp; we can change to configure db using firebird self file called <span style="background-color: yellow;">aliases.conf</span><br />
like this form (basis my local configuration):<br />
<span style="background-color: #98c5ff;">test.fdb = d:/dbfile/firebird/test.fdb</span><br />
<br />
so now using this form jdbc:firebird:localhost:test.fdb&nbsp; in&nbsp; apps <br />
I tried both windows and linux, it works;<br />
<br />
<img src ="http://www.blogjava.net/crazycy/aggbug/157940.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/crazycy/" target="_blank">crazycy</a> 2007-11-03 17:06 <a href="http://www.blogjava.net/crazycy/archive/2007/11/03/157940.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>得到PrepareStatement最终执行的sql语句的方法</title><link>http://www.blogjava.net/crazycy/archive/2006/07/22/59581.html</link><dc:creator>crazycy</dc:creator><author>crazycy</author><pubDate>Sat, 22 Jul 2006 13:53:00 GMT</pubDate><guid>http://www.blogjava.net/crazycy/archive/2006/07/22/59581.html</guid><wfw:comment>http://www.blogjava.net/crazycy/comments/59581.html</wfw:comment><comments>http://www.blogjava.net/crazycy/archive/2006/07/22/59581.html#Feedback</comments><slash:comments>15</slash:comments><wfw:commentRss>http://www.blogjava.net/crazycy/comments/commentRss/59581.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/crazycy/services/trackbacks/59581.html</trackback:ping><description><![CDATA[在CSDN的JAVA基础版,常常有人问及如何得到PreparedStatement最终执行的SQL语句;或者如何在控制台输出占位符的真实值.....<br /><br />原因就是PreparedStatement执行的sql语句有大量的占位符?....<br /><br />问题诸如JDBC中:<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);">如何得到 conn.prepareStatement 最终执行的sql语句。<br />sql</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">update table1 set a=?,b=?</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"><br />stmt </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> con.prepareStatement(sql);<br />stmt.setObjec t(</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">a</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br />stmt.setObjec t(</span><span style="color: rgb(0, 0, 0);">2</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">b</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br /><br />希望可以通过stmt或者conn 得到：<br />update table1 set a</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">'</span><span style="color: rgb(0, 0, 0);">a</span><span style="color: rgb(0, 0, 0);">'</span><span style="color: rgb(0, 0, 0);">,b</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">'</span><span style="color: rgb(0, 0, 0);">b</span><span style="color: rgb(0, 0, 0);">'</span></div><br />亦或Hibernate中<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);">如我执行：find(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">select * from t_table where id = ?</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> Integer(</span><span style="color: rgb(0, 0, 0);">5</span><span style="color: rgb(0, 0, 0);">));<br />在控制台显示SQL时只显示：select </span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);"> from t_table where id </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">?</span><span style="color: rgb(0, 0, 0);"><br />如何才能做到将控制台显示的占位符用其真实的值来替换？<br />即控制台输出时显示：select </span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);"> from t_table where id </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">5</span><span style="color: rgb(0, 0, 0);"><br /></span></div><br />无它，无论JDBC还是Hiberante都不提供默认解决方案，但是参数是设置进去的，我们在设置的过程中可以有充分的理由来截取并获得自己想要的东西，类似于AOP理论。<br /><br />共享我在工程中的使用方法：<br />插入操作：<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 128, 0);">/**</span><span style="color: rgb(0, 128, 0);"><br />     * 执行插入数据库的语句<br />     * </span><span style="color: rgb(128, 128, 128);">@param</span><span style="color: rgb(0, 128, 0);"> sql<br />     * </span><span style="color: rgb(128, 128, 128);">@param</span><span style="color: rgb(0, 128, 0);"> params<br />     * </span><span style="color: rgb(128, 128, 128);">@return</span><span style="color: rgb(0, 128, 0);"> 返回生成的主键<br />     </span><span style="color: rgb(0, 128, 0);">*/</span><span style="color: rgb(0, 0, 0);"><br />    </span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);"> executeInsert(String sql, Object[] params) {<br />        Connection conn </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">null</span><span style="color: rgb(0, 0, 0);">;<br />        PreparedStatement pstmt </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">null</span><span style="color: rgb(0, 0, 0);">;<br />        ResultSet rs </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">null</span><span style="color: rgb(0, 0, 0);">;<br />        </span><span style="color: rgb(0, 0, 255);">try</span><span style="color: rgb(0, 0, 0);"> {<br />            </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">1 获得连接</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">            conn </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> MyDBConnection.getInstance().getConnection();<br />            </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">2 设置提交方式为程序控制</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">            conn.setAutoCommit(</span><span style="color: rgb(0, 0, 255);">false</span><span style="color: rgb(0, 0, 0);">);<br />            </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">3 获得语句对象</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">            pstmt </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> conn.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS);<br />            </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">4 设置SQL语句的参数</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">            </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);"> (</span><span style="color: rgb(0, 0, 255);">null</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">!=</span><span style="color: rgb(0, 0, 0);"> params </span><span style="color: rgb(0, 0, 0);">&amp;&amp;</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);"> params.length) {<br />                setParams(pstmt, params);<br />            }<br />            </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">5 打印SQL语句</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">            </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);"> (MyDBConstants.showSQL) {<br />                getPreparedSQL(sql, params);<br />            }<br />            </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">6 执行语句</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">            pstmt.executeUpdate();<br />            </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">7 程序提交</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">            conn.commit();<br />            </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">8 返回生成的主键</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">            rs </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> pstmt.getGeneratedKeys();<br />            </span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);"> generatedKey </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">;<br />            </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);"> (rs.next()) {<br />                generatedKey </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> rs.getInt(</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">);<br />            }<br />            </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);"> (</span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);"> generatedKey)<br />                </span><span style="color: rgb(0, 0, 255);">throw</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> MySQLException(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">插入记录时出错</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br />            </span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);"> generatedKey;<br />        } </span><span style="color: rgb(0, 0, 255);">catch</span><span style="color: rgb(0, 0, 0);"> (SQLException e) {<br />            </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">回滚</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">            MyDBUtil.rollBack(conn);<br />            </span><span style="color: rgb(0, 0, 255);">throw</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> MySQLException(e);<br />        } </span><span style="color: rgb(0, 0, 255);">finally</span><span style="color: rgb(0, 0, 0);"> {<br />            </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">关闭打开的操作</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">            MyDBUtil.close(conn, pstmt, rs);<br />        }<br />    }</span></div><br /><br />更新查找操作：<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 128, 0);">/**</span><span style="color: rgb(0, 128, 0);"><br />     * 执行更新或者删除数据库的语句<br />     * </span><span style="color: rgb(128, 128, 128);">@param</span><span style="color: rgb(0, 128, 0);"> sql<br />     * </span><span style="color: rgb(128, 128, 128);">@param</span><span style="color: rgb(0, 128, 0);"> params<br />     * </span><span style="color: rgb(128, 128, 128);">@return</span><span style="color: rgb(0, 128, 0);"> 返回执行成功与否<br />     </span><span style="color: rgb(0, 128, 0);">*/</span><span style="color: rgb(0, 0, 0);"><br />    </span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">boolean</span><span style="color: rgb(0, 0, 0);"> executeUpdateDel(String sql, Object[] params) {<br />        </span><span style="color: rgb(0, 0, 255);">boolean</span><span style="color: rgb(0, 0, 0);"> isSuccess </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">false</span><span style="color: rgb(0, 0, 0);">;<br />        Connection conn </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">null</span><span style="color: rgb(0, 0, 0);">;<br />        PreparedStatement pstmt </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">null</span><span style="color: rgb(0, 0, 0);">;<br />        </span><span style="color: rgb(0, 0, 255);">try</span><span style="color: rgb(0, 0, 0);"> {<br />            </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">1 获得连接</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">            conn </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> MyDBConnection.getInstance().getConnection();<br />            </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">2 设置提交方式为程序控制</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">            conn.setAutoCommit(</span><span style="color: rgb(0, 0, 255);">false</span><span style="color: rgb(0, 0, 0);">);<br />            </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">3 获得语句对象</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">            pstmt </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> conn.prepareStatement(sql);<br />            </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">4 设置SQL语句的参数</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">            </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);"> (</span><span style="color: rgb(0, 0, 255);">null</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">!=</span><span style="color: rgb(0, 0, 0);"> params </span><span style="color: rgb(0, 0, 0);">&amp;&amp;</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);"> params.length) {<br />                setParams(pstmt, params);<br />            }<br />            </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">5 打印SQL语句</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">            </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);"> (MyDBConstants.showSQL) {<br />                getPreparedSQL(sql, params);<br />            }<br />            </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">6 执行语句</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">            pstmt.executeUpdate();<br />            </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">7 程序提交</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">            conn.commit();<br />            </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">8 设置语句执行的标记</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">            isSuccess </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">true</span><span style="color: rgb(0, 0, 0);">;<br />        } </span><span style="color: rgb(0, 0, 255);">catch</span><span style="color: rgb(0, 0, 0);"> (SQLException e) {<br />            </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">回滚</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">            MyDBUtil.rollBack(conn);<br />            </span><span style="color: rgb(0, 0, 255);">throw</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> MySQLException(e);<br />        } </span><span style="color: rgb(0, 0, 255);">finally</span><span style="color: rgb(0, 0, 0);"> {<br />            </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">关闭打开的操作</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">            MyDBUtil.close(conn, pstmt);<br />        }<br />        </span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);"> isSuccess;<br />    }</span></div><br />执行查询<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 128, 128);"> 1</span> <span style="color: rgb(0, 128, 0);">/**</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 2</span> <span style="color: rgb(0, 128, 0);">     * 执行查询数据库的语句;</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 9</span> <span style="color: rgb(0, 128, 0);">     *<br /></span><span style="color: rgb(0, 128, 128);">10</span> <span style="color: rgb(0, 128, 0);">     * </span><span style="color: rgb(128, 128, 128);">@return</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 128, 128);">11</span> <span style="color: rgb(0, 128, 0);">     </span><span style="color: rgb(0, 128, 0);">*/</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">12</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);"> Object executeQuery(String sql, Object[] params) {<br /></span><span style="color: rgb(0, 128, 128);">13</span> <span style="color: rgb(0, 0, 0);">        Connection conn </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">null</span><span style="color: rgb(0, 0, 0);">;<br /></span><span style="color: rgb(0, 128, 128);">14</span> <span style="color: rgb(0, 0, 0);">        PreparedStatement pstmt </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">null</span><span style="color: rgb(0, 0, 0);">;<br /></span><span style="color: rgb(0, 128, 128);">15</span> <span style="color: rgb(0, 0, 0);">        ResultSet rs </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">null</span><span style="color: rgb(0, 0, 0);">;<br /></span><span style="color: rgb(0, 128, 128);">16</span> <span style="color: rgb(0, 0, 0);">        </span><span style="color: rgb(0, 0, 255);">try</span><span style="color: rgb(0, 0, 0);"> {<br /></span><span style="color: rgb(0, 128, 128);">17</span> <span style="color: rgb(0, 0, 0);">            </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">1 获得连接</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 128, 128);">18</span> <span style="color: rgb(0, 128, 0);"></span><span style="color: rgb(0, 0, 0);">            conn </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> MyDBConnection.getInstance().getConnection();<br /></span><span style="color: rgb(0, 128, 128);">19</span> <span style="color: rgb(0, 0, 0);">            </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">2 设置提交方式为程序控制</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 128, 128);">20</span> <span style="color: rgb(0, 128, 0);"></span><span style="color: rgb(0, 0, 0);">            conn.setAutoCommit(</span><span style="color: rgb(0, 0, 255);">false</span><span style="color: rgb(0, 0, 0);">);<br /></span><span style="color: rgb(0, 128, 128);">21</span> <span style="color: rgb(0, 0, 0);">            </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">3 获得语句对象</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 128, 128);">22</span> <span style="color: rgb(0, 128, 0);"></span><span style="color: rgb(0, 0, 0);">            pstmt </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> conn.prepareStatement(sql, ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);<br /></span><span style="color: rgb(0, 128, 128);">23</span> <span style="color: rgb(0, 0, 0);">            </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">4 设置SQL语句的参数</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 128, 128);">24</span> <span style="color: rgb(0, 128, 0);"></span><span style="color: rgb(0, 0, 0);">            </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);"> (</span><span style="color: rgb(0, 0, 255);">null</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">!=</span><span style="color: rgb(0, 0, 0);"> params </span><span style="color: rgb(0, 0, 0);">&amp;&amp;</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);"> params.length) {<br /></span><span style="color: rgb(0, 128, 128);">25</span> <span style="color: rgb(0, 0, 0);">                setParams(pstmt, params);<br /></span><span style="color: rgb(0, 128, 128);">26</span> <span style="color: rgb(0, 0, 0);">            }<br /></span><span style="color: rgb(0, 128, 128);">27</span> <span style="color: rgb(0, 0, 0);">            </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">5 打印SQL语句</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 128, 128);">28</span> <span style="color: rgb(0, 128, 0);"></span><span style="color: rgb(0, 0, 0);">            </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);"> (MyDBConstants.showSQL) {<br /></span><span style="color: rgb(0, 128, 128);">29</span> <span style="color: rgb(0, 0, 0);">                getPreparedSQL(sql, params);<br /></span><span style="color: rgb(0, 128, 128);">30</span> <span style="color: rgb(0, 0, 0);">            }<br /></span><span style="color: rgb(0, 128, 128);">31</span> <span style="color: rgb(0, 0, 0);">            </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">6 执行语句</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 128, 128);">32</span> <span style="color: rgb(0, 128, 0);"></span><span style="color: rgb(0, 0, 0);">            rs </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> pstmt.executeQuery();<br /></span><span style="color: rgb(0, 128, 128);">33</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">34</span> <span style="color: rgb(0, 0, 0);">            </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">9 程序提交</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 128, 128);">35</span> <span style="color: rgb(0, 128, 0);"></span><span style="color: rgb(0, 0, 0);">            conn.commit();<br /></span><span style="color: rgb(0, 128, 128);">36</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">37</span> <span style="color: rgb(0, 0, 0);">            </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">10 获得记录</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 128, 128);">38</span> <span style="color: rgb(0, 128, 0);"></span><span style="color: rgb(0, 0, 0);">            Object vo </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> Object();<br /></span><span style="color: rgb(0, 128, 128);">39</span> <span style="color: rgb(0, 0, 0);">            </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);"> (</span><span style="color: rgb(0, 0, 255);">null</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">!=</span><span style="color: rgb(0, 0, 0);"> rs </span><span style="color: rgb(0, 0, 0);">&amp;&amp;</span><span style="color: rgb(0, 0, 0);"> rs.next()) {<br /></span><span style="color: rgb(0, 128, 128);">40</span> <span style="color: rgb(0, 0, 0);">                vo </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> rs2vo(rs);<br /></span><span style="color: rgb(0, 128, 128);">41</span> <span style="color: rgb(0, 0, 0);">            }<br /></span><span style="color: rgb(0, 128, 128);">42</span> <span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">            return results;</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 128, 128);">43</span> <span style="color: rgb(0, 128, 0);"></span><span style="color: rgb(0, 0, 0);">            </span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);"> vo;<br /></span><span style="color: rgb(0, 128, 128);">44</span> <span style="color: rgb(0, 0, 0);">        } </span><span style="color: rgb(0, 0, 255);">catch</span><span style="color: rgb(0, 0, 0);"> (SQLException e) {<br /></span><span style="color: rgb(0, 128, 128);">45</span> <span style="color: rgb(0, 0, 0);">            </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">回滚</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 128, 128);">46</span> <span style="color: rgb(0, 128, 0);"></span><span style="color: rgb(0, 0, 0);">            MyDBUtil.rollBack(conn);<br /></span><span style="color: rgb(0, 128, 128);">47</span> <span style="color: rgb(0, 0, 0);">            </span><span style="color: rgb(0, 0, 255);">throw</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> MySQLException(e);<br /></span><span style="color: rgb(0, 128, 128);">48</span> <span style="color: rgb(0, 0, 0);">        } </span><span style="color: rgb(0, 0, 255);">finally</span><span style="color: rgb(0, 0, 0);"> {<br /></span><span style="color: rgb(0, 128, 128);">49</span> <span style="color: rgb(0, 0, 0);">            </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">关闭打开的操作</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 128, 128);">50</span> <span style="color: rgb(0, 128, 0);"></span><span style="color: rgb(0, 0, 0);">            MyDBUtil.close(conn, pstmt, rs);<br /></span><span style="color: rgb(0, 128, 128);">51</span> <span style="color: rgb(0, 0, 0);">        }<br /></span><span style="color: rgb(0, 128, 128);">52</span> <span style="color: rgb(0, 0, 0);">    }</span></div><br />看到<span style="color: rgb(0, 0, 0);">getPreparedSQL(sql, params)了么？ 这个地方就是要实现我们预期效果的地方：<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><img id="Code_Closed_Image_215212" onclick="this.style.display='none'; Code_Closed_Text_215212.style.display='none'; Code_Open_Image_215212.style.display='inline'; Code_Open_Text_215212.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedBlock.gif" align="top" height="16" width="11" /><img id="Code_Open_Image_215212" style="display: none;" onclick="this.style.display='none'; Code_Open_Text_215212.style.display='none'; Code_Closed_Image_215212.style.display='inline'; Code_Closed_Text_215212.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" height="16" width="11" /><span id="Code_Closed_Text_215212" style="border: 1px solid rgb(128, 128, 128); background-color: rgb(255, 255, 255);">得到PrepareStatement最终执行的sql语句的方法</span><span id="Code_Open_Text_215212" style="display: none;"><br /><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 128, 128);"> 1</span> <span style="color: rgb(0, 128, 0);">/**</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 2</span> <span style="color: rgb(0, 128, 0);">     * 获得PreparedStatement向数据库提交的SQL语句<br /></span><span style="color: rgb(0, 128, 128);"> 3</span> <span style="color: rgb(0, 128, 0);">     * </span><span style="color: rgb(128, 128, 128);">@param</span><span style="color: rgb(0, 128, 0);"> sql<br /></span><span style="color: rgb(0, 128, 128);"> 4</span> <span style="color: rgb(0, 128, 0);">     * </span><span style="color: rgb(128, 128, 128);">@param</span><span style="color: rgb(0, 128, 0);"> params<br /></span><span style="color: rgb(0, 128, 128);"> 5</span> <span style="color: rgb(0, 128, 0);">     * </span><span style="color: rgb(128, 128, 128);">@return</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 6</span> <span style="color: rgb(0, 128, 0);">     </span><span style="color: rgb(0, 128, 0);">*/</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 7</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 255);">private</span><span style="color: rgb(0, 0, 0);"> String getPreparedSQL(String sql, Object[] params) {<br /></span><span style="color: rgb(0, 128, 128);"> 8</span> <span style="color: rgb(0, 0, 0);">        </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">1 如果没有参数，说明是不是动态SQL语句</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 9</span> <span style="color: rgb(0, 128, 0);"></span><span style="color: rgb(0, 0, 0);">                </span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);"> paramNum </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">;<br /></span><span style="color: rgb(0, 128, 128);">10</span> <span style="color: rgb(0, 0, 0);">                </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);"> (</span><span style="color: rgb(0, 0, 255);">null</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">!=</span><span style="color: rgb(0, 0, 0);"> params)  paramNum </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> params.length;<br /></span><span style="color: rgb(0, 128, 128);">11</span> <span style="color: rgb(0, 0, 0);">        </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);"> (</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);"> paramNum) </span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);"> sql;<br /></span><span style="color: rgb(0, 128, 128);">12</span> <span style="color: rgb(0, 0, 0);">        </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">2 如果有参数，则是动态SQL语句</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 128, 128);">13</span> <span style="color: rgb(0, 128, 0);"></span><span style="color: rgb(0, 0, 0);">        StringBuffer returnSQL </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> StringBuffer();<br /></span><span style="color: rgb(0, 128, 128);">14</span> <span style="color: rgb(0, 0, 0);">        String[] subSQL </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> sql.split(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">\\?</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br /></span><span style="color: rgb(0, 128, 128);">15</span> <span style="color: rgb(0, 0, 0);">        </span><span style="color: rgb(0, 0, 255);">for</span><span style="color: rgb(0, 0, 0);"> (</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);"> i </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">; i </span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);"> paramNum; i</span><span style="color: rgb(0, 0, 0);">++</span><span style="color: rgb(0, 0, 0);">) {<br /></span><span style="color: rgb(0, 128, 128);">16</span> <span style="color: rgb(0, 0, 0);">            </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);"> (params[i] </span><span style="color: rgb(0, 0, 255);">instanceof</span><span style="color: rgb(0, 0, 0);"> Date) {<br /></span><span style="color: rgb(0, 128, 128);">17</span> <span style="color: rgb(0, 0, 0);">                returnSQL.append(subSQL[i]).append(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"> '</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">).append(MyDateUtil.dateUtil2SQL((java.util.Date)params[i])).append(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">' </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br /></span><span style="color: rgb(0, 128, 128);">18</span> <span style="color: rgb(0, 0, 0);">            } </span><span style="color: rgb(0, 0, 255);">else</span><span style="color: rgb(0, 0, 0);"> {<br /></span><span style="color: rgb(0, 128, 128);">19</span> <span style="color: rgb(0, 0, 0);">                returnSQL.append(subSQL[i]).append(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"> '</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">).append(params[i]).append(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">' </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br /></span><span style="color: rgb(0, 128, 128);">20</span> <span style="color: rgb(0, 0, 0);">            }<br /></span><span style="color: rgb(0, 128, 128);">21</span> <span style="color: rgb(0, 0, 0);">        }<br /></span><span style="color: rgb(0, 128, 128);">22</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">23</span> <span style="color: rgb(0, 0, 0);">        </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);"> (subSQL.length </span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);"> params.length) {<br /></span><span style="color: rgb(0, 128, 128);">24</span> <span style="color: rgb(0, 0, 0);">            returnSQL.append(subSQL[subSQL.length </span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">]);<br /></span><span style="color: rgb(0, 128, 128);">25</span> <span style="color: rgb(0, 0, 0);">        }<br /></span><span style="color: rgb(0, 128, 128);">26</span> <span style="color: rgb(0, 0, 0);">        </span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);"> returnSQL.toString();<br /></span><span style="color: rgb(0, 128, 128);">27</span> <span style="color: rgb(0, 0, 0);">    }<br /></span><span style="color: rgb(0, 128, 128);">28</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">29</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 128, 0);">/**</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 128, 128);">30</span> <span style="color: rgb(0, 128, 0);">     * 为PreparedStatement预编译的SQL语句设置参数<br /></span><span style="color: rgb(0, 128, 128);">31</span> <span style="color: rgb(0, 128, 0);">     * </span><span style="color: rgb(128, 128, 128);">@param</span><span style="color: rgb(0, 128, 0);"> pstmt<br /></span><span style="color: rgb(0, 128, 128);">32</span> <span style="color: rgb(0, 128, 0);">     * </span><span style="color: rgb(128, 128, 128);">@param</span><span style="color: rgb(0, 128, 0);"> params<br /></span><span style="color: rgb(0, 128, 128);">33</span> <span style="color: rgb(0, 128, 0);">     </span><span style="color: rgb(0, 128, 0);">*/</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">34</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 255);">private</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);"> setParams(PreparedStatement pstmt, Object[] params) {<br /></span><span style="color: rgb(0, 128, 128);">35</span> <span style="color: rgb(0, 0, 0);">            </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);"> (</span><span style="color: rgb(0, 0, 255);">null</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">!=</span><span style="color: rgb(0, 0, 0);"> params) {<br /></span><span style="color: rgb(0, 128, 128);">36</span> <span style="color: rgb(0, 0, 0);">                </span><span style="color: rgb(0, 0, 255);">for</span><span style="color: rgb(0, 0, 0);"> (</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);"> i </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">, paramNum </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> params.length; i </span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);"> paramNum; i</span><span style="color: rgb(0, 0, 0);">++</span><span style="color: rgb(0, 0, 0);">) {<br /></span><span style="color: rgb(0, 128, 128);">37</span> <span style="color: rgb(0, 0, 0);">                    </span><span style="color: rgb(0, 0, 255);">try</span><span style="color: rgb(0, 0, 0);"> {<br /></span><span style="color: rgb(0, 128, 128);">38</span> <span style="color: rgb(0, 0, 0);">                        </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);"> (</span><span style="color: rgb(0, 0, 255);">null</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">!=</span><span style="color: rgb(0, 0, 0);"> params[i] </span><span style="color: rgb(0, 0, 0);">&amp;&amp;</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">39</span> <span style="color: rgb(0, 0, 0);">                            params[i] </span><span style="color: rgb(0, 0, 255);">instanceof</span><span style="color: rgb(0, 0, 0);"> java.util.Date) {<br /></span><span style="color: rgb(0, 128, 128);">40</span> <span style="color: rgb(0, 0, 0);">                            pstmt.setDate(i </span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">, MyDateUtil.dateUtil2SQL(<br /></span><span style="color: rgb(0, 128, 128);">41</span> <span style="color: rgb(0, 0, 0);">                                    (java.util.Date) params[i]));<br /></span><span style="color: rgb(0, 128, 128);">42</span> <span style="color: rgb(0, 0, 0);">                        } </span><span style="color: rgb(0, 0, 255);">else</span><span style="color: rgb(0, 0, 0);"> {<br /></span><span style="color: rgb(0, 128, 128);">43</span> <span style="color: rgb(0, 0, 0);">                            pstmt.setObject(i </span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">, params[i]);<br /></span><span style="color: rgb(0, 128, 128);">44</span> <span style="color: rgb(0, 0, 0);">                        }<br /></span><span style="color: rgb(0, 128, 128);">45</span> <span style="color: rgb(0, 0, 0);">                    } </span><span style="color: rgb(0, 0, 255);">catch</span><span style="color: rgb(0, 0, 0);"> (SQLException e) {<br /></span><span style="color: rgb(0, 128, 128);">46</span> <span style="color: rgb(0, 0, 0);">                        </span><span style="color: rgb(0, 0, 255);">throw</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> MySQLException(e);<br /></span><span style="color: rgb(0, 128, 128);">47</span> <span style="color: rgb(0, 0, 0);">                    }<br /></span><span style="color: rgb(0, 128, 128);">48</span> <span style="color: rgb(0, 0, 0);">                }<br /></span><span style="color: rgb(0, 128, 128);">49</span> <span style="color: rgb(0, 0, 0);">            }<br /></span><span style="color: rgb(0, 128, 128);">50</span> <span style="color: rgb(0, 0, 0);">    }</span></span></div><br />然后轻松核实你的控制台或者日志文件吧......<br /></span><img src ="http://www.blogjava.net/crazycy/aggbug/59581.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/crazycy/" target="_blank">crazycy</a> 2006-07-22 21:53 <a href="http://www.blogjava.net/crazycy/archive/2006/07/22/59581.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>An internal error occurred during: "Generating Artifacts" </title><link>http://www.blogjava.net/crazycy/archive/2006/06/22/54502.html</link><dc:creator>crazycy</dc:creator><author>crazycy</author><pubDate>Thu, 22 Jun 2006 07:41:00 GMT</pubDate><guid>http://www.blogjava.net/crazycy/archive/2006/06/22/54502.html</guid><wfw:comment>http://www.blogjava.net/crazycy/comments/54502.html</wfw:comment><comments>http://www.blogjava.net/crazycy/archive/2006/06/22/54502.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/crazycy/comments/commentRss/54502.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/crazycy/services/trackbacks/54502.html</trackback:ping><description><![CDATA[    今天是用Eclipse3.1.2+MyEclipse4.1.1+MySQL5.0.12，用Database Explorer创建Hibernate3所需的HBM映射文件和VO对象时，居然报An internal error occurred during: "Generating Artifacts" 这个错误。<br /><br />    google了一把，看到Blog（软道，url：http://blog.csdn.net/langtaojin/archive/2006/03/28/641722.aspx）介绍如下：<br />今天在使用myEclipse 的　Database Explorer 视图中Create Hibernate Mapping时，出现了“An internal error occurred during: "Generating Artifacts".”错误提示。费了好大劲，终于解决了。据myEclipse官方网站上的介绍，发生该错误主要有两种情况，一是你eclipse上安装了jboss公司的hibernate tools plugin for eclipse,这些插件与myEclipse发生冲突，解决方法是删除这些插件。二是你在没有卸载以前myEclipse版本的情况下安装了新的 myEclipse版本，解决方法是把myEclipse卸载后重新安装，我遇到的情况就属于每二种情况，重装myEclipse后问题解决了。<br /><br />    第一个问题不存在，然后咣咣的卸载、安装了MyEclipse4.1.1。问题依然。<br /><br />    手工建立测试表，却没有这个问题。突然想到了可能是数据表建立的格式有问题：我用PD直接把物理实体模型导入到Mysql中。就它了。通过MyCC（当然也可以通过命令行 mysql -h localhost -u root -p）把PD生成的SQL语句重新运行，OK，问题解决。<br /><br />    结合上面的blog，可以看出出现这个问题具有三种情况了。<br /><br />    当然或许你用Oracle，也可能遇到这个问题，如果以上三种情况都没有解决了An internal error occurred during: "Generating Artifacts" 这个错误。你注意两点：1PLSQL工具的问题，建议直接命令行。2Orcle的class12驱动的版本，建议换新版本。<br /><br /><br /><img src ="http://www.blogjava.net/crazycy/aggbug/54502.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/crazycy/" target="_blank">crazycy</a> 2006-06-22 15:41 <a href="http://www.blogjava.net/crazycy/archive/2006/06/22/54502.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>