Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我需要同时(同时)运行两个会话(两个文件)。有没有办法使用 pg_sleep 或“delayExecutionUntil(x_time)”之类的其他函数来做到这一点?
要在(几乎)完全相同的时间获得两个事务,您可以使用命令在 Linux shell 中同时安排两个或多个psql调用。at
at
喜欢:
at '08:00 01.12.2012' -f script.sql
(所需的时间戳格式可能取决于您的系统区域设置。) 其中script.sql包含以下内容:
script.sql
psql mydb -p 5432 -c "INSERT INTO tbl (col) VALUES ('foo');
只是有更多的行来引发你所追求的碰撞..
您可以使用表锁(请参阅LOCK文档中的命令)来同步内容:
LOCK