<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="{"err":0,"msg":"ok","data":[]}"></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 + " "; 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
查询与判断表</a></li><li><a href="#t1">
查询与判断列</a></li><li><a href="#t2"> 3
sqlite中新增
删除重命名列</a></li><ol><li><a href="#t3"> </a></li><li><a href="#t4">1 新增一列</a></li><li><a href="#t5">2
删除一列</a></li><li><a href="#t6"> 33
重命名一列</a></li></ol><li><a href="#t7"> 4
sqlite中新增
删除重命名表</a></li><ol><li><a href="#t8"> 41 新增表</a></li><li><a href="#t9"> 42
删除表</a></li><li><a href="#t10"> 43
重命名表</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">
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: 类型,取值一般为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: </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: 表名</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&width=18&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> <span class="keyword">TABLE</span>
sqlite_master ( </li><li>type TEXT, </li><li class="alt"><span class="keyword">name</span> TEXT, </li><li>tbl_name TEXT, </li><li class="alt">rootpage <span class="keyword">INTEGER</span>, </li><li>
sql TEXT </li><li class="alt">); </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&width=18&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> </span><span class="keyword">TABLE</span><span>
sqlite_master ( </span></span></li><li class=""><span>type TEXT, </span></li><li class="alt"><span><span class="keyword">name</span><span> TEXT, </span></span></li><li class=""><span>tbl_name TEXT, </span></li><li class="alt"><span>rootpage <span class="keyword">INTEGER</span><span>, </span></span></li><li class=""><span>
sql TEXT </span></li><li class="alt"><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.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&width=18&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> * <span class="keyword">from</span>
sqlite_master <span class="keyword">where</span> type = <span class="string">'table'</span> <span class="op">and</span> <span class="keyword">name</span> = <span class="string">'t_cmpt_cp'</span> </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&width=18&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> * </span><span class="keyword">from</span><span>
sqlite_master </span><span class="keyword">where</span><span> type = </span><span class="string">'table'</span><span> </span><span class="op">and</span><span> </span><span class="keyword">name</span><span> = </span><span class="string">'t_cmpt_cp'</span><span> </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.
查询与判断</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&width=18&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> <span class="keyword">name</span> <span class="keyword">from</span>
sqlite_master <span class="keyword">where</span> type=<span class="string">'table'</span> <span class="keyword">order</span> <span class="keyword">by</span> <span class="keyword">name</span>; </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&width=18&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> </span><span class="keyword">name</span><span> </span><span class="keyword">from</span><span>
sqlite_master </span><span class="keyword">where</span><span> type=</span><span class="string">'table'</span><span> </span><span class="keyword">order</span><span> </span><span class="keyword">by</span><span> </span><span class="keyword">name</span><span>; </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&width=18&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> * <span class="keyword">from</span>
sqlite_master </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&width=18&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> * </span><span class="keyword">from</span><span>
sqlite_master </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&width=18&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> <span class="func">count</span>(*) <span class="keyword">from</span>
sqlite_master <span class="keyword">where</span> type=<span class="string">'table'</span> <span class="op">and</span> <span class="keyword">name</span> = <span class="string">'yourtablename'</span>; </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&width=18&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> </span><span class="func">count</span><span>(*) </span><span class="keyword">from</span><span>
sqlite_master </span><span class="keyword">where</span><span> type=</span><span class="string">'table'</span><span> </span><span class="op">and</span><span> </span><span class="keyword">name</span><span> = </span><span class="string">'yourtablename'</span><span>; </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.
查询与判断<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 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"> </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 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&width=18&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> </li><li><span class="comment">* 检查表中某列是否存在</span> </li><li class="alt"><span class="comment">* @param db</span> </li><li><span class="comment">* @param tableName 表名</span> </li><li class="alt"><span class="comment">* @param columnName 列名</span> </li><li><span class="comment">* @return</span> </li><li class="alt"><span class="comment">*/</span> </li><li><span class="keyword">private</span> <span class="keyword">boolean</span> checkColumnExists2(
sqliteDatabase db, String tableName </li><li class="alt"> , String columnName) { </li><li> <span class="keyword">boolean</span> result = <span class="keyword">false</span> ; </li><li class="alt"> Cursor cursor = <span class="keyword">null</span> ; </li><li> </li><li class="alt"> <span class="keyword">try</span>{ </li><li> cursor = db.rawQuery( <span class="string">"select * from
sqlite_master where name = ? and
sql like ?"</span> </li><li class="alt"> , <span class="keyword">new</span> String[]{tableName , <span class="string">"%"</span> + columnName + <span class="string">"%"</span>} ); </li><li> result = <span class="keyword">null</span> != cursor && cursor.moveToFirst() ; </li><li class="alt"> }<span class="keyword">catch</span> (Exception e){ </li><li> Log.e(TAG,<span class="string">"checkColumnExists2..."</span> + e.getMessage()) ; </li><li class="alt"> }<span class="keyword">finally</span>{ </li><li> <span class="keyword">if</span>(<span class="keyword">null</span> != cursor && !cursor.isClosed()){ </li><li class="alt"> cursor.close() ; </li><li> } </li><li class="alt"> } </li><li> </li><li class="alt"> <span class="keyword">return</span> result ; </li><li>} </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&width=18&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> </span></li><li class=""><span><span class="comment">* 检查表中某列是否存在</span> </span></li><li class="alt"><span><span class="comment">* @param db</span> </span></li><li class=""><span><span class="comment">* @param tableName 表名</span> </span></li><li class="alt"><span><span class="comment">* @param columnName 列名</span> </span></li><li class=""><span><span class="comment">* @return</span> </span></li><li class="alt"><span><span class="comment">*/</span><span> </span></span></li><li class=""><span><span class="keyword">private</span><span> </span><span class="keyword">boolean</span><span> checkColumnExists2(
sqliteDatabase db, String tableName </span></span></li><li class="alt"><span> , String columnName) { </span></li><li class=""><span> <span class="keyword">boolean</span><span> result = </span><span class="keyword">false</span><span> ; </span></span></li><li class="alt"><span> Cursor cursor = <span class="keyword">null</span><span> ; </span></span></li><li class=""><span> </span></li><li class="alt"><span> <span class="keyword">try</span><span>{ </span></span></li><li class=""><span> cursor = db.rawQuery( <span class="string">"select * from
sqlite_master where name = ? and
sql like ?"</span><span> </span></span></li><li class="alt"><span> , <span class="keyword">new</span><span> String[]{tableName , </span><span class="string">"%"</span><span> + columnName + </span><span class="string">"%"</span><span>} ); </span></span></li><li class=""><span> result = <span class="keyword">null</span><span> != cursor && cursor.moveToFirst() ; </span></span></li><li class="alt"><span> }<span class="keyword">catch</span><span> (Exception e){ </span></span></li><li class=""><span> Log.e(TAG,<span class="string">"checkColumnExists2..."</span><span> + e.getMessage()) ; </span></span></li><li class="alt"><span> }<span class="keyword">finally</span><span>{ </span></span></li><li class=""><span> <span class="keyword">if</span><span>(</span><span class="keyword">null</span><span> != cursor && !cursor.isClosed()){ </span></span></li><li class="alt"><span> cursor.close() ; </span></li><li class=""><span> } </span></li><li class="alt"><span> } </span></li><li class=""><span> </span></li><li class="alt"><span> <span class="keyword">return</span><span> result ; </span></span></li><li class=""><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.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 && cursor.moveToFirst() ; }catch (Exception e){ Log.e(TAG,"checkColumnExists2..." + e.getMessage()) ; }finally{ if(null != cursor && !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&width=18&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> </li><li><span class="comment"> * 判断某表里某字段是否存在 </span> </li><li class="alt"><span class="comment"> * </span> </li><li><span class="comment"> * @param db </span> </li><li class="alt"><span class="comment"> * @param tableName </span> </li><li><span class="comment"> * @param fieldName </span> </li><li class="alt"><span class="comment"> * @return </span> </li><li><span class="comment"> */</span> </li><li class="alt"><span class="keyword">private</span> <span class="keyword">boolean</span> isFieldExist(
sqliteDatabase db, String tableName, String fieldName) { </li><li> String queryStr = <span class="string">"select
sql from
sqlite_master where type = 'table' and name = '%s'"</span>; </li><li class="alt"> queryStr = String.format(queryStr, tableName); </li><li> Cursor c = db.rawQuery(queryStr, <span class="keyword">null</span>); </li><li class="alt"> String tableCreate
sql = <span class="keyword">null</span>; </li><li> <span class="keyword">try</span> { </li><li class="alt"> <span class="keyword">if</span> (c != <span class="keyword">null</span> && c.moveToFirst()) { </li><li> tableCreate
sql = c.getString(c.getColumnIndex(<span class="string">"
sql"</span>)); </li><li class="alt"> } </li><li> } <span class="keyword">finally</span> { </li><li class="alt"> <span class="keyword">if</span> (c != <span class="keyword">null</span>) </li><li> c.close(); </li><li class="alt"> } </li><li> <span class="keyword">if</span> (tableCreate
sql != <span class="keyword">null</span> && tableCreate
sql.contains(fieldName)) </li><li class="alt"> <span class="keyword">return</span> <span class="keyword">true</span>; </li><li> <span class="keyword">return</span> <span class="keyword">false</span>; </li><li class="alt">} </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&width=18&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> </span></li><li class=""><span><span class="comment"> * 判断某表里某字段是否存在 </span> </span></li><li class="alt"><span><span class="comment"> * </span> </span></li><li class=""><span><span class="comment"> * @param db </span> </span></li><li class="alt"><span><span class="comment"> * @param tableName </span> </span></li><li class=""><span><span class="comment"> * @param fieldName </span> </span></li><li class="alt"><span><span class="comment"> * @return </span> </span></li><li class=""><span><span class="comment"> */</span><span> </span></span></li><li class="alt"><span><span class="keyword">private</span><span> </span><span class="keyword">boolean</span><span> isFieldExist(
sqliteDatabase db, String fieldName) { </span></span></li><li class=""><span> String queryStr = <span class="string">"select
sql from
sqlite_master where type = 'table' and name = '%s'"</span><span>; </span></span></li><li class="alt"><span> queryStr = String.format(queryStr, tableName); </span></li><li class=""><span> Cursor c = db.rawQuery(queryStr, <span class="keyword">null</span><span>); </span></span></li><li class="alt"><span> String tableCreate
sql = <span class="keyword">null</span><span>; </span></span></li><li class=""><span> <span class="keyword">try</span><span> { </span></span></li><li class="alt"><span> <span class="keyword">if</span><span> (c != </span><span class="keyword">null</span><span> && c.moveToFirst()) { </span></span></li><li class=""><span> tableCreate
sql = c.getString(c.getColumnIndex(<span class="string">"
sql"</span><span>)); </span></span></li><li class="alt"><span> } </span></li><li class=""><span> } <span class="keyword">finally</span><span> { </span></span></li><li class="alt"><span> <span class="keyword">if</span><span> (c != </span><span class="keyword">null</span><span>) </span></span></li><li class=""><span> c.close(); </span></li><li class="alt"><span> } </span></li><li class=""><span> <span class="keyword">if</span><span> (tableCreate
sql != </span><span class="keyword">null</span><span> && tableCreate
sql.contains(fieldName)) </span></span></li><li class="alt"><span> <span class="keyword">return</span><span> </span><span class="keyword">true</span><span>; </span></span></li><li class=""><span> <span class="keyword">return</span><span> </span><span class="keyword">false</span><span>; </span></span></li><li class="alt"><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_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 tableCreate
sql = null; try { if (c != null && c.moveToFirst()) { tableCreate
sql = c.getString(c.getColumnIndex("
sql")); } } finally { if (c != null) c.close(); } if (tableCreate
sql != null && tableCreate
sql.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&width=18&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> </li><li><span class="comment">* 检查某表列是否存在</span> </li><li class="alt"><span class="comment">* @param db</span> </li><li><span class="comment">* @param tableName 表名</span> </li><li class="alt"><span class="comment">* @param columnName 列名</span> </li><li><span class="comment">* @return</span> </li><li class="alt"><span class="comment">*/</span> </li><li><span class="keyword">private</span> <span class="keyword">boolean</span> checkColumnExist1(
sqliteDatabase db, String tableName </li><li class="alt"> , String columnName) { </li><li> <span class="keyword">boolean</span> result = <span class="keyword">false</span> ; </li><li class="alt"> Cursor cursor = <span class="keyword">null</span> ; </li><li> <span class="keyword">try</span>{ </li><li class="alt"> <span class="comment">//
查询一行</span> </li><li> cursor = db.rawQuery( <span class="string">"SELECT * FROM "</span> + tableName + <span class="string">" LIMIT 0"</span> </li><li class="alt"> , <span class="keyword">null</span> ); </li><li> result = cursor != <span class="keyword">null</span> && cursor.getColumnIndex(columnName) != -<span class="number">1</span> ; </li><li class="alt"> }<span class="keyword">catch</span> (Exception e){ </li><li> Log.e(TAG,<span class="string">"checkColumnExists1..."</span> + e.getMessage()) ; </li><li class="alt"> }<span class="keyword">finally</span>{ </li><li> <span class="keyword">if</span>(<span class="keyword">null</span> != cursor && !cursor.isClosed()){ </li><li class="alt"> cursor.close() ; </li><li> } </li><li class="alt"> } </li><li> </li><li class="alt"> <span class="keyword">return</span> result ; </li><li>} </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&width=18&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> </span></li><li class=""><span><span class="comment">* 检查某表列是否存在</span> </span></li><li class="alt"><span><span class="comment">* @param db</span> </span></li><li class=""><span><span class="comment">* @param tableName 表名</span> </span></li><li class="alt"><span><span class="comment">* @param columnName 列名</span> </span></li><li class=""><span><span class="comment">* @return</span> </span></li><li class="alt"><span><span class="comment">*/</span><span> </span></span></li><li class=""><span><span class="keyword">private</span><span> </span><span class="keyword">boolean</span><span> checkColumnExist1(
sqliteDatabase db, String tableName </span></span></li><li class="alt"><span> , String columnName) { </span></li><li class=""><span> <span class="keyword">boolean</span><span> result = </span><span class="keyword">false</span><span> ; </span></span></li><li class="alt"><span> Cursor cursor = <span class="keyword">null</span><span> ; </span></span></li><li class=""><span> <span class="keyword">try</span><span>{ </span></span></li><li class="alt"><span> <span class="comment">//
查询一行</span><span> </span></span></li><li class=""><span> cursor = db.rawQuery( <span class="string">"SELECT * FROM "</span><span> + tableName + </span><span class="string">" LIMIT 0"</span><span> </span></span></li><li class="alt"><span> , <span class="keyword">null</span><span> ); </span></span></li><li class=""><span> result = cursor != <span class="keyword">null</span><span> && cursor.getColumnIndex(columnName) != -</span><span class="number">1</span><span> ; </span></span></li><li class="alt"><span> }<span class="keyword">catch</span><span> (Exception e){ </span></span></li><li class=""><span> Log.e(TAG,<span class="string">"checkColumnExists1..."</span><span> + e.getMessage()) ; </span></span></li><li class="alt"><span> }<span class="keyword">finally</span><span>{ </span></span></li><li class=""><span> <span class="keyword">if</span><span>(</span><span class="keyword">null</span><span> != cursor && !cursor.isClosed()){ </span></span></li><li class="alt"><span> cursor.close() ; </span></li><li class=""><span> } </span></li><li class="alt"><span> } </span></li><li class=""><span> </span></li><li class="alt"><span> <span class="keyword">return</span><span> result ; </span></span></li><li class=""><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_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 && cursor.getColumnIndex(columnName) != -1 ; }catch (Exception e){ Log.e(TAG,"checkColumnExists1..." + e.getMessage()) ; }finally{ if(null != cursor && !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.
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 新增一列</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 TABLE table-name ADD COLUMN 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"> 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
删除一列</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
重命名一列</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.
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 新增表</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
删除表</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
重命名表</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="bdsharebutton
Box 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&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"> </a> </div> <div class="tracking-ad" data-mod="popu_223"> <a href="javascript:void(0);" target="_blank"> </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