将函数 Postgresql 转换为 Sqlite
我的 iPad 应用程序出现问题。我必须将 PostgreSQL 数据库转换为 SQLite 数据库。幸运的是我做到了,但我不知道如何转换 PostgreSQL 函数。有人知道怎么做吗?或者我怎样才能在 Sqlite 中得到相同的结果?
预先感谢,卢卡
I have a problem with my iPad app. I have to convert a PostgreSQL database to SQLite database. Luckily I did it but I didn't know how to convert the PostgreSQL functions. Anyone knows how to did it? Or how can I get the same result in Sqlite?
Thanks in advance, Luca
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
正如您已经发现的那样,sqlite 没有任何功能。因此,您可能需要将函数中的一些逻辑和单个查询从数据库移至应用程序中。这可能意味着执行一个查看结果的查询,并基于该结果执行更多查询。因此您可以在应用程序中执行该函数的逻辑。
虽然在 PostgreSQL 中不建议这样做,因为性能会受到许多小查询的影响,但 SQlite 中的性能损失要小得多,因为它是嵌入式数据库(无通信开销),而且它的规划器更直接,这使得单独查询的规划开销更小。
As you allready discovered sqlite has no functions. So you will probably have to move some logic from the function and the single query out of your db into your app. This will probably mean executing a query looking at the result and based on that executing some more queries. So you can do the logic of the function in your app.
While this is not recommended in PostgreSQL as performance suffers from many small queries the performance loss in SQlite is much smaller as it is an embedded database (no communication overhead) and it's planner is more straight forward which makes the planning overhead of seperate queries smaller.