【发布时间】:2016-01-12 21:23:58
【问题描述】:
我是通过 R 连接到 Redshift 的新手,我已阅读其他问题,但在尝试创建表时仍然出现错误。 我已经成功建立了一个连接,我认为建立表成功:
redshiftcon <- dbConnect(mm, user="username", password="secret_password",
dbname="dbtable", host="hostname", port="portnumber")
dbSendQuery(redshiftcon,
"create table ss_playground.test_table (unique_id VARCHAR,
category VARCHAR,
name VARCHAR,
number_min float);")
<PostgreSQLResult:(70214,5,1)>
但是,当我尝试检查表是否存在以及字段是否存在时,我收到以下消息:
dbExistsTable(redshiftcon, ss_playground.test_table)
Error in is(object, Cl) :
error in evaluating the argument 'name' in selecting a method for function
'dbExistsTable': Error: object 'ss_playground.test_table' not found
> dbExistsTable(redshiftcon, 'ss_playground.test_table')
[1] FALSE
我很困惑,因为我以为表创建成功,但在数据库本身中也找不到。 当我尝试发送它并再次创建它时,我得到以下信息:
> dbSendQuery(redshiftcon,
"create table ss_playground.test_table (unique_id VARCHAR,
category VARCHAR,
name VARCHAR,
number_min float);")
Error in postgresqlExecStatement(conn, statement, ...) :
RS-DBI driver: (could not Retrieve the result : ERROR: Relation
'test_table' already exists)
我有什么遗漏吗?
请帮忙! 谢谢
【问题讨论】:
-
我不确定,但请在创建表后尝试添加
commit;。您的更改可能是特定于会话的,您可能想先提交它们。
标签: r amazon-redshift rpostgresql