我正在使用 html 客户端存储,想知道是否有任何用于自省数据库的工具 - 是否有相当于 sqlite“.tables”或“.schema”的工具?

另外,我没有看到我的表格出现在 AppData\Local\Apple Computer\Safari\LocalStorage 中。还有其他地方可以存放表格吗?

有帮助吗?

解决方案

这是特定于浏览器的。

对于 Safari,您需要 Safari 4——他们有 检查工具(图2-11)就是为了这个目的。

其他提示

Safari浏览器保存在 “应用程序数据\本地\苹果电脑\ Safari浏览器\数据库” 表。

首先Databases.db是具有2代表的sqlite3的数据库。

  

起源跟踪什么网站上创建该数据库的数据库和最大存储。

     

数据库跟踪特定的数据库和相应的文件夹,通用和文件名

我使用sqlite3的命令行工具或有时SQLite的管理员。任何sqlite3的应用程序就可以了。

您数据库将在像http_exeample_com_0 \ 00000000003.db

的子目录
select * from sqlite_master;

这表具有列类型( '表' 或 '索引'),名称,tbl_name,SQL(什么.schema输出当量)

我已经创建了一个脚本来显示数据库中的内容。

<!DOCTYPE html>
<html>
<head>
<title>sqlite database</title>
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript">
var db;
function openDB(shortName, version, displayName, maxSize){
 try{
  if(window.openDatabase)
  {
   db = openDatabase(shortName, version, displayName, maxSize);
  }
  else
  {
   alert("Your browser does not have a sqlite database");
  }
 }catch(e){
  alert(e);
 }
}
function executeQuery($query,callback,errorcallback){
 try{
  if(window.openDatabase){
   db.transaction(function(tx){
    tx.executeSql($query,[],function(tx,result){
     if(typeof callback == "function"){
      callback(result);
     }else{
      if(callback != undefined){
       eval(callback+"(result)");
      }
     }
    },function(tx,error){
     if(typeof errorcallback == "function"){
      errorcallback(error);
     }else{
      if(errorcallback != undefined){
       eval(errorcallback+"(error)");
      }
     }
    });
   });
  }
 }catch(e){
  alert(e);
 }
}
$(function(){
  openDB("dbname", "1.0", "Display Name", 2 * 1024 * 1024/*size of db*/);
  executeQuery("SELECT name FROM sqlite_master WHERE type='table'", function(tables)
  {
   var tableNames = new Array();
   for(var i = 1; i < tables.rows.length; i++)//i starts at 1 to skip over the "__WebKitDatabaseInfoTable__" table
   {
    tableNames.push(tables.rows.item(i).name);
   }
   var count = 0;
   for(var i = 0; i < tableNames.length; i++)//if there is no information in the table we cannot get the column names;
   {
    executeQuery("SELECT * FROM " + tableNames[i], function(results){
    var columnNames = new Array();
    var table = "<div class='tableName'>" + tableNames[count++] + "</div><table cellspacing='0' cellspacing='0' class='table'>";
    if(results.rows.length > 0)
    {
     table += "<tr class='headerRow'>";
     for(var column in results.rows.item(0))
     {
      columnNames.push(column);
      table += "<th class='columnName'>" + column + "</th>";
     }
     table += "</tr>"
     for(var i = 0; i < results.rows.length; i++)
     {
      table += "<tr class='tableRow'>";
      for(var columnName in columnNames)
      {
       table += "<td class='tableEntry'>" + results.rows.item(i)[columnNames[columnName]] + "</td>";
      }
      table += "</tr>";
     }
    }
    else
    {
     table += "<tr><td>empty</td></tr>";
    }
    table += "</table>";
    $("body").append(table);
   }, function(error){
    alert(error.message);
   });
  }
 }, function(error){
  alert(error.message);
 });
});
</script>
<style type="text/css">
.tableName{
 font-variant: small-caps;
 font-size: 20px;
 margin-top: 15px;
}
.headerRow{
    background-color: #ff0;
}
.columnName{
 border: 1px solid #000;
 padding: 2px 10px;
}
.tableRow{
    background-color: #AFA;
}
.tableEntry{
 border: 1px solid #000;
 padding: 2px 10px;
}
.table{
 border: 1px solid #000;
}
</style>
</head>
<body>
</body>
</html>
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top