sqlite常用方法

前端之家收集整理的这篇文章主要介绍了sqlite常用方法前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
<div id="article_details" class="details"> <div class="article_title"> <span class="ico ico_type_Repost"></span> <h1> <span class="link_title"><a href="/hanfengzqh/article/details/54346865"> sqlite中判断表、字段是否存在的方法 </a></span> </h1> </div> <div class="article_manage clearfix"> <div class="article_r"> <span class="link_postdate">2017-01-11 19:26</span> <span class="link_view" title="阅读次数">429人阅读</span> <span class="link_comments" title="评论次数"> <a href="#comments" onclick="_gaq.push(['_trackEvent','function','onclick','blog_articles_pinglun'])">评论</a>(0)</span> <span class="link_collect tracking-ad" data-mod="popu_171"> <a href="javascript:void(0);" onclick="javascript:collectArticle('sqlite%e4%b8%ad%e5%88%a4%e6%96%ad%e8%a1%a8%e3%80%81%e5%ad%97%e6%ae%b5%e6%98%af%e5%90%a6%e5%ad%98%e5%9c%a8%e7%9a%84%e6%96%b9%e6%b3%95','54346865');return false;" title="收藏" target="_blank">收藏</a></span> <span class="link_report"> <a href="#report" onclick="javascript:report(54346865,2);return false;" title="举报">举报</a></span> </div> </div> <div class="embody" style="display:none" id="embody"> <span class="embody_t">本文章已收录于:</span> <div class="embody_c" id="lib" value="{&quot;err&quot;:0,&quot;msg&quot;:&quot;ok&quot;,&quot;data&quot;:[]}"></div> </div> <style type="text/css"> .embody{ padding:10px 10px 10px; margin:0 -20px; border-bottom:solid 1px #ededed; } .embody_b{ margin:0 ; padding:10px 0; } .embody .embody_t,.embody .embody_c{ display: inline-block; margin-right:10px; } .embody_t{ font-size: 12px; color:#999; } .embody_c{ font-size: 12px; } .embody_c img,.embody_c em{ display: inline-block; vertical-align: middle; } .embody_c img{ width:30px; height:30px; } .embody_c em{ margin: 0 20px 0 10px; color:#333; font-style: normal; } </style> <script type="text/javascript"> $(function () { try { var lib = eval("("+$("#lib").attr("value")+")"); var html = ""; if (lib.err == 0) { $.each(lib.data,function (i) { var obj = lib.data[i]; //html += '<img src="' + obj.logo + '"/>' + obj.name + "&nbsp;&nbsp;"; html += ' <a href="' + obj.url + '" target="_blank">'; html += ' <img src="' + obj.logo + '">'; html += ' <em><b>' + obj.name + '</b></em>'; html += ' </a>'; }); if (html != "") { setTimeout(function () { $("#lib").html(html); $("#embody").show(); },100); } } } catch (err) { } }); </script> <script type="text/javascript" src="http://static.blog.csdn.net/scripts/category.js"></script> <div style="clear:both"></div><div style="border:solid 1px #ccc; background:#eee; float:left; min-width:200px;padding:4px 10px;"><p style="text-align:right;margin:0;"><span style="float:left;">目录<a href="#" title="系统根据文章中H1到H6标签自动生成文章目录">(?)</a></span><a href="#" onclick="javascript:return openct(this);" title="展开">[+]</a></p><ol style="display:none;margin-left:14px;padding-left:14px;line-height:160%;"><li><a href="#t0"> 1&nbsp;&nbsp;&nbsp;查询与判断表</a></li><li><a href="#t1">查询与判断列</a></li><li><a href="#t2"> 3&nbsp;&nbsp;&nbsp;sqlite中新增删除重命名列</a></li><ol><li><a href="#t3"> </a></li><li><a href="#t4">1&nbsp;&nbsp;&nbsp;新增一列</a></li><li><a href="#t5">2&nbsp;&nbsp;&nbsp;删除一列</a></li><li><a href="#t6"> 33&nbsp;&nbsp;&nbsp;重命名一列</a></li></ol><li><a href="#t7"> 4&nbsp;&nbsp;&nbsp;sqlite中新增删除重命名表</a></li><ol><li><a href="#t8"> 41&nbsp;&nbsp;&nbsp;新增表</a></li><li><a href="#t9"> 42&nbsp;&nbsp;&nbsp;删除表</a></li><li><a href="#t10"> 43&nbsp;&nbsp;&nbsp;重命名表</a></li></ol></ol></div><div style="clear:both"></div><div id="article_content" class="article_content"> <p><span style="color:rgb(51,51,51); line-height:26px; font-family:微软雅黑; font-size:14px; orphans:2; widows:2">&nbsp; sqlite会自动维护一个系统表</span><span style="line-height:26px; font-family:微软雅黑; font-size:14px; orphans:2; widows:2"><span style="color:rgb(255,0)">sqlite_master</span></span><span style="color:rgb(51,51); line-height:26px; font-family:微软雅黑; font-size:14px; orphans:2; widows:2">,该表存储了我们所创建的各个table,view,trigger等等信息。</span></p> <p><span style="color:rgb(51,51); line-height:26px; font-family:微软雅黑; font-size:14px; orphans:2; widows:2">sqlite_master表数据字段:</span></p> <div style="color:rgb(51,51); line-height:26px; font-family:微软雅黑; font-size:14px; orphans:2; widows:2"> <span style="font-family:Monaco; font-size:10px"><span style="font-family:Arial; font-size:14px">type: &nbsp;类型,取值一般为table,view</span></span></div> <div style="color:rgb(51,51); line-height:26px; font-family:微软雅黑; font-size:14px; orphans:2; widows:2"> <span style="font-family:Monaco; font-size:10px"><span style="font-family:Arial; font-size:14px">name: &nbsp; &nbsp;</span></span></div> <div style="color:rgb(51,51); line-height:26px; font-family:微软雅黑; font-size:14px; orphans:2; widows:2"> <span style="font-family:Monaco; font-size:10px"><span style="font-family:Arial; font-size:14px">tbl_name: &nbsp; 表名</span></span></div> <div style="color:rgb(51,51); line-height:26px; font-family:微软雅黑; font-size:14px; orphans:2; widows:2"> <span style="font-family:Monaco; font-size:10px"><span style="font-family:Arial; font-size:14px">rootpage:</span></span></div> <p></p> <p style="color:rgb(51,51); line-height:26px; font-family:微软雅黑; font-size:14px; orphans:2; widows:2"> <span style="font-family:Monaco; font-size:10px"><span style="font-family:Arial; font-size:14px">sql:创建表或者视图的sql语句,可以从该sql语句中判断某字段是否存在</span></span></p> <br> <p><span style="color:rgb(51,51); line-height:26px; font-family:Arial; font-size:18px">sqlite_master表结构如下:</span><br> </p> <p><span style="color:rgb(51,51); line-height:26px; font-family:Arial; font-size:18px"></span></p> <div class="dp-Highlighter bg_sql"> <div class="bar"> <div class="tools"><strong>[sql]</strong> <a target="_blank" title="view plain" class="ViewSource" href="http://blog.csdn.net/wuyou1336/article/details/53770799#"> view plain</a><span> <a target="_blank" title="copy" class="CopyToClipboard" href="http://blog.csdn.net/wuyou1336/article/details/53770799#"> copy</a><div style="position: absolute; left: 740px; top: 863px; width: 18px; height: 18px; z-index: 99;"><embed id="ZeroClipboardMovie_1" src="http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf" loop="false" menu="false" quality="best" bgcolor="#ffffff" width="18" height="18" name="ZeroClipboardMovie_1" align="middle" allowscriptaccess="always" allowfullscreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="id=1&amp;width=18&amp;height=18" wmode="transparent"></div></span><span> <a target="_blank" title="print" class="PrintSource" href="http://blog.csdn.net/wuyou1336/article/details/53770799#"> print</a></span><a target="_blank" title="?" class="About" href="http://blog.csdn.net/wuyou1336/article/details/53770799#">?</a><span class="tracking-ad"><a target="_blank" title="在CODE上查看代码片" href="https://code.csdn.net/snippets/2064732"><img width="12" height="12" alt="在CODE上查看代码片" src="https://code.csdn.net/assets/CODE_ico.png" style="left:2px; top:1px; position:relative"></a></span><span class="tracking-ad"><a target="_blank" title="派生到我的代码片" href="https://code.csdn.net/snippets/2064732/fork"><img width="12" height="12" alt="派生到我的代码片" src="https://code.csdn.net/assets/ico_fork.svg" style="left:2px; top:2px; position:relative"></a></span></div> </div> <ol class="dp-sql"> <li class="alt"><span class="keyword">CREATE</span>&nbsp;<span class="keyword">TABLE</span>&nbsp;sqlite_master&nbsp;(&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</li><li>type&nbsp;TEXT,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</li><li class="alt"><span class="keyword">name</span>&nbsp;TEXT,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</li><li>tbl_name&nbsp;TEXT,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</li><li class="alt">rootpage&nbsp;<span class="keyword">INTEGER</span>,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</li><li>sql&nbsp;TEXT&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</li><li class="alt">);&nbsp;&nbsp;&nbsp;</li></ol> <div class="save_code tracking-ad" style="display: none;"><a target="_blank"><img src="http://static.blog.csdn.net/images/save_snippets.png" alt=""></a></div> <div class="save_code tracking-ad" data-mod="popu_249" style="display: none;"><a href="javascript:;" target="_blank"><img src="http://static.blog.csdn.net/images/save_snippets.png"></a></div></div> <div class="dp-Highlighter bg_sql"><div class="bar"><div class="tools"><b>[sql]</b> <a href="#" class="ViewSource" title="view plain" onclick="dp.sh.Toolbar.Command('ViewSource',this);return false;">view plain</a><span data-mod="popu_168"> <a href="#" class="CopyToClipboard" title="copy" onclick="dp.sh.Toolbar.Command('CopyToClipboard',this);return false;">copy</a><div style="position: absolute; left: 740px; top: 1040px; width: 18px; height: 18px; z-index: 99;"><embed id="ZeroClipboardMovie_2" src="http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf" loop="false" menu="false" quality="best" bgcolor="#ffffff" width="18" height="18" name="ZeroClipboardMovie_2" align="middle" allowscriptaccess="always" allowfullscreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="id=2&amp;width=18&amp;height=18" wmode="transparent"></div></span><span data-mod="popu_169"> <a href="#" class="PrintSource" title="print" onclick="dp.sh.Toolbar.Command('PrintSource',this);return false;">print</a></span><a href="#" class="About" title="?" onclick="dp.sh.Toolbar.Command('About',this);return false;">?</a><span class="tracking-ad" data-mod="popu_167"><a href="https://code.csdn.net/snippets/2064732" target="_blank" title="在CODE上查看代码片" style="text-indent:0;"><img src="https://code.csdn.net/assets/CODE_ico.png" width="12" height="12" alt="在CODE上查看代码片" style="position:relative;top:1px;left:2px;"></a></span><span class="tracking-ad" data-mod="popu_170"><a href="https://code.csdn.net/snippets/2064732/fork" target="_blank" title="派生到我的代码片" style="text-indent:0;"><img src="https://code.csdn.net/assets/ico_fork.svg" width="12" height="12" alt="派生到我的代码片" style="position:relative;top:2px;left:2px;"></a></span></div></div><ol start="1" class="dp-sql"><li class="alt"><span><span class="keyword">CREATE</span><span>&nbsp;</span><span class="keyword">TABLE</span><span>&nbsp;sqlite_master&nbsp;(&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></span></li><li class=""><span>type&nbsp;TEXT,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></li><li class="alt"><span><span class="keyword">name</span><span>&nbsp;TEXT,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></span></li><li class=""><span>tbl_name&nbsp;TEXT,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></li><li class="alt"><span>rootpage&nbsp;<span class="keyword">INTEGER</span><span>,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></span></li><li class=""><span>sql&nbsp;TEXT&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></li><li class="alt"><span>);&nbsp;&nbsp;&nbsp;</span></li></ol><div class="save_code tracking-ad" data-mod="popu_249" style="display: none;"><a href="javascript:;" target="_blank"><img src="http://static.blog.csdn.net/images/save_snippets.png"></a></div></div><pre code_snippet_id="2064732" snippet_file_name="blog_20161220_1_2322816" class="sql" style="display: none;" name="code">CREATE TABLE sqlite_master ( type TEXT,name TEXT,tbl_name TEXT,rootpage INTEGER,sql TEXT ); </pre> <p></p> <p><span style="color:rgb(51,51); line-height:26px; font-family:Arial; font-size:18px"><br> </span></p> 例如: <p><span style="color:rgb(51,51); line-height:26px; font-family:Arial; font-size:18px"></span></p> <div class="dp-Highlighter bg_sql"> <div class="bar"> <div class="tools"><strong>[sql]</strong> <a target="_blank" title="view plain" class="ViewSource" href="http://blog.csdn.net/wuyou1336/article/details/53770799#"> view plain</a><span> <a target="_blank" title="copy" class="CopyToClipboard" href="http://blog.csdn.net/wuyou1336/article/details/53770799#"> copy</a><div style="position: absolute; left: 740px; top: 1296px; width: 18px; height: 18px; z-index: 99;"><embed id="ZeroClipboardMovie_3" src="http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf" loop="false" menu="false" quality="best" bgcolor="#ffffff" width="18" height="18" name="ZeroClipboardMovie_3" align="middle" allowscriptaccess="always" allowfullscreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="id=3&amp;width=18&amp;height=18" wmode="transparent"></div></span><span> <a target="_blank" title="print" class="PrintSource" href="http://blog.csdn.net/wuyou1336/article/details/53770799#"> print</a></span><a target="_blank" title="?" class="About" href="http://blog.csdn.net/wuyou1336/article/details/53770799#">?</a><span class="tracking-ad"><a target="_blank" title="在CODE上查看代码片" href="https://code.csdn.net/snippets/2064732"><img width="12" height="12" alt="在CODE上查看代码片" src="https://code.csdn.net/assets/CODE_ico.png" style="left:2px; top:1px; position:relative"></a></span><span class="tracking-ad"><a target="_blank" title="派生到我的代码片" href="https://code.csdn.net/snippets/2064732/fork"><img width="12" height="12" alt="派生到我的代码片" src="https://code.csdn.net/assets/ico_fork.svg" style="left:2px; top:2px; position:relative"></a></span></div> </div> <ol class="dp-sql"> <li class="alt"><span class="keyword">select</span>&nbsp;*&nbsp;<span class="keyword">from</span>&nbsp;sqlite_master&nbsp;<span class="keyword">where</span>&nbsp;type&nbsp;=&nbsp;<span class="string">'table'</span>&nbsp;<span class="op">and</span>&nbsp;<span class="keyword">name</span>&nbsp;=&nbsp;<span class="string">'t_cmpt_cp'</span>&nbsp;&nbsp;</li></ol> <div class="save_code tracking-ad" style=""><a target="_blank"><img src="http://static.blog.csdn.net/images/save_snippets_01.png" alt=""></a></div> <div class="save_code tracking-ad" data-mod="popu_249"><a href="javascript:;" target="_blank"><img src="http://static.blog.csdn.net/images/save_snippets.png"></a></div></div> <div class="dp-Highlighter bg_sql"><div class="bar"><div class="tools"><b>[sql]</b> <a href="#" class="ViewSource" title="view plain" onclick="dp.sh.Toolbar.Command('ViewSource',this);return false;">copy</a><div style="position: absolute; left: 740px; top: 1365px; width: 18px; height: 18px; z-index: 99;"><embed id="ZeroClipboardMovie_4" src="http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf" loop="false" menu="false" quality="best" bgcolor="#ffffff" width="18" height="18" name="ZeroClipboardMovie_4" align="middle" allowscriptaccess="always" allowfullscreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="id=4&amp;width=18&amp;height=18" wmode="transparent"></div></span><span data-mod="popu_169"> <a href="#" class="PrintSource" title="print" onclick="dp.sh.Toolbar.Command('PrintSource',this);return false;">?</a><span class="tracking-ad" data-mod="popu_167"><a href="https://code.csdn.net/snippets/2064732" target="_blank" title="在CODE上查看代码片" style="text-indent:0;"><img src="https://code.csdn.net/assets/CODE_ico.png" width="12" height="12" alt="在CODE上查看代码片" style="position:relative;top:1px;left:2px;"></a></span><span class="tracking-ad" data-mod="popu_170"><a href="https://code.csdn.net/snippets/2064732/fork" target="_blank" title="派生到我的代码片" style="text-indent:0;"><img src="https://code.csdn.net/assets/ico_fork.svg" width="12" height="12" alt="派生到我的代码片" style="position:relative;top:2px;left:2px;"></a></span></div></div><ol start="1" class="dp-sql"><li class="alt"><span><span class="keyword">select</span><span>&nbsp;*&nbsp;</span><span class="keyword">from</span><span>&nbsp;sqlite_master&nbsp;</span><span class="keyword">where</span><span>&nbsp;type&nbsp;=&nbsp;</span><span class="string">'table'</span><span>&nbsp;</span><span class="op">and</span><span>&nbsp;</span><span class="keyword">name</span><span>&nbsp;=&nbsp;</span><span class="string">'t_cmpt_cp'</span><span>&nbsp;&nbsp;</span></span></li></ol><div class="save_code tracking-ad" data-mod="popu_249"><a href="javascript:;" target="_blank"><img src="http://static.blog.csdn.net/images/save_snippets.png"></a></div></div><pre code_snippet_id="2064732" snippet_file_name="blog_20161220_2_7557477" class="sql" style="display: none;" name="code">select * from sqlite_master where type = 'table' and name = 't_cmpt_cp'</pre>sql执行结果是: <p></p> <p><span style="line-height:26px; font-family:Arial"><span style="color:rgb(51,51); font-size:18px"><img alt="" src="http://img.blog.csdn.net/20161220223812079?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvd3V5b3UxMzM2/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center"></span><br> <br> </span></p> <h1 style="margin:0px; padding:0px; line-height:26px; font-family:Arial; font-size:18px"><a name="t0"></a> <a target="_blank" name="t0"></a><span style="color:rgb(51,51)">1.&nbsp;&nbsp;&nbsp;查询与判断</span><span style="color:rgb(255,102,102)">表</span></h1> <div style="font-size:18px"><span style="color:rgb(255,102)"><br> </span></div> <p></p> <p style="color:rgb(51,51); line-height:26px; padding-top:0px; padding-bottom:0px; font-family:Arial; font-size:14px; margin-top:0px; margin-bottom:0px"> 查询sqlite中所有表,可用如下sql语句。</p> <p style="color:rgb(51,51); line-height:26px; padding-top:0px; padding-bottom:0px; font-family:Arial; font-size:14px; margin-top:0px; margin-bottom:0px"> </p> <div class="dp-Highlighter bg_sql"> <div class="bar"> <div class="tools"><strong>[sql]</strong> <a target="_blank" title="view plain" class="ViewSource" href="http://blog.csdn.net/wuyou1336/article/details/53770799#"> view plain</a><span> <a target="_blank" title="copy" class="CopyToClipboard" href="http://blog.csdn.net/wuyou1336/article/details/53770799#"> copy</a><div style="position: absolute; left: 740px; top: 1673px; width: 18px; height: 18px; z-index: 99;"><embed id="ZeroClipboardMovie_5" src="http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf" loop="false" menu="false" quality="best" bgcolor="#ffffff" width="18" height="18" name="ZeroClipboardMovie_5" align="middle" allowscriptaccess="always" allowfullscreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="id=5&amp;width=18&amp;height=18" wmode="transparent"></div></span><span> <a target="_blank" title="print" class="PrintSource" href="http://blog.csdn.net/wuyou1336/article/details/53770799#"> print</a></span><a target="_blank" title="?" class="About" href="http://blog.csdn.net/wuyou1336/article/details/53770799#">?</a><span class="tracking-ad"><a target="_blank" title="在CODE上查看代码片" href="https://code.csdn.net/snippets/2064732"><img width="12" height="12" alt="在CODE上查看代码片" src="https://code.csdn.net/assets/CODE_ico.png" style="left:2px; top:1px; position:relative"></a></span><span class="tracking-ad"><a target="_blank" title="派生到我的代码片" href="https://code.csdn.net/snippets/2064732/fork"><img width="12" height="12" alt="派生到我的代码片" src="https://code.csdn.net/assets/ico_fork.svg" style="left:2px; top:2px; position:relative"></a></span></div> </div> <ol class="dp-sql"> <li class="alt"><span class="keyword">select</span>&nbsp;<span class="keyword">name</span>&nbsp;<span class="keyword">from</span>&nbsp;sqlite_master&nbsp;<span class="keyword">where</span>&nbsp;type=<span class="string">'table'</span>&nbsp;<span class="keyword">order</span>&nbsp;<span class="keyword">by</span>&nbsp;<span class="keyword">name</span>;&nbsp;&nbsp;</li></ol> <div class="save_code tracking-ad"><a target="_blank"><img src="http://static.blog.csdn.net/images/save_snippets.png" alt=""></a></div> <div class="save_code tracking-ad" data-mod="popu_249"><a href="javascript:;" target="_blank"><img src="http://static.blog.csdn.net/images/save_snippets.png"></a></div></div> <div class="dp-Highlighter bg_sql"><div class="bar"><div class="tools"><b>[sql]</b> <a href="#" class="ViewSource" title="view plain" onclick="dp.sh.Toolbar.Command('ViewSource',this);return false;">copy</a><div style="position: absolute; left: 740px; top: 1742px; width: 18px; height: 18px; z-index: 99;"><embed id="ZeroClipboardMovie_6" src="http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf" loop="false" menu="false" quality="best" bgcolor="#ffffff" width="18" height="18" name="ZeroClipboardMovie_6" align="middle" allowscriptaccess="always" allowfullscreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="id=6&amp;width=18&amp;height=18" wmode="transparent"></div></span><span data-mod="popu_169"> <a href="#" class="PrintSource" title="print" onclick="dp.sh.Toolbar.Command('PrintSource',this);return false;">?</a><span class="tracking-ad" data-mod="popu_167"><a href="https://code.csdn.net/snippets/2064732" target="_blank" title="在CODE上查看代码片" style="text-indent:0;"><img src="https://code.csdn.net/assets/CODE_ico.png" width="12" height="12" alt="在CODE上查看代码片" style="position:relative;top:1px;left:2px;"></a></span><span class="tracking-ad" data-mod="popu_170"><a href="https://code.csdn.net/snippets/2064732/fork" target="_blank" title="派生到我的代码片" style="text-indent:0;"><img src="https://code.csdn.net/assets/ico_fork.svg" width="12" height="12" alt="派生到我的代码片" style="position:relative;top:2px;left:2px;"></a></span></div></div><ol start="1" class="dp-sql"><li class="alt"><span><span class="keyword">select</span><span>&nbsp;</span><span class="keyword">name</span><span>&nbsp;</span><span class="keyword">from</span><span>&nbsp;sqlite_master&nbsp;</span><span class="keyword">where</span><span>&nbsp;type=</span><span class="string">'table'</span><span>&nbsp;</span><span class="keyword">order</span><span>&nbsp;</span><span class="keyword">by</span><span>&nbsp;</span><span class="keyword">name</span><span>;&nbsp;&nbsp;</span></span></li></ol><div class="save_code tracking-ad" data-mod="popu_249" style="display: none;"><a href="javascript:;" target="_blank"><img src="http://static.blog.csdn.net/images/save_snippets_01.png"></a></div></div><pre code_snippet_id="2064732" snippet_file_name="blog_20161220_3_2683454" class="sql" style="display: none;" name="code">select name from sqlite_master where type='table' order by name;</pre> <p></p> <p style="color:rgb(51,51); line-height:26px; padding-top:0px; padding-bottom:0px; font-family:Arial; font-size:14px; margin-top:0px; margin-bottom:0px"> <br> </p> <p style="color:rgb(51,51); line-height:26px; padding-top:0px; padding-bottom:0px; font-family:Arial; font-size:14px; margin-top:0px; margin-bottom:0px"> 我们可以通过如下语句查看这个内建表的所有记录:</p> <p style="color:rgb(51,51); line-height:26px; padding-top:0px; padding-bottom:0px; font-family:Arial; font-size:14px; margin-top:0px; margin-bottom:0px"> </p> <div class="dp-Highlighter bg_sql"> <div class="bar"> <div class="tools"><strong>[sql]</strong> <a target="_blank" title="view plain" class="ViewSource" href="http://blog.csdn.net/wuyou1336/article/details/53770799#"> view plain</a><span> <a target="_blank" title="copy" class="CopyToClipboard" href="http://blog.csdn.net/wuyou1336/article/details/53770799#"> copy</a><div style="position: absolute; left: 740px; top: 1907px; width: 18px; height: 18px; z-index: 99;"><embed id="ZeroClipboardMovie_7" src="http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf" loop="false" menu="false" quality="best" bgcolor="#ffffff" width="18" height="18" name="ZeroClipboardMovie_7" align="middle" allowscriptaccess="always" allowfullscreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="id=7&amp;width=18&amp;height=18" wmode="transparent"></div></span><span> <a target="_blank" title="print" class="PrintSource" href="http://blog.csdn.net/wuyou1336/article/details/53770799#"> print</a></span><a target="_blank" title="?" class="About" href="http://blog.csdn.net/wuyou1336/article/details/53770799#">?</a><span class="tracking-ad"><a target="_blank" title="在CODE上查看代码片" href="https://code.csdn.net/snippets/2064732"><img width="12" height="12" alt="在CODE上查看代码片" src="https://code.csdn.net/assets/CODE_ico.png" style="left:2px; top:1px; position:relative"></a></span><span class="tracking-ad"><a target="_blank" title="派生到我的代码片" href="https://code.csdn.net/snippets/2064732/fork"><img width="12" height="12" alt="派生到我的代码片" src="https://code.csdn.net/assets/ico_fork.svg" style="left:2px; top:2px; position:relative"></a></span></div> </div> <ol class="dp-sql"> <li class="alt"><span class="keyword">select</span>&nbsp;*&nbsp;<span class="keyword">from</span>&nbsp;sqlite_master&nbsp;&nbsp;</li></ol> <div class="save_code tracking-ad"><a target="_blank"><img src="http://static.blog.csdn.net/images/save_snippets.png" alt=""></a></div> <div class="save_code tracking-ad" data-mod="popu_249"><a href="javascript:;" target="_blank"><img src="http://static.blog.csdn.net/images/save_snippets.png"></a></div></div> <div class="dp-Highlighter bg_sql"><div class="bar"><div class="tools"><b>[sql]</b> <a href="#" class="ViewSource" title="view plain" onclick="dp.sh.Toolbar.Command('ViewSource',this);return false;">copy</a><div style="position: absolute; left: 740px; top: 1976px; width: 18px; height: 18px; z-index: 99;"><embed id="ZeroClipboardMovie_8" src="http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf" loop="false" menu="false" quality="best" bgcolor="#ffffff" width="18" height="18" name="ZeroClipboardMovie_8" align="middle" allowscriptaccess="always" allowfullscreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="id=8&amp;width=18&amp;height=18" wmode="transparent"></div></span><span data-mod="popu_169"> <a href="#" class="PrintSource" title="print" onclick="dp.sh.Toolbar.Command('PrintSource',this);return false;">?</a><span class="tracking-ad" data-mod="popu_167"><a href="https://code.csdn.net/snippets/2064732" target="_blank" title="在CODE上查看代码片" style="text-indent:0;"><img src="https://code.csdn.net/assets/CODE_ico.png" width="12" height="12" alt="在CODE上查看代码片" style="position:relative;top:1px;left:2px;"></a></span><span class="tracking-ad" data-mod="popu_170"><a href="https://code.csdn.net/snippets/2064732/fork" target="_blank" title="派生到我的代码片" style="text-indent:0;"><img src="https://code.csdn.net/assets/ico_fork.svg" width="12" height="12" alt="派生到我的代码片" style="position:relative;top:2px;left:2px;"></a></span></div></div><ol start="1" class="dp-sql"><li class="alt"><span><span class="keyword">select</span><span>&nbsp;*&nbsp;</span><span class="keyword">from</span><span>&nbsp;sqlite_master&nbsp;&nbsp;</span></span></li></ol><div class="save_code tracking-ad" data-mod="popu_249"><a href="javascript:;" target="_blank"><img src="http://static.blog.csdn.net/images/save_snippets.png"></a></div></div><pre code_snippet_id="2064732" snippet_file_name="blog_20161220_4_3141585" class="sql" style="display: none;" name="code">select * from sqlite_master</pre> <p></p> <p style="color:rgb(51,51); line-height:26px; padding-top:0px; padding-bottom:0px; font-family:Arial; font-size:14px; margin-top:0px; margin-bottom:0px"> 执行结果:</p> <p style="color:rgb(51,51); line-height:26px; padding-top:0px; padding-bottom:0px; font-family:Arial; font-size:14px; margin-top:0px; margin-bottom:0px"> <img alt="" src="http://img.blog.csdn.net/20161220224210581?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvd3V5b3UxMzM2/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center"><br> </p> <p style="color:rgb(51,51); line-height:26px; padding-top:0px; padding-bottom:0px; font-family:Arial; font-size:14px; margin-top:0px; margin-bottom:0px"> 由此可以进一步引申:判断指定的表是否存在,可以用如下语句:</p> <p style="color:rgb(51,51); line-height:26px; padding-top:0px; padding-bottom:0px; font-family:Arial; font-size:14px; margin-top:0px; margin-bottom:0px"> </p> <div class="dp-Highlighter bg_sql"> <div class="bar"> <div class="tools"><strong>[sql]</strong> <a target="_blank" title="view plain" class="ViewSource" href="http://blog.csdn.net/wuyou1336/article/details/53770799#"> view plain</a><span> <a target="_blank" title="copy" class="CopyToClipboard" href="http://blog.csdn.net/wuyou1336/article/details/53770799#"> copy</a><div style="position: absolute; left: 740px; top: 2337px; width: 18px; height: 18px; z-index: 99;"><embed id="ZeroClipboardMovie_9" src="http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf" loop="false" menu="false" quality="best" bgcolor="#ffffff" width="18" height="18" name="ZeroClipboardMovie_9" align="middle" allowscriptaccess="always" allowfullscreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="id=9&amp;width=18&amp;height=18" wmode="transparent"></div></span><span> <a target="_blank" title="print" class="PrintSource" href="http://blog.csdn.net/wuyou1336/article/details/53770799#"> print</a></span><a target="_blank" title="?" class="About" href="http://blog.csdn.net/wuyou1336/article/details/53770799#">?</a><span class="tracking-ad"><a target="_blank" title="在CODE上查看代码片" href="https://code.csdn.net/snippets/2064732"><img width="12" height="12" alt="在CODE上查看代码片" src="https://code.csdn.net/assets/CODE_ico.png" style="left:2px; top:1px; position:relative"></a></span><span class="tracking-ad"><a target="_blank" title="派生到我的代码片" href="https://code.csdn.net/snippets/2064732/fork"><img width="12" height="12" alt="派生到我的代码片" src="https://code.csdn.net/assets/ico_fork.svg" style="left:2px; top:2px; position:relative"></a></span></div> </div> <ol class="dp-sql"> <li class="alt"><span class="keyword">select</span>&nbsp;<span class="func">count</span>(*)&nbsp;&nbsp;<span class="keyword">from</span>&nbsp;sqlite_master&nbsp;<span class="keyword">where</span>&nbsp;type=<span class="string">'table'</span>&nbsp;<span class="op">and</span>&nbsp;<span class="keyword">name</span>&nbsp;=&nbsp;<span class="string">'yourtablename'</span>;&nbsp;&nbsp;</li></ol> <div class="save_code tracking-ad"><a target="_blank"><img src="http://static.blog.csdn.net/images/save_snippets.png" alt=""></a></div> <div class="save_code tracking-ad" data-mod="popu_249"><a href="javascript:;" target="_blank"><img src="http://static.blog.csdn.net/images/save_snippets.png"></a></div></div> <div class="dp-Highlighter bg_sql"><div class="bar"><div class="tools"><b>[sql]</b> <a href="#" class="ViewSource" title="view plain" onclick="dp.sh.Toolbar.Command('ViewSource',this);return false;">copy</a><div style="position: absolute; left: 740px; top: 2406px; width: 18px; height: 18px; z-index: 99;"><embed id="ZeroClipboardMovie_10" src="http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf" loop="false" menu="false" quality="best" bgcolor="#ffffff" width="18" height="18" name="ZeroClipboardMovie_10" align="middle" allowscriptaccess="always" allowfullscreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="id=10&amp;width=18&amp;height=18" wmode="transparent"></div></span><span data-mod="popu_169"> <a href="#" class="PrintSource" title="print" onclick="dp.sh.Toolbar.Command('PrintSource',this);return false;">?</a><span class="tracking-ad" data-mod="popu_167"><a href="https://code.csdn.net/snippets/2064732" target="_blank" title="在CODE上查看代码片" style="text-indent:0;"><img src="https://code.csdn.net/assets/CODE_ico.png" width="12" height="12" alt="在CODE上查看代码片" style="position:relative;top:1px;left:2px;"></a></span><span class="tracking-ad" data-mod="popu_170"><a href="https://code.csdn.net/snippets/2064732/fork" target="_blank" title="派生到我的代码片" style="text-indent:0;"><img src="https://code.csdn.net/assets/ico_fork.svg" width="12" height="12" alt="派生到我的代码片" style="position:relative;top:2px;left:2px;"></a></span></div></div><ol start="1" class="dp-sql"><li class="alt"><span><span class="keyword">select</span><span>&nbsp;</span><span class="func">count</span><span>(*)&nbsp;&nbsp;</span><span class="keyword">from</span><span>&nbsp;sqlite_master&nbsp;</span><span class="keyword">where</span><span>&nbsp;type=</span><span class="string">'table'</span><span>&nbsp;</span><span class="op">and</span><span>&nbsp;</span><span class="keyword">name</span><span>&nbsp;=&nbsp;</span><span class="string">'yourtablename'</span><span>;&nbsp;&nbsp;</span></span></li></ol><div class="save_code tracking-ad" data-mod="popu_249"><a href="javascript:;" target="_blank"><img src="http://static.blog.csdn.net/images/save_snippets.png"></a></div></div><pre code_snippet_id="2064732" snippet_file_name="blog_20161220_5_394133" class="sql" style="display: none;" name="code">select count(*) from sqlite_master where type='table' and name = 'yourtablename';</pre><br> <p></p> <p style="color:rgb(51,51); line-height:26px; padding-top:0px; padding-bottom:0px; font-family:Arial; font-size:14px; margin-top:0px; margin-bottom:0px"> 或者</p> <p style="color:rgb(51,51); line-height:26px; padding-top:0px; padding-bottom:0px; font-family:Arial; font-size:14px; margin-top:0px; margin-bottom:0px"> 其中yourtablename表示你要判断的表名,如果查询结果大于0,表示该表存在于<a target="_blank" title="MysqL知识库" class="replace_word" href="http://lib.csdn.net/base/MysqL" style="color:rgb(223,52,52); font-weight:bold; text-decoration:none">数据库</a>中,否则不存在。</p> <p style="color:rgb(51,51); line-height:26px; padding-top:0px; padding-bottom:0px; font-family:Arial; font-size:14px; margin-top:0px; margin-bottom:0px"> </p> <h1 style="margin:0px; padding:0px; line-height:26px; font-family:Arial"><a name="t1"></a><a target="_blank" name="t1"></a>2.&nbsp;&nbsp;&nbsp;查询与判断<span style="color:rgb(255,102)">列</span></h1> <p></p> <p style="line-height:26px; padding-top:0px; padding-bottom:0px; font-family:Arial; font-size:14px; margin-top:0px; margin-bottom:0px"> 通过以下语句可查询出某个表的所有字段信息</p> <p style="line-height:26px; padding-top:0px; padding-bottom:0px; font-family:Arial; font-size:14px; margin-top:0px; margin-bottom:0px"> PRAGMA &nbsp;table_info([tablename])</p> <p style="line-height:26px; padding-top:0px; padding-bottom:0px; font-family:Arial; font-size:14px; margin-top:0px; margin-bottom:0px"> &nbsp;</p> <p style="line-height:26px; padding-top:0px; padding-bottom:0px; font-family:Arial; font-size:14px; margin-top:0px; margin-bottom:0px"> 比如:我想查看表catalog的所有列信息,可以用下述代码,结果如图所示:</p> PRAGMA &nbsp;table_info(t_cmpt_cp)<br> <p style="color:rgb(51,51); line-height:26px; padding-top:0px; padding-bottom:0px; font-family:Arial; font-size:14px; margin-top:0px; margin-bottom:0px"> <img alt="" src="http://img.blog.csdn.net/20161220224539709?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvd3V5b3UxMzM2/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center"><br> </p> <p style="color:rgb(51,51); line-height:26px; padding-top:0px; padding-bottom:0px; font-family:Arial; font-size:14px; margin-top:0px; margin-bottom:0px"> 判断某列是否存在的方法:</p> <p style="color:rgb(51,51); line-height:26px; padding-top:0px; padding-bottom:0px; font-family:Arial; font-size:14px; margin-top:0px; margin-bottom:0px"> 方法1:</p> <p style="color:rgb(51,51); line-height:26px; padding-top:0px; padding-bottom:0px; font-family:Arial; font-size:14px; margin-top:0px; margin-bottom:0px"> </p> <div class="dp-Highlighter bg_java"> <div class="bar"> <div class="tools"><strong>[java]</strong> <a target="_blank" title="view plain" class="ViewSource" href="http://blog.csdn.net/wuyou1336/article/details/53770799#"> view plain</a><span> <a target="_blank" title="copy" class="CopyToClipboard" href="http://blog.csdn.net/wuyou1336/article/details/53770799#"> copy</a><div style="position: absolute; left: 750px; top: 3091px; width: 18px; height: 18px; z-index: 99;"><embed id="ZeroClipboardMovie_11" src="http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf" loop="false" menu="false" quality="best" bgcolor="#ffffff" width="18" height="18" name="ZeroClipboardMovie_11" align="middle" allowscriptaccess="always" allowfullscreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="id=11&amp;width=18&amp;height=18" wmode="transparent"></div></span><span> <a target="_blank" title="print" class="PrintSource" href="http://blog.csdn.net/wuyou1336/article/details/53770799#"> print</a></span><a target="_blank" title="?" class="About" href="http://blog.csdn.net/wuyou1336/article/details/53770799#">?</a><span class="tracking-ad"><a target="_blank" title="在CODE上查看代码片" href="https://code.csdn.net/snippets/2064732"><img width="12" height="12" alt="在CODE上查看代码片" src="https://code.csdn.net/assets/CODE_ico.png" style="left:2px; top:1px; position:relative"></a></span><span class="tracking-ad"><a target="_blank" title="派生到我的代码片" href="https://code.csdn.net/snippets/2064732/fork"><img width="12" height="12" alt="派生到我的代码片" src="https://code.csdn.net/assets/ico_fork.svg" style="left:2px; top:2px; position:relative"></a></span></div> </div> <ol class="dp-j"> <li class="alt"><span class="comment">/**</span>&nbsp;</li><li><span class="comment">*&nbsp;检查表中某列是否存在</span>&nbsp;</li><li class="alt"><span class="comment">*&nbsp;@param&nbsp;db</span>&nbsp;</li><li><span class="comment">*&nbsp;@param&nbsp;tableName&nbsp;表名</span>&nbsp;</li><li class="alt"><span class="comment">*&nbsp;@param&nbsp;columnName&nbsp;列名</span>&nbsp;</li><li><span class="comment">*&nbsp;@return</span>&nbsp;</li><li class="alt"><span class="comment">*/</span>&nbsp;&nbsp;</li><li><span class="keyword">private</span>&nbsp;<span class="keyword">boolean</span>&nbsp;checkColumnExists2(sqliteDatabase&nbsp;db,&nbsp;String&nbsp;tableName&nbsp;&nbsp;</li><li class="alt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;,&nbsp;String&nbsp;columnName)&nbsp;{&nbsp;&nbsp;</li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">boolean</span>&nbsp;result&nbsp;=&nbsp;<span class="keyword">false</span>&nbsp;;&nbsp;&nbsp;</li><li class="alt">&nbsp;&nbsp;&nbsp;&nbsp;Cursor&nbsp;cursor&nbsp;=&nbsp;<span class="keyword">null</span>&nbsp;;&nbsp;&nbsp;</li><li>&nbsp;&nbsp;</li><li class="alt">&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">try</span>{&nbsp;&nbsp;</li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cursor&nbsp;=&nbsp;db.rawQuery(&nbsp;<span class="string">"select&nbsp;*&nbsp;from&nbsp;sqlite_master&nbsp;where&nbsp;name&nbsp;=&nbsp;?&nbsp;and&nbsp;sql&nbsp;like&nbsp;?"</span>&nbsp;&nbsp;</li><li class="alt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;,&nbsp;<span class="keyword">new</span>&nbsp;String[]{tableName&nbsp;,&nbsp;<span class="string">"%"</span>&nbsp;+&nbsp;columnName&nbsp;+&nbsp;<span class="string">"%"</span>}&nbsp;);&nbsp;&nbsp;</li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;result&nbsp;=&nbsp;<span class="keyword">null</span>&nbsp;!=&nbsp;cursor&nbsp;&amp;&amp;&nbsp;cursor.moveToFirst()&nbsp;;&nbsp;&nbsp;</li><li class="alt">&nbsp;&nbsp;&nbsp;&nbsp;}<span class="keyword">catch</span>&nbsp;(Exception&nbsp;e){&nbsp;&nbsp;</li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Log.e(TAG,<span class="string">"checkColumnExists2..."</span>&nbsp;+&nbsp;e.getMessage())&nbsp;;&nbsp;&nbsp;</li><li class="alt">&nbsp;&nbsp;&nbsp;&nbsp;}<span class="keyword">finally</span>{&nbsp;&nbsp;</li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">if</span>(<span class="keyword">null</span>&nbsp;!=&nbsp;cursor&nbsp;&amp;&amp;&nbsp;!cursor.isClosed()){&nbsp;&nbsp;</li><li class="alt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cursor.close()&nbsp;;&nbsp;&nbsp;</li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</li><li class="alt">&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</li><li>&nbsp;&nbsp;</li><li class="alt">&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">return</span>&nbsp;result&nbsp;;&nbsp;&nbsp;</li><li>}&nbsp;&nbsp;</li></ol> <div class="save_code tracking-ad" style="display: none;"><a target="_blank"><img src="http://static.blog.csdn.net/images/save_snippets.png" alt=""></a></div> <div class="save_code tracking-ad" data-mod="popu_249" style="display: none;"><a href="javascript:;" target="_blank"><img src="http://static.blog.csdn.net/images/save_snippets.png"></a></div></div> <div class="dp-Highlighter bg_java"><div class="bar"><div class="tools"><b>[java]</b> <a href="#" class="ViewSource" title="view plain" onclick="dp.sh.Toolbar.Command('ViewSource',this);return false;">copy</a><div style="position: absolute; left: 750px; top: 3610px; width: 18px; height: 18px; z-index: 99;"><embed id="ZeroClipboardMovie_12" src="http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf" loop="false" menu="false" quality="best" bgcolor="#ffffff" width="18" height="18" name="ZeroClipboardMovie_12" align="middle" allowscriptaccess="always" allowfullscreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="id=12&amp;width=18&amp;height=18" wmode="transparent"></div></span><span data-mod="popu_169"> <a href="#" class="PrintSource" title="print" onclick="dp.sh.Toolbar.Command('PrintSource',this);return false;">?</a><span class="tracking-ad" data-mod="popu_167"><a href="https://code.csdn.net/snippets/2064732" target="_blank" title="在CODE上查看代码片" style="text-indent:0;"><img src="https://code.csdn.net/assets/CODE_ico.png" width="12" height="12" alt="在CODE上查看代码片" style="position:relative;top:1px;left:2px;"></a></span><span class="tracking-ad" data-mod="popu_170"><a href="https://code.csdn.net/snippets/2064732/fork" target="_blank" title="派生到我的代码片" style="text-indent:0;"><img src="https://code.csdn.net/assets/ico_fork.svg" width="12" height="12" alt="派生到我的代码片" style="position:relative;top:2px;left:2px;"></a></span></div></div><ol start="1" class="dp-j"><li class="alt"><span><span class="comment">/**</span>&nbsp;</span></li><li class=""><span><span class="comment">*&nbsp;检查表中某列是否存在</span>&nbsp;</span></li><li class="alt"><span><span class="comment">*&nbsp;@param&nbsp;db</span>&nbsp;</span></li><li class=""><span><span class="comment">*&nbsp;@param&nbsp;tableName&nbsp;表名</span>&nbsp;</span></li><li class="alt"><span><span class="comment">*&nbsp;@param&nbsp;columnName&nbsp;列名</span>&nbsp;</span></li><li class=""><span><span class="comment">*&nbsp;@return</span>&nbsp;</span></li><li class="alt"><span><span class="comment">*/</span><span>&nbsp;&nbsp;</span></span></li><li class=""><span><span class="keyword">private</span><span>&nbsp;</span><span class="keyword">boolean</span><span>&nbsp;checkColumnExists2(sqliteDatabase&nbsp;db,&nbsp;String&nbsp;tableName&nbsp;&nbsp;</span></span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;,&nbsp;String&nbsp;columnName)&nbsp;{&nbsp;&nbsp;</span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">boolean</span><span>&nbsp;result&nbsp;=&nbsp;</span><span class="keyword">false</span><span>&nbsp;;&nbsp;&nbsp;</span></span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;Cursor&nbsp;cursor&nbsp;=&nbsp;<span class="keyword">null</span><span>&nbsp;;&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;</span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">try</span><span>{&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cursor&nbsp;=&nbsp;db.rawQuery(&nbsp;<span class="string">"select&nbsp;*&nbsp;from&nbsp;sqlite_master&nbsp;where&nbsp;name&nbsp;=&nbsp;?&nbsp;and&nbsp;sql&nbsp;like&nbsp;?"</span><span>&nbsp;&nbsp;</span></span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;,&nbsp;<span class="keyword">new</span><span>&nbsp;String[]{tableName&nbsp;,&nbsp;</span><span class="string">"%"</span><span>&nbsp;+&nbsp;columnName&nbsp;+&nbsp;</span><span class="string">"%"</span><span>}&nbsp;);&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;result&nbsp;=&nbsp;<span class="keyword">null</span><span>&nbsp;!=&nbsp;cursor&nbsp;&amp;&amp;&nbsp;cursor.moveToFirst()&nbsp;;&nbsp;&nbsp;</span></span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;}<span class="keyword">catch</span><span>&nbsp;(Exception&nbsp;e){&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Log.e(TAG,<span class="string">"checkColumnExists2..."</span><span>&nbsp;+&nbsp;e.getMessage())&nbsp;;&nbsp;&nbsp;</span></span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;}<span class="keyword">finally</span><span>{&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">if</span><span>(</span><span class="keyword">null</span><span>&nbsp;!=&nbsp;cursor&nbsp;&amp;&amp;&nbsp;!cursor.isClosed()){&nbsp;&nbsp;</span></span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cursor.close()&nbsp;;&nbsp;&nbsp;</span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</span></li><li class=""><span>&nbsp;&nbsp;</span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">return</span><span>&nbsp;result&nbsp;;&nbsp;&nbsp;</span></span></li><li class=""><span>}&nbsp;&nbsp;</span></li></ol><div class="save_code tracking-ad" data-mod="popu_249" style="display: none;"><a href="javascript:;" target="_blank"><img src="http://static.blog.csdn.net/images/save_snippets.png"></a></div></div><pre code_snippet_id="2064732" snippet_file_name="blog_20161220_6_6915549" class="java" style="display: none;" name="code">/** * 检查表中某列是否存在 * @param db * @param tableName 表名 * @param columnName 列名 * @return */ private boolean checkColumnExists2(sqliteDatabase db,String tableName,String columnName) { boolean result = false ; Cursor cursor = null ; try{ cursor = db.rawQuery( "select * from sqlite_master where name = ? and sql like ?",new String[]{tableName,"%" + columnName + "%"} ); result = null != cursor &amp;&amp; cursor.moveToFirst() ; }catch (Exception e){ Log.e(TAG,"checkColumnExists2..." + e.getMessage()) ; }finally{ if(null != cursor &amp;&amp; !cursor.isClosed()){ cursor.close() ; } } return result ; }</pre> <p></p> <p style="color:rgb(51,51); line-height:26px; padding-top:0px; padding-bottom:0px; font-family:Arial; font-size:14px; margin-top:0px; margin-bottom:0px"> 方法2:<br> </p> <div class="dp-Highlighter bg_java"> <div class="bar"> <div class="tools"><strong>[java]</strong> <a target="_blank" title="view plain" class="ViewSource" href="http://blog.csdn.net/wuyou1336/article/details/53770799#"> view plain</a><span> <a target="_blank" title="copy" class="CopyToClipboard" href="http://blog.csdn.net/wuyou1336/article/details/53770799#"> copy</a><div style="position: absolute; left: 750px; top: 4173px; width: 18px; height: 18px; z-index: 99;"><embed id="ZeroClipboardMovie_13" src="http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf" loop="false" menu="false" quality="best" bgcolor="#ffffff" width="18" height="18" name="ZeroClipboardMovie_13" align="middle" allowscriptaccess="always" allowfullscreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="id=13&amp;width=18&amp;height=18" wmode="transparent"></div></span><span> <a target="_blank" title="print" class="PrintSource" href="http://blog.csdn.net/wuyou1336/article/details/53770799#"> print</a></span><a target="_blank" title="?" class="About" href="http://blog.csdn.net/wuyou1336/article/details/53770799#">?</a><span class="tracking-ad"><a target="_blank" title="在CODE上查看代码片" href="https://code.csdn.net/snippets/2064732"><img width="12" height="12" alt="在CODE上查看代码片" src="https://code.csdn.net/assets/CODE_ico.png" style="left:2px; top:1px; position:relative"></a></span><span class="tracking-ad"><a target="_blank" title="派生到我的代码片" href="https://code.csdn.net/snippets/2064732/fork"><img width="12" height="12" alt="派生到我的代码片" src="https://code.csdn.net/assets/ico_fork.svg" style="left:2px; top:2px; position:relative"></a></span></div> </div> <ol class="dp-j"> <li class="alt"><span class="comment">/**&nbsp;</span>&nbsp;</li><li><span class="comment">&nbsp;*&nbsp;判断某表里某字段是否存在&nbsp;</span>&nbsp;</li><li class="alt"><span class="comment">&nbsp;*&nbsp;&nbsp;</span>&nbsp;</li><li><span class="comment">&nbsp;*&nbsp;@param&nbsp;db&nbsp;</span>&nbsp;</li><li class="alt"><span class="comment">&nbsp;*&nbsp;@param&nbsp;tableName&nbsp;</span>&nbsp;</li><li><span class="comment">&nbsp;*&nbsp;@param&nbsp;fieldName&nbsp;</span>&nbsp;</li><li class="alt"><span class="comment">&nbsp;*&nbsp;@return&nbsp;</span>&nbsp;</li><li><span class="comment">&nbsp;*/</span>&nbsp;&nbsp;&nbsp;&nbsp;</li><li class="alt"><span class="keyword">private</span>&nbsp;<span class="keyword">boolean</span>&nbsp;isFieldExist(sqliteDatabase&nbsp;db,&nbsp;String&nbsp;tableName,&nbsp;String&nbsp;fieldName)&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;</li><li>&nbsp;&nbsp;&nbsp;&nbsp;String&nbsp;queryStr&nbsp;=&nbsp;<span class="string">"select&nbsp;sql&nbsp;from&nbsp;sqlite_master&nbsp;where&nbsp;type&nbsp;=&nbsp;'table'&nbsp;and&nbsp;name&nbsp;=&nbsp;'%s'"</span>;&nbsp;&nbsp;&nbsp;&nbsp;</li><li class="alt">&nbsp;&nbsp;&nbsp;&nbsp;queryStr&nbsp;=&nbsp;String.format(queryStr,&nbsp;tableName);&nbsp;&nbsp;&nbsp;&nbsp;</li><li>&nbsp;&nbsp;&nbsp;&nbsp;Cursor&nbsp;c&nbsp;=&nbsp;db.rawQuery(queryStr,&nbsp;<span class="keyword">null</span>);&nbsp;&nbsp;&nbsp;&nbsp;</li><li class="alt">&nbsp;&nbsp;&nbsp;&nbsp;String&nbsp;tableCreatesql&nbsp;=&nbsp;<span class="keyword">null</span>;&nbsp;&nbsp;&nbsp;&nbsp;</li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">try</span>&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;</li><li class="alt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">if</span>&nbsp;(c&nbsp;!=&nbsp;<span class="keyword">null</span>&nbsp;&amp;&amp;&nbsp;c.moveToFirst())&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;</li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;tableCreatesql&nbsp;=&nbsp;c.getString(c.getColumnIndex(<span class="string">"sql"</span>));&nbsp;&nbsp;&nbsp;&nbsp;</li><li class="alt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;&nbsp;&nbsp;</li><li>&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;<span class="keyword">finally</span>&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;</li><li class="alt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">if</span>&nbsp;(c&nbsp;!=&nbsp;<span class="keyword">null</span>)&nbsp;&nbsp;&nbsp;&nbsp;</li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;c.close();&nbsp;&nbsp;&nbsp;&nbsp;</li><li class="alt">&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;&nbsp;&nbsp;</li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">if</span>&nbsp;(tableCreatesql&nbsp;!=&nbsp;<span class="keyword">null</span>&nbsp;&amp;&amp;&nbsp;tableCreatesql.contains(fieldName))&nbsp;&nbsp;&nbsp;&nbsp;</li><li class="alt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">return</span>&nbsp;<span class="keyword">true</span>;&nbsp;&nbsp;&nbsp;&nbsp;</li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">return</span>&nbsp;<span class="keyword">false</span>;&nbsp;&nbsp;&nbsp;&nbsp;</li><li class="alt">}&nbsp;&nbsp;&nbsp;&nbsp;</li></ol> <div class="save_code tracking-ad" style="display: none;"><a target="_blank"><img src="http://static.blog.csdn.net/images/save_snippets.png" alt=""></a></div> <div class="save_code tracking-ad" data-mod="popu_249" style="display: none;"><a href="javascript:;" target="_blank"><img src="http://static.blog.csdn.net/images/save_snippets.png"></a></div></div> <div class="dp-Highlighter bg_java"><div class="bar"><div class="tools"><b>[java]</b> <a href="#" class="ViewSource" title="view plain" onclick="dp.sh.Toolbar.Command('ViewSource',this);return false;">copy</a><div style="position: absolute; left: 750px; top: 4674px; width: 18px; height: 18px; z-index: 99;"><embed id="ZeroClipboardMovie_14" src="http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf" loop="false" menu="false" quality="best" bgcolor="#ffffff" width="18" height="18" name="ZeroClipboardMovie_14" align="middle" allowscriptaccess="always" allowfullscreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="id=14&amp;width=18&amp;height=18" wmode="transparent"></div></span><span data-mod="popu_169"> <a href="#" class="PrintSource" title="print" onclick="dp.sh.Toolbar.Command('PrintSource',this);return false;">?</a><span class="tracking-ad" data-mod="popu_167"><a href="https://code.csdn.net/snippets/2064732" target="_blank" title="在CODE上查看代码片" style="text-indent:0;"><img src="https://code.csdn.net/assets/CODE_ico.png" width="12" height="12" alt="在CODE上查看代码片" style="position:relative;top:1px;left:2px;"></a></span><span class="tracking-ad" data-mod="popu_170"><a href="https://code.csdn.net/snippets/2064732/fork" target="_blank" title="派生到我的代码片" style="text-indent:0;"><img src="https://code.csdn.net/assets/ico_fork.svg" width="12" height="12" alt="派生到我的代码片" style="position:relative;top:2px;left:2px;"></a></span></div></div><ol start="1" class="dp-j"><li class="alt"><span><span class="comment">/**&nbsp;</span>&nbsp;</span></li><li class=""><span><span class="comment">&nbsp;*&nbsp;判断某表里某字段是否存在&nbsp;</span>&nbsp;</span></li><li class="alt"><span><span class="comment">&nbsp;*&nbsp;&nbsp;</span>&nbsp;</span></li><li class=""><span><span class="comment">&nbsp;*&nbsp;@param&nbsp;db&nbsp;</span>&nbsp;</span></li><li class="alt"><span><span class="comment">&nbsp;*&nbsp;@param&nbsp;tableName&nbsp;</span>&nbsp;</span></li><li class=""><span><span class="comment">&nbsp;*&nbsp;@param&nbsp;fieldName&nbsp;</span>&nbsp;</span></li><li class="alt"><span><span class="comment">&nbsp;*&nbsp;@return&nbsp;</span>&nbsp;</span></li><li class=""><span><span class="comment">&nbsp;*/</span><span>&nbsp;&nbsp;&nbsp;&nbsp;</span></span></li><li class="alt"><span><span class="keyword">private</span><span>&nbsp;</span><span class="keyword">boolean</span><span>&nbsp;isFieldExist(sqliteDatabase&nbsp;db,&nbsp;String&nbsp;fieldName)&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;String&nbsp;queryStr&nbsp;=&nbsp;<span class="string">"select&nbsp;sql&nbsp;from&nbsp;sqlite_master&nbsp;where&nbsp;type&nbsp;=&nbsp;'table'&nbsp;and&nbsp;name&nbsp;=&nbsp;'%s'"</span><span>;&nbsp;&nbsp;&nbsp;&nbsp;</span></span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;queryStr&nbsp;=&nbsp;String.format(queryStr,&nbsp;tableName);&nbsp;&nbsp;&nbsp;&nbsp;</span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;Cursor&nbsp;c&nbsp;=&nbsp;db.rawQuery(queryStr,&nbsp;<span class="keyword">null</span><span>);&nbsp;&nbsp;&nbsp;&nbsp;</span></span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;String&nbsp;tableCreatesql&nbsp;=&nbsp;<span class="keyword">null</span><span>;&nbsp;&nbsp;&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">try</span><span>&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;</span></span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">if</span><span>&nbsp;(c&nbsp;!=&nbsp;</span><span class="keyword">null</span><span>&nbsp;&amp;&amp;&nbsp;c.moveToFirst())&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;tableCreatesql&nbsp;=&nbsp;c.getString(c.getColumnIndex(<span class="string">"sql"</span><span>));&nbsp;&nbsp;&nbsp;&nbsp;</span></span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;&nbsp;&nbsp;</span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;<span class="keyword">finally</span><span>&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;</span></span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">if</span><span>&nbsp;(c&nbsp;!=&nbsp;</span><span class="keyword">null</span><span>)&nbsp;&nbsp;&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;c.close();&nbsp;&nbsp;&nbsp;&nbsp;</span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;&nbsp;&nbsp;</span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">if</span><span>&nbsp;(tableCreatesql&nbsp;!=&nbsp;</span><span class="keyword">null</span><span>&nbsp;&amp;&amp;&nbsp;tableCreatesql.contains(fieldName))&nbsp;&nbsp;&nbsp;&nbsp;</span></span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">return</span><span>&nbsp;</span><span class="keyword">true</span><span>;&nbsp;&nbsp;&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">return</span><span>&nbsp;</span><span class="keyword">false</span><span>;&nbsp;&nbsp;&nbsp;&nbsp;</span></span></li><li class="alt"><span>}&nbsp;&nbsp;&nbsp;&nbsp;</span></li></ol><div class="save_code tracking-ad" data-mod="popu_249"><a href="javascript:;" target="_blank"><img src="http://static.blog.csdn.net/images/save_snippets.png"></a></div></div><pre code_snippet_id="2064732" snippet_file_name="blog_20161220_7_6468608" class="java" style="display: none;" name="code">/** * 判断某表里某字段是否存在 * * @param db * @param tableName * @param fieldName * @return */ private boolean isFieldExist(sqliteDatabase db,String fieldName) { String queryStr = "select sql from sqlite_master where type = 'table' and name = '%s'"; queryStr = String.format(queryStr,tableName); Cursor c = db.rawQuery(queryStr,null); String tableCreatesql = null; try { if (c != null &amp;&amp; c.moveToFirst()) { tableCreatesql = c.getString(c.getColumnIndex("sql")); } } finally { if (c != null) c.close(); } if (tableCreatesql != null &amp;&amp; tableCreatesql.contains(fieldName)) return true; return false; } </pre><span style="color:rgb(51,51); line-height:26px; font-family:Arial; font-size:14px">方法3:</span><br> <p style="margin:10px auto; line-height:20.88px; padding-top:0px; padding-bottom:0px; font-family:Verdana,Arial,Helvetica,sans-serif; font-size:13.92px"> 根据 cursor.getColumnIndex(String columnName) 的返回值判断,如果为-1表示表中无此字段</p> <p style="margin:10px auto; line-height:20.88px; padding-top:0px; padding-bottom:0px; font-family:Verdana,sans-serif; font-size:13.92px"> </p> <div class="dp-Highlighter bg_java"> <div class="bar"> <div class="tools"><strong>[java]</strong> <a target="_blank" title="view plain" class="ViewSource" href="http://blog.csdn.net/wuyou1336/article/details/53770799#"> view plain</a><span> <a target="_blank" title="copy" class="CopyToClipboard" href="http://blog.csdn.net/wuyou1336/article/details/53770799#"> copy</a><div style="position: absolute; left: 750px; top: 5249px; width: 18px; height: 18px; z-index: 99;"><embed id="ZeroClipboardMovie_15" src="http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf" loop="false" menu="false" quality="best" bgcolor="#ffffff" width="18" height="18" name="ZeroClipboardMovie_15" align="middle" allowscriptaccess="always" allowfullscreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="id=15&amp;width=18&amp;height=18" wmode="transparent"></div></span><span> <a target="_blank" title="print" class="PrintSource" href="http://blog.csdn.net/wuyou1336/article/details/53770799#"> print</a></span><a target="_blank" title="?" class="About" href="http://blog.csdn.net/wuyou1336/article/details/53770799#">?</a><span class="tracking-ad"><a target="_blank" title="在CODE上查看代码片" href="https://code.csdn.net/snippets/2064732"><img width="12" height="12" alt="在CODE上查看代码片" src="https://code.csdn.net/assets/CODE_ico.png" style="left:2px; top:1px; position:relative"></a></span><span class="tracking-ad"><a target="_blank" title="派生到我的代码片" href="https://code.csdn.net/snippets/2064732/fork"><img width="12" height="12" alt="派生到我的代码片" src="https://code.csdn.net/assets/ico_fork.svg" style="left:2px; top:2px; position:relative"></a></span></div> </div> <ol class="dp-j"> <li class="alt"><span class="comment">/**</span>&nbsp;</li><li><span class="comment">*&nbsp;检查某表列是否存在</span>&nbsp;</li><li class="alt"><span class="comment">*&nbsp;@param&nbsp;db</span>&nbsp;</li><li><span class="comment">*&nbsp;@param&nbsp;tableName&nbsp;表名</span>&nbsp;</li><li class="alt"><span class="comment">*&nbsp;@param&nbsp;columnName&nbsp;列名</span>&nbsp;</li><li><span class="comment">*&nbsp;@return</span>&nbsp;</li><li class="alt"><span class="comment">*/</span>&nbsp;&nbsp;</li><li><span class="keyword">private</span>&nbsp;<span class="keyword">boolean</span>&nbsp;checkColumnExist1(sqliteDatabase&nbsp;db,&nbsp;String&nbsp;tableName&nbsp;&nbsp;</li><li class="alt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;,&nbsp;String&nbsp;columnName)&nbsp;{&nbsp;&nbsp;</li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">boolean</span>&nbsp;result&nbsp;=&nbsp;<span class="keyword">false</span>&nbsp;;&nbsp;&nbsp;</li><li class="alt">&nbsp;&nbsp;&nbsp;&nbsp;Cursor&nbsp;cursor&nbsp;=&nbsp;<span class="keyword">null</span>&nbsp;;&nbsp;&nbsp;</li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">try</span>{&nbsp;&nbsp;</li><li class="alt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment">//查询一行</span>&nbsp;&nbsp;</li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cursor&nbsp;=&nbsp;db.rawQuery(&nbsp;<span class="string">"SELECT&nbsp;*&nbsp;FROM&nbsp;"</span>&nbsp;+&nbsp;tableName&nbsp;+&nbsp;<span class="string">"&nbsp;LIMIT&nbsp;0"</span>&nbsp;&nbsp;</li><li class="alt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;,&nbsp;<span class="keyword">null</span>&nbsp;);&nbsp;&nbsp;</li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;result&nbsp;=&nbsp;cursor&nbsp;!=&nbsp;<span class="keyword">null</span>&nbsp;&amp;&amp;&nbsp;cursor.getColumnIndex(columnName)&nbsp;!=&nbsp;-<span class="number">1</span>&nbsp;;&nbsp;&nbsp;</li><li class="alt">&nbsp;&nbsp;&nbsp;&nbsp;}<span class="keyword">catch</span>&nbsp;(Exception&nbsp;e){&nbsp;&nbsp;</li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Log.e(TAG,<span class="string">"checkColumnExists1..."</span>&nbsp;+&nbsp;e.getMessage())&nbsp;;&nbsp;&nbsp;</li><li class="alt">&nbsp;&nbsp;&nbsp;&nbsp;}<span class="keyword">finally</span>{&nbsp;&nbsp;</li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">if</span>(<span class="keyword">null</span>&nbsp;!=&nbsp;cursor&nbsp;&amp;&amp;&nbsp;!cursor.isClosed()){&nbsp;&nbsp;</li><li class="alt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cursor.close()&nbsp;;&nbsp;&nbsp;</li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</li><li class="alt">&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</li><li>&nbsp;&nbsp;</li><li class="alt">&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">return</span>&nbsp;result&nbsp;;&nbsp;&nbsp;</li><li>}&nbsp;&nbsp;</li></ol> <div class="save_code tracking-ad"><a target="_blank"><img src="http://static.blog.csdn.net/images/save_snippets.png" alt=""></a></div> <div class="save_code tracking-ad" data-mod="popu_249"><a href="javascript:;" target="_blank"><img src="http://static.blog.csdn.net/images/save_snippets.png"></a></div></div> <div class="dp-Highlighter bg_java"><div class="bar"><div class="tools"><b>[java]</b> <a href="#" class="ViewSource" title="view plain" onclick="dp.sh.Toolbar.Command('ViewSource',this);return false;">copy</a><div style="position: absolute; left: 750px; top: 5768px; width: 18px; height: 18px; z-index: 99;"><embed id="ZeroClipboardMovie_16" src="http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf" loop="false" menu="false" quality="best" bgcolor="#ffffff" width="18" height="18" name="ZeroClipboardMovie_16" align="middle" allowscriptaccess="always" allowfullscreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="id=16&amp;width=18&amp;height=18" wmode="transparent"></div></span><span data-mod="popu_169"> <a href="#" class="PrintSource" title="print" onclick="dp.sh.Toolbar.Command('PrintSource',this);return false;">?</a><span class="tracking-ad" data-mod="popu_167"><a href="https://code.csdn.net/snippets/2064732" target="_blank" title="在CODE上查看代码片" style="text-indent:0;"><img src="https://code.csdn.net/assets/CODE_ico.png" width="12" height="12" alt="在CODE上查看代码片" style="position:relative;top:1px;left:2px;"></a></span><span class="tracking-ad" data-mod="popu_170"><a href="https://code.csdn.net/snippets/2064732/fork" target="_blank" title="派生到我的代码片" style="text-indent:0;"><img src="https://code.csdn.net/assets/ico_fork.svg" width="12" height="12" alt="派生到我的代码片" style="position:relative;top:2px;left:2px;"></a></span></div></div><ol start="1" class="dp-j"><li class="alt"><span><span class="comment">/**</span>&nbsp;</span></li><li class=""><span><span class="comment">*&nbsp;检查某表列是否存在</span>&nbsp;</span></li><li class="alt"><span><span class="comment">*&nbsp;@param&nbsp;db</span>&nbsp;</span></li><li class=""><span><span class="comment">*&nbsp;@param&nbsp;tableName&nbsp;表名</span>&nbsp;</span></li><li class="alt"><span><span class="comment">*&nbsp;@param&nbsp;columnName&nbsp;列名</span>&nbsp;</span></li><li class=""><span><span class="comment">*&nbsp;@return</span>&nbsp;</span></li><li class="alt"><span><span class="comment">*/</span><span>&nbsp;&nbsp;</span></span></li><li class=""><span><span class="keyword">private</span><span>&nbsp;</span><span class="keyword">boolean</span><span>&nbsp;checkColumnExist1(sqliteDatabase&nbsp;db,&nbsp;String&nbsp;tableName&nbsp;&nbsp;</span></span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;,&nbsp;String&nbsp;columnName)&nbsp;{&nbsp;&nbsp;</span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">boolean</span><span>&nbsp;result&nbsp;=&nbsp;</span><span class="keyword">false</span><span>&nbsp;;&nbsp;&nbsp;</span></span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;Cursor&nbsp;cursor&nbsp;=&nbsp;<span class="keyword">null</span><span>&nbsp;;&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">try</span><span>{&nbsp;&nbsp;</span></span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment">//查询一行</span><span>&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cursor&nbsp;=&nbsp;db.rawQuery(&nbsp;<span class="string">"SELECT&nbsp;*&nbsp;FROM&nbsp;"</span><span>&nbsp;+&nbsp;tableName&nbsp;+&nbsp;</span><span class="string">"&nbsp;LIMIT&nbsp;0"</span><span>&nbsp;&nbsp;</span></span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;,&nbsp;<span class="keyword">null</span><span>&nbsp;);&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;result&nbsp;=&nbsp;cursor&nbsp;!=&nbsp;<span class="keyword">null</span><span>&nbsp;&amp;&amp;&nbsp;cursor.getColumnIndex(columnName)&nbsp;!=&nbsp;-</span><span class="number">1</span><span>&nbsp;;&nbsp;&nbsp;</span></span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;}<span class="keyword">catch</span><span>&nbsp;(Exception&nbsp;e){&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Log.e(TAG,<span class="string">"checkColumnExists1..."</span><span>&nbsp;+&nbsp;e.getMessage())&nbsp;;&nbsp;&nbsp;</span></span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;}<span class="keyword">finally</span><span>{&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">if</span><span>(</span><span class="keyword">null</span><span>&nbsp;!=&nbsp;cursor&nbsp;&amp;&amp;&nbsp;!cursor.isClosed()){&nbsp;&nbsp;</span></span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cursor.close()&nbsp;;&nbsp;&nbsp;</span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</span></li><li class=""><span>&nbsp;&nbsp;</span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">return</span><span>&nbsp;result&nbsp;;&nbsp;&nbsp;</span></span></li><li class=""><span>}&nbsp;&nbsp;</span></li></ol><div class="save_code tracking-ad" data-mod="popu_249"><a href="javascript:;" target="_blank"><img src="http://static.blog.csdn.net/images/save_snippets.png"></a></div></div><pre code_snippet_id="2064732" snippet_file_name="blog_20161220_8_8214278" class="java" style="display: none;" name="code">/** * 检查某表列是否存在 * @param db * @param tableName 表名 * @param columnName 列名 * @return */ private boolean checkColumnExist1(sqliteDatabase db,String columnName) { boolean result = false ; Cursor cursor = null ; try{ //查询一行 cursor = db.rawQuery( "SELECT * FROM " + tableName + " LIMIT 0",null ); result = cursor != null &amp;&amp; cursor.getColumnIndex(columnName) != -1 ; }catch (Exception e){ Log.e(TAG,"checkColumnExists1..." + e.getMessage()) ; }finally{ if(null != cursor &amp;&amp; !cursor.isClosed()){ cursor.close() ; } } return result ; }</pre><br> <br> <p></p> <pre code_snippet_id="2064732" snippet_file_name="blog_20170111_9_9386907" class="prettyprint java" style="padding: 0px; line-height: 20.88px; font-size: 13.92px; margin-top: 0px; margin-bottom: 0px; white-space: pre-wrap; word-wrap: break-word; background-color: rgb(255,255,255);" name="code"><div class="save_code tracking-ad" data-mod="popu_249"><a target="_blank"><img src="http://static.blog.csdn.net/images/save_snippets.png" alt=""></a></div><div class="save_code tracking-ad" data-mod="popu_249"><a href="javascript:;" target="_blank"><img src="http://static.blog.csdn.net/images/save_snippets.png"></a></div></pre> <h1 style="margin:0px; padding:0px; line-height:26px; font-family:Arial; font-size:18px"><a name="t2"></a> <a target="_blank" name="t2"></a>3.&nbsp;&nbsp;&nbsp;sqlite中新增、删除重命名列</h1> <div> <h2 style="margin:0px; padding:0px; line-height:26px; font-family:Arial; font-size:18px"><a name="t3"></a> <a target="_blank" name="t3"></a><br> </h2> <h2 style="margin:0px; padding:0px; line-height:26px; font-family:Arial"><a name="t4"></a><a target="_blank" name="t4"></a>3.1&nbsp;&nbsp;&nbsp;新增一列</h2> </div> <p style="line-height:26px; padding-top:0px; padding-bottom:0px; font-family:Arial; font-size:14px; margin-top:0px; margin-bottom:0px"> </p> <p align="left" style="line-height:26px; padding-top:0px; padding-bottom:0px; font-family:Arial; font-size:14px; margin-top:0px; margin-bottom:0px"> 方法:使用sql命令</p> <p align="left" style="line-height:26px; padding-top:0px; padding-bottom:0px; font-family:Arial; font-size:14px; margin-top:0px; margin-bottom:0px"> 命令:ALTER&nbsp; TABLE&nbsp;&nbsp; table-name&nbsp;ADD COLUMN&nbsp; column-name column-type</p> <p align="left" style="line-height:26px; padding-top:0px; padding-bottom:0px; font-family:Arial; font-size:14px; margin-top:0px; margin-bottom:0px"> 例如:在student表中添加一列名为name,类型为varchar:</p> <p align="left" style="line-height:26px; padding-top:0px; padding-bottom:0px; font-family:Arial; font-size:14px; margin-top:0px; margin-bottom:0px"> alter table student add column name varchar;</p> <p align="left" style="line-height:26px; padding-top:0px; padding-bottom:0px; font-family:Arial; font-size:14px; margin-top:0px; margin-bottom:0px"> &nbsp;alter table catalog add column xxx1 char(20) default '';</p> <p align="left" style="line-height:26px; padding-top:0px; padding-bottom:0px; font-family:Arial; font-size:14px; margin-top:0px; margin-bottom:0px"> <br> </p> <p align="left" style="line-height:26px; padding-top:0px; padding-bottom:0px; font-family:Arial; font-size:14px; margin-top:0px; margin-bottom:0px"> </p> <h2 style="margin:0px; padding:0px; line-height:26px; font-family:Arial"><a name="t5"></a><a target="_blank" name="t5"></a>3.2&nbsp;&nbsp;&nbsp;删除一列</h2> <p></p> <p align="left" style="line-height:26px; padding-top:0px; padding-bottom:0px; font-family:Arial; font-size:14px; margin-top:0px; margin-bottom:0px"> 方法:由于drop命令在sqlite中不可用于删除列,</p> <p align="left" style="line-height:26px; padding-top:0px; padding-bottom:0px; font-family:Arial; font-size:14px; margin-top:0px; margin-bottom:0px"> alter table student drop column name // 该行在sqlite中不能用,sqlite不支持drop</p> <p align="left" style="line-height:26px; padding-top:0px; padding-bottom:0px; font-family:Arial; font-size:14px; margin-top:0px; margin-bottom:0px"> 可采用如下思路,类似于swap()函数的过程。</p> <p align="left" style="line-height:26px; padding-top:0px; padding-bottom:0px; font-family:Arial; font-size:14px; margin-top:0px; margin-bottom:0px"> 比如我有表A,A中有x、y、z三列。我要将表A中的x列删掉。那么,</p> <p align="left" style="line-height:26px; padding-top:0px; padding-bottom:0px; font-family:Arial; font-size:14px; margin-top:0px; margin-bottom:0px"> 第1步,新建一个表B,B中含有y、z两个字段,且类型与A中的y、z类型相同。</p> <p align="left" style="line-height:26px; padding-top:0px; padding-bottom:0px; font-family:Arial; font-size:14px; margin-top:0px; margin-bottom:0px"> 第2步,将A中的所有y、z两列的值拷贝到B中。</p> <p style="line-height:26px; padding-top:0px; padding-bottom:0px; font-family:Arial; font-size:14px; margin-top:0px; margin-bottom:0px"> 上面两步使用一句命令即可完成</p> <p style="line-height:26px; padding-top:0px; padding-bottom:0px; font-family:Arial; font-size:14px; margin-top:0px; margin-bottom:0px"> create table B as select y,z from A</p> <p style="line-height:26px; padding-top:0px; padding-bottom:0px; font-family:Arial; font-size:14px; margin-top:0px; margin-bottom:0px"> 注意,如果A中y的类型为char,则上面create命令会在B中创建类型为TEXT的y列。即char类型会被改变。</p> <p style="line-height:26px; padding-top:0px; padding-bottom:0px; font-family:Arial; font-size:14px; margin-top:0px; margin-bottom:0px"> 第3步,将A表删除</p> <p style="line-height:26px; padding-top:0px; padding-bottom:0px; font-family:Arial; font-size:14px; margin-top:0px; margin-bottom:0px"> drop table if exists A</p> <p style="line-height:26px; padding-top:0px; padding-bottom:0px; font-family:Arial; font-size:14px; margin-top:0px; margin-bottom:0px"> 第4步,将B重命名为A</p> <p style="line-height:26px; padding-top:0px; padding-bottom:0px; font-family:Arial; font-size:14px; margin-top:0px; margin-bottom:0px"> alter table B rename to A</p> <p style="line-height:26px; padding-top:0px; padding-bottom:0px; font-family:Arial; font-size:14px; margin-top:0px; margin-bottom:0px"> <br> </p> <p style="line-height:26px; padding-top:0px; padding-bottom:0px; font-family:Arial; font-size:14px; margin-top:0px; margin-bottom:0px"> </p> <h2 style="margin:0px; padding:0px; line-height:26px; font-family:Arial; font-size:18px"><a name="t6"></a> <a target="_blank" name="t6"></a>3.3&nbsp;&nbsp;&nbsp;重命名一列</h2> <p></p> <p style="line-height:26px; padding-top:0px; padding-bottom:0px; font-family:Arial; font-size:14px; margin-top:0px; margin-bottom:0px"> </p> <p align="left" style="line-height:26px; padding-top:0px; padding-bottom:0px; font-family:Arial; font-size:14px; margin-top:0px; margin-bottom:0px"> 方法:与删除一列相同,在sqlite中alter同样无法重命名一列。如果想重命名,那么思路与删除一列相同。</p> <p align="left" style="line-height:26px; padding-top:0px; padding-bottom:0px; font-family:Arial; font-size:14px; margin-top:0px; margin-bottom:0px"> <br> </p> <p align="left" style="line-height:26px; padding-top:0px; padding-bottom:0px; font-family:Arial; font-size:14px; margin-top:0px; margin-bottom:0px"> <br> </p> <h1 style="margin:0px; padding:0px; line-height:26px; font-family:Arial; font-size:18px"><a name="t7"></a> <a target="_blank" name="t7"></a>4.&nbsp;&nbsp;&nbsp;sqlite中新增、删除重命名表</h1> <br style="line-height:26px; font-family:Arial; font-size:14px"> <p style="line-height:26px; padding-top:0px; padding-bottom:0px; font-family:Arial; font-size:14px; margin-top:0px; margin-bottom:0px"> </p> <p style="line-height:26px; padding-top:0px; padding-bottom:0px; font-family:Arial; font-size:14px; margin-top:0px; margin-bottom:0px"> sql语句在3.2中已有。整理如下。</p> <p style="line-height:26px; padding-top:0px; padding-bottom:0px; font-family:Arial; font-size:14px; margin-top:0px; margin-bottom:0px"> </p> <h2 style="margin:0px; padding:0px; line-height:26px; font-family:Arial; font-size:18px"><a name="t8"></a> <a target="_blank" name="t8"></a>4.1&nbsp;&nbsp;&nbsp;新增表</h2> <p></p> <p style="line-height:26px; padding-top:0px; padding-bottom:0px; font-family:Arial; font-size:14px; margin-top:0px; margin-bottom:0px"> create table A(id char(20),channeltext,name text,primary key (id))</p> <p style="line-height:26px; padding-top:0px; padding-bottom:0px; font-family:Arial; font-size:14px; margin-top:0px; margin-bottom:0px"> create table B as select y,z from A</p> <p style="line-height:26px; padding-top:0px; padding-bottom:0px; font-family:Arial; font-size:14px; margin-top:0px; margin-bottom:0px"> <br> </p> <p style="line-height:26px; padding-top:0px; padding-bottom:0px; font-family:Arial; font-size:14px; margin-top:0px; margin-bottom:0px"> </p> <h2 style="margin:0px; padding:0px; line-height:26px; font-family:Arial; font-size:18px"><a name="t9"></a> <a target="_blank" name="t9"></a>4.2&nbsp;&nbsp;&nbsp;删除表</h2> <p></p> <p style="line-height:26px; padding-top:0px; padding-bottom:0px; font-family:Arial; font-size:14px; margin-top:0px; margin-bottom:0px"> drop table if exists A</p> <p style="line-height:26px; padding-top:0px; padding-bottom:0px; font-family:Arial; font-size:14px; margin-top:0px; margin-bottom:0px"> <br> </p> <p style="line-height:26px; padding-top:0px; padding-bottom:0px; font-family:Arial; font-size:14px; margin-top:0px; margin-bottom:0px"> </p> <h2 style="margin:0px; padding:0px; line-height:26px; font-family:Arial; font-size:18px"><a name="t10"></a> <a target="_blank" name="t10"></a>4.3&nbsp;&nbsp;&nbsp;重命名表</h2> <p></p> <p style="line-height:26px; padding-top:0px; padding-bottom:0px; font-family:Arial; font-size:14px; margin-top:0px; margin-bottom:0px"> alter table B rename to A</p> </div> <!-- Baidu Button BEGIN --> <div class="bdsharebuttonBox tracking-ad bdshare-button-style0-16" style="float: right;" data-mod="popu_172" data-bd-bind="1492658031998"> <a href="#" class="bds_more" data-cmd="more" style="background-position:0 0 !important; background-image: url(http://bdimg.share.baidu.com/static/api/img/share/icons_0_16.png?v=d754dcc0.png) !important" target="_blank"></a> <a href="#" class="bds_qzone" data-cmd="qzone" title="分享到QQ空间" style="background-position:0 -52px !important" target="_blank"></a> <a href="#" class="bds_tsina" data-cmd="tsina" title="分享到新浪微博" style="background-position:0 -104px !important" target="_blank"></a> <a href="#" class="bds_tqq" data-cmd="tqq" title="分享到腾讯微博" style="background-position:0 -260px !important" target="_blank"></a> <a href="#" class="bds_renren" data-cmd="renren" title="分享到人人网" style="background-position:0 -208px !important" target="_blank"></a> <a href="#" class="bds_weixin" data-cmd="weixin" title="分享到微信" style="background-position:0 -1612px !important" target="_blank"></a> </div> <script>window._bd_share_config = { "common": { "bdSnsKey": {},"bdText": "","bdMini": "1","bdMiniList": false,"bdPic": "","bdStyle": "0","bdSize": "16" },"share": {} }; with (document) 0[(getElementsByTagName('head')[0] || body).appendChild(createElement('script')).src = 'http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion=' + ~(-new Date() / 36e5)];</script> <!-- Baidu Button END --> <link rel="stylesheet" href="http://static.blog.csdn.net/css/blog_detail.css"> <!--172.16.140.13--> <!-- Baidu Button BEGIN --> <script type="text/javascript" id="bdshare_js" data="type=tools&amp;uid=1536434" src="http://bdimg.share.baidu.com/static/js/bds_s_v2.js?cdnversion=414628"></script> <script type="text/javascript"> document.getElementById("bdshell_js").src = "http://bdimg.share.baidu.com/static/js/shell_v2.js?cdnversion=" + Math.ceil(new Date()/3600000) </script> <!-- Baidu Button END --> <script type="text/javascript"> var fromjs = $("#fromjs"); if (fromjs.length > 0) { $("#fromjs .markdown_views pre").addClass("prettyprint"); prettyPrint(); $('pre.prettyprint code').each(function () { var lines = $(this).text().split('\n').length; var $numbering = $('<ul/>').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i <= lines; i++) { $numbering.append($('<li/>').text(i)); }; $numbering.fadeIn(1700); }); $('.pre-numbering li').css("color","#999"); } </script> <div id="digg" articleid="54346865"> <dl id="btnDigg" class="digg digg_disable" onclick="btndigga();"> <dt>顶</dt> <dd>0</dd> </dl> <dl id="btnBury" class="digg digg_disable" onclick="btnburya();"> <dt>踩</dt> <dd>0</dd> </dl> </div> <div class="tracking-ad" data-mod="popu_222"><a href="javascript:void(0);" target="_blank">&nbsp;</a> </div> <div class="tracking-ad" data-mod="popu_223"> <a href="javascript:void(0);" target="_blank">&nbsp;</a></div> <script type="text/javascript"> function btndigga() { $(".tracking-ad[data-mod='popu_222'] a").click(); } function btnburya() { $(".tracking-ad[data-mod='popu_223'] a").click(); } </script> <ul class="article_next_prev"> <li class="prev_article"><span onclick="_gaq.push(['_trackEvent','blog_articles_shangyipian']);location.href='/hanfengzqh/article/details/54138240';">上一篇</span><a href="/hanfengzqh/article/details/54138240" onclick="_gaq.push(['_trackEvent','blog_articles_shangyipian'])">Android中解析Json——Jackson使用</a></li> <li class="next_article"><span onclick="_gaq.push(['_trackEvent','blog_articles_xiayipian']);location.href='/hanfengzqh/article/details/54379084';">下一篇</span><a href="/hanfengzqh/article/details/54379084" onclick="_gaq.push(['_trackEvent','blog_articles_xiayipian'])">android 关于Make sure the plugin is properly configured问题的解决办法</a></li> </ul> <div style="clear:both; height:10px;"></div> </div> 原文链接:https://www.f2er.com/sqlite/198460.html

猜你在找的Sqlite相关文章