问题标签 [postgresql]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
18 回答
31351 浏览

sql - 'active' 标志与否?

好的,所以实际上每个基于数据库的应用程序都必须处理“非活动”记录。无论是软删除还是将某些内容标记为“被忽略”。我很好奇在“活动”列(或状态列)上是否有任何激进的替代想法。

例如,如果我有一个人员列表

这意味着要获取活跃人员列表,您需要使用

有没有人建议将非活动记录移到单独的表中,并在哪里进行适当的 UNION 来加入两者?

好奇心强...

编辑: 我应该说清楚,我是从纯粹主义者的角度来看的。我可以看到对于大量数据可能需要数据归档,但这不是我的出发点。如果您执行 SELECT * FROM people ,那么这些条目在某种意义上是“活跃的”对我来说是有意义的

谢谢

0 投票
9 回答
145095 浏览

windows - Windows 的好 postgresql 客户端?

经过几年的 oracle 回到 postgresql ......

Windows 上最先进的 postgresql 管理/ddl 生成/数据插入前端是什么?如果它也集成了 postgis 那就太好了。它应该是独立的,或者是 intellij idea 的插件

回想起来,我使用的所有针对 postgresql 的 Windows 程序都是垃圾,尤其是 PGAdmin。它变得更好了吗?

0 投票
1 回答
13748 浏览

java - Hibernate 3:无法查询 PostgreSQL 数据库

我正在使用Hibernate 3.3.1 GAand设置一个项目PostgreSQL 8.3。我刚刚创建了一个数据库,第一个表,在那里添加了一行,现在正在配置 Hibernate。

但是,即使是最简单的查询:

无法执行(尽管数据库中有一条记录,但返回空列表)。我查看了 PostgreSQL 日志以查看:

我使用纯 JDBC 编写了一个简单的程序来获取相同的数据,并且它工作正常。这种情况下的 PostgreSQL 日志如下所示(用于比较):

Hibernate 调试日志不指示任何错误。如果我采用日志中列出的查询:

并在 psql 中再次执行数据库,它可以工作(这意味着 Hibernate 已经生成了正确的 SQL)。

下面是休眠配置:

...和映射文件:

谷歌搜索unexpected EOF日志条目并不有趣。任何想法,社区?

0 投票
22 回答
1284290 浏览

postgresql - PostgreSQL“描述表”

您如何DESCRIBE TABLE在 PostgreSQL 中执行相当于 Oracle 的操作(使用 psql 命令)?

0 投票
3 回答
9578 浏览

mysql - 将 PostgreSQL 数据库转换为 MySQL

我已经看到了反向操作的问题,但是我有一个 800MB 的 PostgreSQL 数据库需要转换为 MySQL。我假设这是可能的(一切皆有可能!),我想知道解决此问题的最有效方法以及需要注意的任何常见错误。我几乎没有使用 Postgre 的经验。任何指向这方面指南的链接也会有所帮助!谢谢。

0 投票
6 回答
21523 浏览

sql - Update VERY LARGE PostgreSQL database table efficiently

I have a very large database table in PostgresQL and a column like "copied". Every new row starts uncopied and will later be replicated to another thing by a background programm. There is an partial index on that table "btree(ID) WHERE replicated=0". The background programm does a select for at most 2000 entries (LIMIT 2000), works on them and then commits the changes in one transaction using 2000 prepared sql-commands.

Now the problem ist that I want to give the user an option to reset this replicated-value, make it all zero again.

An update table set replicated=0;

is not possible:

  • It takes very much time
  • It duplicates the size of the tabel because of MVCC
  • It is done in one transaction: It either fails or goes through.

I actually don't need transaction-features for this case: If the system goes down, it shall process only parts of it.

Several other problems: Doing an

is also bad: It does a sequential scan all over the whole table which is too slow. If it weren't doing that, it would still be slow because it would be too many seeks.

What I really need is a way of going through all rows, changing them and not being bound to a giant transaction.

Strangely, an

is also slow, although it should be a good thing: Go through the table in DISK-order...

(Note that in that case there was also an index that covered this)

(An update LIMIT like Mysql is unavailable for PostgresQL)

BTW: The real problem is more complicated and we're talking about an embedded system here that is already deployed, so remote schema changes are difficult, but possible It's PostgresQL 7.4 unfortunately.

The amount of rows I'm talking about is e.g. 90000000. The size of the databse can be several dozend gigabytes.

The database itself only contains 5 tables, one is a very large one. But that is not bad design, because these embedded boxes only operate with one kind of entity, it's not an ERP-system or something like that!

Any ideas?

0 投票
2 回答
2183 浏览

nhibernate - 如何从 NHibernate 映射文件生成“迁移”DDL?

我在我的项目中使用 NHibernate 2 和 PostgreSQL。SchemaExport 类在为数据库生成 DDL 方案方面做得很好,但在第一个应用程序之前它就很棒。

有没有办法使用 NHibernate 映射文件生成“迁移”DLL(一批“ALTER TABLE”而不是 DROP/CREATE 对)?

0 投票
7 回答
64238 浏览

postgresql - PostgreSQL 解释到底告诉我什么?

MySQL 的解释输出非常简单。PostgreSQL 有点复杂。我也找不到解释它的好资源。

你能描述一下确切的解释是什么,或者至少给我指出一个好的资源的方向吗?

0 投票
3 回答
8749 浏览

sql - 在 Common Lisp 中使用的最佳 SQL 库是什么?

理想情况下,可以与 Oracle、MS SQL Server、MySQL 和 Posgress 一起使用。

0 投票
2 回答
1415 浏览

python - 尝试安装 psycopg2 时“找不到 -lpq”

简介:我正在尝试将我们的 Trac SQLite 迁移到 PostgreSQL 后端,为此我需要 psycopg2。点击 www.initd.org 上令人尴尬的咆哮后,我下载了最新版本并尝试运行setup.py install. 这没有用,告诉我我需要mingw。所以我下载并安装了mingw。

问题:我现在在运行时收到以下错误setup.py build_ext --compiler=mingw32 install

我试过的 - 我注意到 -L 选项中的正斜杠,所以我在 setup.cfg 的 library_dirs 选项中手动输入了我的 PostgreSQL lib 目录,但无济于事(然后调用有一个带反斜杠的 -L 选项,但错误信息保持不变)。