Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/extjs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 检查WebSQL中是否存在索引_Javascript_Web Sql - Fatal编程技术网

Javascript 检查WebSQL中是否存在索引

Javascript 检查WebSQL中是否存在索引,javascript,web-sql,Javascript,Web Sql,是否有方法检查WebSQL数据库中的表是否存在索引? 我正在使用CREATE UNIQUE INDEX\u GUID对表PERSONS进行创建。但如果索引已经存在,我会得到一个错误: 对我来说,最好的解决方案是列出一个表的所有索引 我正在使用这个,但这是一个解决办法。我希望错误信息都是英文的 db.transaction(function (tx) { tx.executeSql( "CREATE UNIQUE INDEX INDEX_GUID ON TABLE PER

是否有方法检查WebSQL数据库中的表是否存在索引? 我正在使用
CREATE UNIQUE INDEX\u GUID对表PERSONS
进行创建。但如果索引已经存在,我会得到一个错误:


对我来说,最好的解决方案是列出一个表的所有索引

我正在使用这个,但这是一个解决办法。我希望错误信息都是英文的

db.transaction(function (tx) {
    tx.executeSql(
        "CREATE UNIQUE INDEX INDEX_GUID ON TABLE PERSONS",
        [],
        function (tx, rs) {
            // index created
        },
        function (tx, e) {
            if (e.message.indexOf("already exists") == -1) {
                // index not created - already exists
            }
        });
    );
});

在我的情况下,如果不存在,则使用
。我需要知道索引是否存在。
db.transaction(function (tx) {
    tx.executeSql(
        "CREATE UNIQUE INDEX INDEX_GUID ON TABLE PERSONS",
        [],
        function (tx, rs) {
            // index created
        },
        function (tx, e) {
            if (e.message.indexOf("already exists") == -1) {
                // index not created - already exists
            }
        });
    );
});