如何将ID列数据类型整数更改为Hasura中的自动信息Integer
我在hasura控制台中遇到了此错误:
{ "internal": { "statement": "ALTER TABLE users\nADD id Integer auto-increment;", "prepared": false, "error": { "exec_status": "FatalError", "hint": null, "message": "syntax error at or near \"auto\"", "status_code": "42601", "description": null }, "arguments": [] }, "path": "$[0]", "error": "query execution failed", "code": "postgres-error" }
检查了我的表后,我发现我不将ID列提供给整数(自动插入)数据类型现在ID列使用另一个表攻击,所以我无法删除它,所以我想要要将ID列更改为自动收入,我将Postgres数据库与Hasura和GraphQl一起使用,
这是我的ID
id - integer, primary key, unique, default: nextval('users_id_seq'::regclass)
I got this error in hasura console:
{ "internal": { "statement": "ALTER TABLE users\nADD id Integer auto-increment;", "prepared": false, "error": { "exec_status": "FatalError", "hint": null, "message": "syntax error at or near \"auto\"", "status_code": "42601", "description": null }, "arguments": [] }, "path": "$[0]", "error": "query execution failed", "code": "postgres-error" }
After checking my table, I find that I don't give the id column to the integer (auto-increment) datatype now id column is attack with another table so I can not delete it so I want to change id column to auto-increment and I use Postgres database with Hasura and graphql
This is my id look like
id - integer, primary key, unique, default: nextval('users_id_seq'::regclass)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您没有序列,则必须为表创建序列:
之后您可以将此序列添加到表格:
之后,您必须将序列值更新为
max(id)(id)(id)
of Table:If you have not a SEQUENCE firstly you must create sequence for table:
After than you can add this sequence to your table:
After than, you must update your sequence value to
max(id)
of table: