postgresql 连接到 Redshift 时出现 SQL 工作台错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/29222533/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 05:56:15  来源:igfitidea点击:

SQL workbench Error while connecting to Redshift

postgresqlamazon-web-servicesamazon-redshift

提问by user3858193

I am trying to create a table in aws redshift using sqlwork bench. I am able to connect redshift but while executing below script, I am getting connection aborted error. Please let me know if any one has any solution.

我正在尝试使用 sqlwork bench 在 aws redshift 中创建一个表。我能够连接 redshift,但是在执行下面的脚本时,出现连接中止错误。如果有人有任何解决方案,请告诉我。

CREATE  TABLE actual_report (
  type1 varchar(40),
  Jj_calendar_Order_Month varchar(40),
  Jj_Calendar_Order_Year varchar(40),
  Product_major_Code_description varchar(40),
  Product_minor_Code varchar(40),
  Product_part_number varchar(40),
  Product_Minor_Description varchar(40),
  Order_Quantity decimal(20),
  Order_Item_Unit_Price decimal(10,2),
  country varchar(40))

An error occurred when executing the SQL command: CREATE TABLE actual_report ( type1 varchar(40), Jj_calendar_Order_Month varchar(40), Jj_Calendar_Order_Year varchar(40), Product_major_Code_descripti...

执行SQL命令时出错:CREATE TABLE actual_report ( type1 varchar(40), Jj_calendar_Order_Month varchar(40), Jj_Calendar_Order_Year varchar(40), Product_major_Code_descripti...

Amazon Invalid operation: current transaction is aborted, commands ignored until end of transaction block; Execution time: 0.22s 1 statement failed.

亚马逊无效操作:当前交易被中止,命令被忽略,直到交易块结束;执行时间:0.22s 1 条语句失败。

采纳答案by user3858193

I got it. Below script worked out for me. I just removed (_).

我知道了。下面的脚本对我有用。我刚刚删除了(_)。

CREATE  TABLE actual_report (
type1 varchar(40),
JjcalendarOrderMonth varchar(40),
JjCalendarOrderYear varchar(40),
ProductmajorCodedescription varchar(40),
ProductminorCode varchar(40),
Productpartnumber varchar(40),
ProductMinorDescription varchar(40),
OrderQuantity decimal(20),
OrderItemUnitPrice decimal(10,2),
country varchar(40))

回答by keypoint

I'm using SQL Workbench, and by default autocommit is off. I run the SQL command below to turn on autocommit, otherwise the transaction will not be committed to database. Just for your reference.

我正在使用 SQL Workbench,默认情况下自动提交是关闭的。我运行下面的 SQL 命令打开 autocommit,否则事务将不会提交到数据库。仅供参考。

SET autocommit ON

回答by Anuj Sethi

Set Autocommit to TRUE in SQL Workbench connection window. See attached image:

在 SQL Workbench 连接窗口中将 Autocommit 设置为 TRUE。见附图:

Set Autocommit to TRUE in SQL Workbench connection window

在 SQL Workbench 连接窗口中将 Autocommit 设置为 TRUE

回答by Conor

Unless you start one explicitly, every Redshift query you make is wrapped in a transaction: http://docs.aws.amazon.com/redshift/latest/dg/r_BEGIN.html

除非您明确开始,否则您所做的每个 Redshift 查询都包含在一个事务中:http: //docs.aws.amazon.com/redshift/latest/dg/r_BEGIN.html

To fix this issue when it arises again, enter ROLLBACK;on a line by itself and run it. This should bring your connection back to working order.

要在再次出现此问题时解决此问题,请单独输入ROLLBACK;一行并运行它。这应该使您的连接恢复正常工作。