我正在尝试从一列字符串中编辑“\n”换行符,如何修改已加载的table中的数据?

I am trying to edit the "\n" new line character from a column of strings, how can I modify the data in the already loaded table?

我一直在尝试从 table 列中删除所有换行符并替换为 spaces。我尝试了以下方法:

其中 none 有效。

None 这些查询抛出错误,但它们也没有删除任何换行符。

只是为了澄清,对于大多数这些查询,如果我 运行 它们在一个单独的字符串上,它们就可以工作。例如,select regexp_replace('hello \n world', '\n',' ') 给出了 "hello world" 的期望输出。但是,运行在整个列上使用它似乎不起作用。 (运行 其他替换查询对整个列都有效 - 只是这个换行符似乎不起作用。)

这是我生成的一些我们可以测试的数据,这是我的 .sql 文件,之前答案是换行符而不是文字“\n”字符,这是我的想。

我尝试了什么:

USE Warehouse "Test";
Create database "strings";
Use database "strings";

CREATE OR REPLACE TABLE Lora_ipsum(line varchar); 

INSERT INTO Lora_ipsum Values
('What is Lorem Ipsum?\n'),
('Lorem Ipsum is simply dummy text of the printing and typesetting industry.\n'),
( 'Lorem Ipsum has been the industrys standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.\n'),
('It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged.\n'),
('It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.\n'),
('Why do we use it?\n'),
('It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout.\n'),
( 'The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using Content here, content here,\n'),
(' making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text,\n'),
('and a search for lorem ipsum will uncover many web sites still in their infancy.\n'),
('Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).\n'),
('\n'),
('Where does it come from?\n'),
('Contrary to popular belief\n'); 

Select line FROM Lora_ipsum;

结果是所有数据点都存储在 varchar 中,\n 不可见,我使用了单引号。

所以我尝试了建议的解决方案,其中:

SELECT REPLACE(line,'\n',' ') FROM Lora_ipsum;

结果将一些数据 varchar 项更改为蓝色和黑色:

我使用的第二个建议在第 3 项中没有 space 作为:

select replace(line,'\n','') from Lora_ipsum;

结果是一样的。

如果我在字符串中有文字“\n”,我的 table 的数据类型是否不正确,是否有正则表达式来删除文字而不是新行? 谢谢您的帮助。

这很奇怪,以下所有对我有用(我使用 # 而不是   所以我可以看到):

SELECT
  LINE,
  TRANSLATE(LINE, '\r\n','##') "TRANSLATE",
  REGEXP_REPLACE(LINE, '\r?\n','#') "REGEXP_REPLACE",
  REPLACE(LINE, '\n','#') "REPLACE",
  REPLACE(LINE, CHR(10),'#') "REPLACE_CHR"
FROM LORA_IPSUM;

也许这是一个已修复的错误? @Rachel:这个箱子多大了?