0
我错过了什么?我可以在Inspector窗口中看到数据库,但没有表格。 我可以在控制台中创建表格并显示出来,但它们不会自动出现。Sqlite创建表如果不存在不工作?
这里的电话的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)');
});
您是否有错误? –
检查员没有错误。它只是不添加表格。 – bdmflyer