我错过了什么?我可以在 Inspector 窗口中看到数据库,但没有表。我可以在控制台中创建表格并显示它们,但它们不会自动出现。
这是 openDatabase 调用:
<script>var newdb = openDatabase('db2', '1.00', 'DB1', (100 * 1024 * 1024));
如果它们不存在,这是创建表的调用:
newdb.transaction(function (tx) {
tx.executeSql('CREATE TABLE IF NOT EXISTS LOGS (id unique, log)');
tx.executeSql('CREATE TABLE IF NOT EXISTS OBSERVATIONS (observation_id unique, field_id, observation_date, phase_id, magnitude_id, summary)');
tx.executeSql('INSERT INTO LOGS (id, log) VALUES (1, "Test Field 1")');
tx.executeSql('INSERT INTO LOGS (id, log) VALUES (2, "Test Field 2")');
tx.executeSql('INSERT INTO LOGS (id, log) VALUES (4, "Test Field 3")');
tx.executeSql('INSERT INTO OBSERVATIONS (observation_id, field_id, observation_date, phase_id, magnitude_id, summary, plant_no) VALUES (1, 1, "1/1/2012", 1234, 5678, "This is Observation 1", 100)');
tx.executeSql('INSERT INTO OBSERVATIONS (observation_id, field_id, observation_date, phase_id, magnitude_id, summary, plant_no) VALUES (2, 1, "1/2/2012", 1234, 5679, "This is Observation 2", 101)');
});