将表格的一个字段分开最多5个单独的行,每个记录分隔符字符的每个实例(char(30))
我目前正在研究一个Oracle SQL脚本,该脚本需要将下表的地址字段拆分下面的地址字段最多5行。上述字段由记录分离器角色界定(char(30)。我想索要任何建议的方法如何提出上述数据?
请参阅下面的示例数据。
| ID | ADDRESS |
|;--------|;-------------------------------------------------------|
| 1000000 | Xxxxx XxxxxXxxxx XxxxXxxxxx xx Xxxxxx |
| 1000001 | 61 Xxxxxxx XxxxXxxxxxxXxxx |
| 1000002 | 36 Xxxxx XxxXxxxxxxxxXxxxxxxxxxxxxxXxxxxxxxxxxxxxxx |
上面的样本如下。
| ID | ADDRESS1 | ADDRESS2 | ADDRESS3 | ADDRESS4 | ADDRESS5|
|;--------|;----------------|;-----------|;-----------------|;-----------------|;--------|
| 1000000 | Xxxxx Xxxxx | Xxxxx Xxxx | Xxxxxx xx Xxxxxx | | |
| 1000001 | 61 Xxxxxxx Xxxx | Xxxxxxx | Xxxx | | |
| 1000002 | 36 Xxxxx Xxx | Xxxxxxxxx | Xxxxxxxxxxxxxx | Xxxxxxxxxxxxxxxx | |
I am currently working on an Oracle SQL script that needs to split the ADDRESS field of the table below up to 5 separate rows. The said field is delimited by a record separator character (CHAR(30). I would like to ask for any recommended approach how to come up with the said data?
Please see sample data below.
| ID | ADDRESS |
|;--------|;-------------------------------------------------------|
| 1000000 | Xxxxx XxxxxXxxxx XxxxXxxxxx xx Xxxxxx |
| 1000001 | 61 Xxxxxxx XxxxXxxxxxxXxxx |
| 1000002 | 36 Xxxxx XxxXxxxxxxxxXxxxxxxxxxxxxxXxxxxxxxxxxxxxxx |
The expected output of the sample above is as follows.
| ID | ADDRESS1 | ADDRESS2 | ADDRESS3 | ADDRESS4 | ADDRESS5|
|;--------|;----------------|;-----------|;-----------------|;-----------------|;--------|
| 1000000 | Xxxxx Xxxxx | Xxxxx Xxxx | Xxxxxx xx Xxxxxx | | |
| 1000001 | 61 Xxxxxxx Xxxx | Xxxxxxx | Xxxx | | |
| 1000002 | 36 Xxxxx Xxx | Xxxxxxxxx | Xxxxxxxxxxxxxx | Xxxxxxxxxxxxxxxx | |
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是一个选项:
Here's one option:
您可以使用简单的字符串函数(比正则表达式快的数量级):
对于示例数据:
输出:
If you did want to use (slower) regular expressions then:
Which outputs the same 。
db<>>
You can use simple string functions (which are an order of magnitude faster than regular expressions):
Which, for the sample data:
Outputs:
If you did want to use (slower) regular expressions then:
Which outputs the same.
db<>fiddle here