HTML Editor
<!DOCTYPE html> <html lang="en-US"> <body> <button type="button" onclick="insertData()">Create DataBase</button> <script> var db = openDatabase('studentsDB', '1.0', 'Test DB', 2 * 1024 * 1024); function insertData(){ //Insert Operation db.transaction(function (tx) { tx.executeSql('CREATE TABLE IF NOT EXISTS myGroup (id unique, name)'); tx.executeSql('INSERT INTO myGroup (id, name) VALUES(?,?)', [1, "Abraham"],function(transaction,result){ console.log("inserted successfully 1"); }); tx.executeSql('INSERT INTO myGroup (id, name) VALUES(?,?)', [2, "Michael"],function(transaction,result){ console.log("inserted successfully 2"); }); }); } </script> <p><strong>Note:</strong> Go to your Developer Tools to check the database as mentioned in this <a href="/html/web-sql" target="_blank">page</a></p> </body> </html>
OUTPUT
×

Save as Private