xamarin开发常见错误总结--Sqlite本地数据库使用了保留字段导致语法错误
1.1.1 数据表使用了Sqlite并且字段上使用了Sqlite的保留字段
1.1.1.1 概述
如果使用Sqlite作为本地数据库,创建表的时候,表里的字段使用了Sqlite的保留字段。这个时候直接使用Sql语句进行操作数据库表的时候,就会报错,错误截图如下所示:
1.1.1.1.1 Sqlite保留字段参考链接
https://www.sqlite.org/lang_keywords.html
1.1.1.2 原因分析
使用了保留字段+使用了直接使用Sql语句操作数据库
1.1.1.3 参考链接
https://cloud.tencent.com/developer/ask/49047
1.1.1.4 解决方案
1.1.1.4.1 修改字段名为非保留字段
1.1.1.4.2 使用如下方式描述字段
'keyword' A keyword in single quotes is a string literal.
"keyword" A keyword in double-quotes is an identifier.
[keyword] A keyword enclosed in square brackets is an identifier. This is not standard SQL. This quoting mechanism is used by MS Access and SQL Server and is included in SQLite for compatibility.
`keyword` A keyword enclosed in grave accents (ASCII code 96) is an identifier. This is not standard SQL. This quoting mechanism is used by MySQL and is included in SQLite for compatibility.
1.1.1.4.3 Dapper操作时推荐使用[keyword]形式
1.1.1.5 总结
之后涉及数据库表的时候,尽量避免使用关键字,这样可以避免好多不必要的麻烦。(例如,给表名或字段名前后添加个性化的前后缀)
相关文章
- 【ARM-Linux开发】嵌入式操作系统上的小型数据库移植SQLite
- SQlite数据库框架:LitePal
- sqlite 使用记录
- IOS学习:ios中的数据持久化初级(文件、xml、json、sqlite、CoreData)
- Android中使用adb访问SQLite的方法
- SQLite简介
- SQLite中sqlite3_column_value()的返回值
- SQLite Editor
- iOS学习之sqlite的创建数据库,表,插入查看数据
- android SQLite数据库用法图文详解(附源码)
- .NET Core 2.1 EF(Entity Framework) Core Sqlite配置和使用分享
- 用Python进行SQLite数据库操作
- android直接读取项目中的sqlite数据库
- 43.QT-访问远程SQLite数据库