问题标签 [postgresql-14]
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.
sql - 尝试使用临时表中的标识列 INSERT INTO 表时出错
我正在尝试将临时表中的数据插入到另一个具有标识列的类似表中,并且无法正确无误地获取 SQL 语法。这是在 PostgreSQL 14 中。
暂存表:
要插入的表格:
插入查询:
我收到一个错误
错误:列“id”的类型为整数,但表达式的类型为字符变化
我在查询中尝试了几件事(如下所列),但它们都给出了错误。从固定值列表中搜索插入而不是从另一个表中插入时的大多数示例,例如...VALUES(guid, productimagehash_sha2256, productimage)...
。我在搜索中找不到类似的东西,希望有人能指出我正确的方向?
postgresql - 无法将 sql 模块加载到数据库集群中
我尝试在我的 Windows 10 中安装 postgreSQL v14.1.1 x64,但完成后出现错误
“未能将 sql 模块加载到数据库集群中”。
但是应用程序仍然运行,所以打开“pgadmin4”,连接服务器时输入postgres用户密码并得到以下错误
无法连接到服务器:连接被拒绝 (0x0000274D/10061) 服务器是否在主机“localhost”(::1) 上运行并接受端口 5432 上的 TCP/IP 连接?无法连接到服务器:连接被拒绝 (0x0000274D/10061) 服务器是否在主机“localhost”(127.0.0.1) 上运行并接受端口 5432 上的 TCP/IP 连接?
PS我在安装它时没有对端口进行任何更改,它是5432,而在设置密码时它是纯文本,不包括特殊字符。
postgresql - Having Trouble with a First Time Installation of PostgreSQL 14.1 on Ubuntu 18.04
I've been having a bit of trouble trying to install PostgreSQL 14 for the first time.
I would like to apologize in advance if this question has been asked in the manner that I am about to ask it, but I do not think it has. If it has been, please direct me to the appropriate location!
I've done a fair amount of Googling on the matter, and all the information that I find seems to be rather fragmented, or I end up following a spaghetti trail of hyperlinks (a la-do-this-and-follow-this-other-link-with-more-information-than-you-need-to-understand-this-other-required-portion). Personally, I don't want to jump around to 50 different locations on the web to try and conjure up a piecemeal solution that I believe works, only to be proven wrong later. I want to know what to do and why it works. I've tried reading the documentation, and have given up on it, because to me, it seems to assume that the server has already been set up by a database administrator.
Instead of articulating my problem directly (as I seem to be having more trouble than I would like by trying to do so), I believe it would be easier to articulate my problem indirectly by stating what my expectations would be after installing PostgreSQL for the first time.
So to start, I will mention that I'm running Ubuntu 18.04.6 LTS, and am installing PostgreSQL 14.1 with the following command:
Before continuing, I would like to add a side note in advance, that I do not want suggestions for an alternative OS or install method. I just want to be able to get "up and running" in a common-sense fashion from this exact point.
Moving on, I know that the aforementioned command creates a *nix user called postgres
.
From here, I can now indirectly state my problem using an outline of what my goals and expectations are immediately after installing the software via that command.
- After installing PostgreSQL via
apt
, these are my expected goals:- I want any client to be able to connect to the database server from any computer where a route exists from the client to the server.
- For the sake of simplicity with these stated goals, when it is directly or implicitly stated that I am trying to connect a client to the database server, I am making the assumption that the client is able to, at a minimum,
ping
the machine that the server is running on, and vice versa. - For now, I'm not completely worried about the database being accessible from the public Internet.
- I expect to be able to access the database from any computer on my LAN, whether it is an actual LAN, or some sort of logical LAN (like a WAN or a VPN).
- For the sake of simplicity with these stated goals, when it is directly or implicitly stated that I am trying to connect a client to the database server, I am making the assumption that the client is able to, at a minimum,
- If I change the PostgreSQL password of the postgres user, I expect that any client logging into the database server via the postgres user will require the password.
- This means if I want to change the password to some_password via
\password postgres
orALTER USER postgres WITH PASSWORD 'some_password';
(I am assuming this is how you change the login password of a PostgreSQL user), then...- I expect running
psql [-h host] -U postgres -W
from any host...- That when I am prompted to enter the password...
- I can only log in by entering the exact password of some_password.
- Entering any other arbitrary text for the password should not allow me to log in.
- I am adding this as a requirement because previous install attempts have shown me that this is NOT the case.
- That when I am prompted to enter the password...
- I expect running
- I expect to be able to create a PostgreSQL user account other than postgres (e.g. db_user) with a password and have it be subject to the same requirements as the postgres user.
- i.e. once the new account is given permission to log in, the same common-sense login requirements to log in must be imposed, i.e. you can't get in if you don't have the correct username/password combination.
- This means if I want to change the password to some_password via
- I want any client to be able to connect to the database server from any computer where a route exists from the client to the server.
If the process to achieve the aforementioned can be explained in such a way that it can be understood with minimal mental friction, I would be extremely grateful.
Feel free to assume that my knowledge is on par with that of a undergraduate CS student who just completed their first year of university, who also understands Linux filesystems and basic computer networking. I just want the answer to be as accessible to as many people as possible, as I am sure I'm not the only person who has struggled with installing PostgreSQL, in spite of having a power user's level of computer literacy.
sql - 格式化间隔日期类型作为 PostgreSQL 函数中的参数
在 PostgreSQL 函数中参数化间隔日期类型的最佳方法是什么?我有以下功能
每次我尝试执行该功能时,我都会收到以下错误ERROR: syntax error at or near "hours"
postgresql - 使用 pgpool2 的负载均衡器不工作,流媒体工作
我是 postgres 集群的新手,我正在尝试使用 pgpool2 归档负载均衡器,但它不起作用,请按照以下步骤操作,
这些是节点:
主节点即主节点 192.168.100.130 备用节点 192.168.100.131 pgpool 192.168.100.132
脚步 :
谢谢帕万
postgresql - PgSql 14-Pgagent 未与数据库连接
嗨,我正在使用 PgSql 14,并且我已经从堆栈生成器安装了它的相关 PgAgent。
通过使用本地和远程都没有连接到数据库。但是相同的作业脚本在 PgSQL 12.3 上运行良好,它是 PgAgent。
有哪些事情需要考虑。任何要检查 PGAGENT 的错误日志?请提出建议。
谢谢
postgresql - Postgresql:读取文件内容并插入到列中抛出'cat'不被识别为内部或外部命令,
我有 2 个文件。1) 是txt.sql
和 2) 是post.html
。我尝试使用 .sql 脚本插入到我的 postgresql 表中。使用了 windows cmd、Powershell 和我的 IDE(以及 vscode)。
我的脚本代码在这里txt.sql
和我的post.html代码在这里
myapp
当我针对数据库运行以下命令时。
得到以下结果并插入没有内容的数据
'cat' 不是内部或外部命令、可运行程序或批处理文件。插入 0 1
我相信cat
shell 命令仅适用于 unix,不适用于 windows。你能帮我用其他解决方案从文件中读取数据并插入到windows psql中的表列吗?
postgresql - Postgres 14 存储过程输出参数
我有一堆用于简单插入的函数(或过程),例如: insert_user( email );
它们中的大多数都返回inserted_id,无论是用于其他过程还是驱动程序。而有些则没有,比如插入到没有 id 的多对多表中。
PG 存储过程的参数似乎以 SQL 标准方式处理,而不像 PG 函数。它们不是可选的/可默认的,因此每次不需要 id 时都会以结尾的 null 结尾,例如:
那感觉很笨拙。如果我可以重载它,那就太棒了,但令人惊讶的是,你不能使用 out 参数,即使它们是签名的必需部分。我可以为每个插入创建第二个过程,例如:
但后来我有双倍的过程来测试和维护。我可以切换到函数,它不需要 out_id 的额外参数,如果我不想要它可以忽略 out_id。但是“插入”函数必须以 SELECT ex 开头:
关于“选择插入”的一些东西让人感觉不舒服。尤其是返回 void 的多对多插入。任何想法或建议将不胜感激!
sql - 根据以前的记录,停止总和字段
我有一张这样的桌子:
sum
我的目标是从现在到日期获取point
s 点大于等于 1 并停止该日期之前的字段总和。
在上面的示例中(按日期排序),答案是sum
将 date now( 2022/01/06
) 指向日期2022/01/04
并等于9 + 7 + 1 = 17
。由于日期的点值2022/01/03
等于 4,因此不在 中计算sum
。
我阅读了有关CTE和Window Functoin的信息,但是我无法正确实现它们。
laravel - Laravel 8 Postgres 用户卖家角色属性
您好,我想在 Laravel 8 和 Postgresql 中创建一个电子商务应用程序。我正试图围绕如何创建一个用户数据库,让买家可以选择成为卖家。我会在表格上将卖家 ID 属性设置为 null 并通过 Laravel 上的安全策略处理授权吗?