WebSQL is a SQL enhancement and unification to generalize access to increasingly heterogeneous data in mixed databases: relational and non-relational. WebSQL does not replace a SQL supported by a specific database, but adds missing functionality.
WebSQL consists of the following statements:
SELECT
statement is used to retrieve data from a database
where the SELECT
clause allows specifying values (aka columns/properties/attributes)
to be returned in the result output and its JSON format: Array (default) or Map.
SELECT ( * | expr [, ...]) FROM [ WHERE ] [ ORDER BY order [, ...]] [ LIMIT number ] // where: path: value_name [. value_name ...] expr: [ path .] value_name [. * | [ AS ] alias ] order: path [ ASC | DESC ]
FROM
clause allows specifying data sources: tables, etc.
FROM expr [, ...] // where: expr: table_name [[ AS ] from_alias ]
WHERE
clause allows specifying the search condition.
WHERE cond [( AND | OR ) ...] // where: cond: [ from_alias. ] value_name is null cond: [ from_alias. ] value_name is not null cond: [ from_alias. ] value_name oper ( const | var ) cond: [ from_alias. ] value_name oper [ from_alias. ] value_name oper: = | != | <> | >= | > | <= | <
INSERT
statement is used to add data into a database. WebSQL supports the following syntaxes:
INSERT table_name { json } // a sample with json: INSERT Test { "aNumber" : 123, "aString" : "test", "aBoolean" : true, "aNull" : null, "anArray" : [ ... ], "anObject" : { ... } }
REPLACE
statement is used to replace data in a database. WebSQL supports the following syntaxes:
REPLACE table_name WHERE clause { json } // a sample with json: REPLACE Test WHERE aNumber = 123 { "aString" : "test", "aBoolean" : true, "aNull" : null, "anArray" : [ ... ], "anObject" : { ... } }
UPDATE
statement is used to update data in a database. WebSQL supports the following syntaxes:
UPDATE table_name WHERE clause { json } // a sample with json: UPDATE Test WHERE aNumber = 123 { "aString" : "test", "aBoolean" : true, "aNull" : null, "anArray" : [ ... ], "anObject" : { ... } }
DELETE
statement is used to delete data from a database. WebSQL supports the following syntaxes:
DELETE table_name WHERE clause