Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/postgresql/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby-on-rails-4/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Postgresql 如何手动更改heroku数据库中的记录_Postgresql_Ruby On Rails 4_Heroku_Heroku Toolbelt - Fatal编程技术网

Postgresql 如何手动更改heroku数据库中的记录

Postgresql 如何手动更改heroku数据库中的记录,postgresql,ruby-on-rails-4,heroku,heroku-toolbelt,Postgresql,Ruby On Rails 4,Heroku,Heroku Toolbelt,我有一个在heroku托管的rails应用程序。我有一个带内容栏的问题表。“内容”列包含问题的单词。例如,如果您查询。问题。首先。内容,你会得到“你好吗?”。我一共有8个问题。我想手动进入数据库并更改这些问题 我尝试使用以下命令在heroku上运行终端: heroku pg:psql 我使用这个查询来更改记录的内容列 UPDATE Questions SET content="What country does this story orginate? (Japan)" 但是,我收到以下

我有一个在heroku托管的rails应用程序。我有一个带内容栏的问题表。“内容”列包含问题的单词。例如,如果您查询。问题。首先。内容,你会得到“你好吗?”。我一共有8个问题。我想手动进入数据库并更改这些问题

我尝试使用以下命令在heroku上运行终端:

heroku pg:psql
我使用这个查询来更改记录的内容列

UPDATE Questions
SET content="What country does this story orginate? (Japan)"  
但是,我收到以下错误消息:

错误:“这个故事起源于哪个国家?(日本)”栏不存在
第2行:SET content=“这个故事起源于哪个国家?(日本)


更改问题内容列的正确查询是什么?

SQL对字符串文本使用单引号,对标识符(如表名和列名)使用双引号,这就是为什么您会收到关于未知列的投诉。修复方法很简单,对字符串文字使用单引号:

update questions set content = '...' where ...

有些数据库允许对字符串使用双引号,但这是非标准的,应该避免使用。

事实证明我可以使用heroku run console。进入控制台后,我可以执行活动记录查询,如
Question.find(1).更新属性(:content=>“你好吗?”)
并进行更新。无论出于何种原因,heroku run rails console没有使用活动记录查询更新记录,只是返回查询成功

或者您可以使用rails控制台-heroku运行rails c