我有这个密码散列函数,可以将密码散列到 sha256。我已经在本地数据库的 pgadmin3 中运行了它。我是通过导入扩展来完成的,这是几个版本前添加的功能。
为了我的功课,我需要在 phppgadmin 服务器中运行触发器,但是当我执行时
CREATE EXTENSION pgcrypto;
Run Code Online (Sandbox Code Playgroud)
我得到
ERROR: could not open extension control file "/usr/share/postgresql/9.1/extension/pgcrypto.control": No such file or directory
Run Code Online (Sandbox Code Playgroud)
如何在不必将我的哈希更改为较弱的哈希(md5 或 sha1)的情况下解决此问题?
我一生都无法弄清楚如何在我的 json 列的整数属性上创建索引。
我以这种方式尝试过(以及其他数十种方式)
CREATE INDEX user_reputation_idx ON users(("user"->>'reputation')::int)
Run Code Online (Sandbox Code Playgroud)
它在查询中工作得很好(例如ORDER BY ("user"->>'reputation')::int
)
我错过了什么?
更新
我收到一个简单的语法错误,但是,我真的不知道为什么。
ERROR: syntax error at or near "::"
LINE 1: ... user_reputation_idx ON users (("user"->>'reputation')::int)
Run Code Online (Sandbox Code Playgroud)
表定义非常简单。它只是一列user
type json
。
所以,看起来像这样:
CREATE TABLE users
(
"user" json
)
Run Code Online (Sandbox Code Playgroud) 我有一个 PostgreSQL 表,我需要创建一个带有新列的视图。此列需要是从 1 开始到 N 的自动增量列。
这是否可以在不影响遗留数据结构的原始模式的情况下完成?