MySQL建表语句解析表名
生活随笔
收集整理的這篇文章主要介紹了
MySQL建表语句解析表名
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
/*** input: sqlCreateTableScript放置建表語句* output: nameList表名列表*/String sqlCreateTableScript="";String[] scriptArray=sqlCreateTableScript.split("(?i)"+"CREATE"+"\\s+"+"TABLE");//大小寫都匹配List<String> nameList=new ArrayList<>(Arrays.asList(scriptArray));for(int i=0;i<nameList.size();i++) {String e=nameList.get(i);if(e==null||e.equals("")||e.indexOf("(")<0) {nameList.remove(i);i--;}else {e=e.substring(0,e.indexOf("("));e=e.replaceAll(" ", "");e=e.replaceAll("`", "");nameList.set(i, e);System.out.println(e);} }System.out.println("一共有"+nameList.size()+"個表名");
總結
以上是生活随笔為你收集整理的MySQL建表语句解析表名的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 超导量子计算机速度多快,我国量子计算机实
- 下一篇: 2017蓝桥杯c语言C组承压计算,蓝桥杯