开发中的 SQLite,生产中的 PostgreSQL——为什么不呢?

2021-12-16 00:00:00 postgresql heroku ruby-on-rails sqlite

Heroku 建议不要这样做,因为可能存在问题.我是一个 SQL 菜鸟,你能解释一下使用不同数据库可能遇到的问题类型吗?

Heroku advises against this because of possible issues. I'm an SQL noob, can you explain the type of issues that could be encountered by using different databases?

推荐答案

不同的数据库以不同的方式解释和遵守 SQL 标准.例如,如果您要将一些代码从 SQLite 复制粘贴到 PostgreSQL,那么它很可能不会立即起作用.如果它只是基本查询,那么也许可以,但在处理任何特定问题时,完全兼容的可能性非常低.

Different databases interpret and adhere to the SQL standard differently. If you were to, say, copy paste some code from SQLite to PostgreSQL there's a very large chance that it won't immediately work. If it's only basic queries, then maybe, but when dealing with anything particular there's a very low chance of complete compatability.

有些数据库也更符合标准.这是一个类似于互联网浏览器的战场.如果你曾经制作过一些网站,你就会知道兼容性是个麻烦事,必须让它在旧版本和 Internet Explorer 上工作.因为有些数据库比其他数据库更旧,有些甚至比标准更旧,他们会有自己的做事方式,他们不能只是废弃并跳到标准,因为他们会失去对现有大客户的支持(使用名为 Oracle 的数据库引擎尤其如此).PostgreSQL 有点像 Google Chrome,在标准合规性方面相当高,但仍然有一些自己的小怪癖.顾名思义,SQLite 是一个轻量级的数据库系统.您可以假设它缺少标准中的一些更高级的功能.

Some databases are also more up to date with the standard. It's a similar battlefield to that of internet browsers. If you've ever made some websites you'd know compatability is a pain in the ass, having to get it to work for older versions and Internet Explorer. Because some databases are older than others, and some even older than the standards, they would've had their own way of doing things which they can't just scrap and jump to the standard because they would lose support for their existing larger customers (this is especially the case with a database engine called Oracle). PostgreSQL is sort of like Google Chrome, quite high up there on standards compliance but still with some of its own little quirks. SQLite is, as the name suggests, a light-weight database system. You could assume it lacks some of the more advanced functionality from the standards.

数据库引擎也以不同的方式执行相同的操作.了解和了解一个数据库及其工作原理(比查询级别更深入)是值得的,这样您就可以充分利用它.

The database engines also perform the same actions differently. It is worth getting to know and understand one database and how it works (deeper than just the query level) so you can make the most of that.

相关文章