HTML Web SQL

Last Updated:

What is Web SQL?

Web SQL is a database for storing data that can be queried using a variant of SQL.

Note: Web SQL is deprecated and is no longer recommended. Instead, try to use IndexedDB.

How to view Web SQL?

Follow the below steps to view your data stored in the Web SQL:

  1. Go to Developer Tools or Press F12 or Press Ctrl + Shift + i.
  2. Switch to Application Tab on the top navigation bar.
  3. On the left side menu you will find the Web SQL.

Note: If you couldn't find your recent changes in the Web SQL database, close and reopen the developer tools to see the changes.

In the following example, we will create a Web SQL database.

Example

HTML Online Editor
<!DOCTYPE html> <html> <body> <button type="button" onclick="createDB()">Create DataBase</button> <script type="text/javascript"> function createDB(){ var db = openDatabase('studentsDB', '1.0', 'Test DB', 2 * 1024 * 1024); if(db) alert("Your DB was created"); else alert("Something went wrong."); } </script> </body> </html>

Syntax

openDatabase(DB_Name, Version_Number, Text_Description, DB_Size);

Parameters

ParameterTypeExplanation
DB_Name string Specifies the name of the database.
Version_Number string Specifies the version number of the database.
Text_Description string Specifies the text description of the database.
DB_Size Number Specifies the size of the database.

Browser Support

Devicedesktopmobile
Browsergoogle chromesafarifirefoxinternet Exploreredgeoperagoogle chromesafarifirefoxedgeoperaandroid webviewsamsung internet
web sqlYesYesNoNoNoYesYesYesNoNoYesYesNo

Share this Page

Meet the Author