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