帮助中心
- 平台介绍
- 接入指引
- 版本信息
- 使用流程
- 功能手册
- 操作视频
- 技术文档
- 基础知识
- 客户端SDK
- 服务端SDK
- 数据导入
- API功能
- SQL手册
- DML
- SQL函数
- 日期函数
- convert_tz
- curdate,current_date
- current_timestamp
- curtime,current_time
- date_add
- date_format
- date_sub
- datediff
- day
- dayname
- dayofmonth
- dayofweek
- dayofyear
- from_days
- from_unixtime
- hour
- makedate
- minute
- month
- monthname
- now
- second
- str_to_date
- time_round
- timediff
- timestampadd
- timestampdiff
- to_date
- to_days
- unix_timestamp
- utc_timestamp
- week
- weekday
- weekofyear
- year
- yearweek
- localtime,localtimestamp
- quarter
- last_day
- extract
- date_trunc
- minutes_add
- minutes_diff
- minutes_sub
- seconds_add
- seconds_diff
- seconds_sub
- hours_add
- hours_diff
- hours_sub
- days_add
- days_diff
- days_sub
- weeks_add
- weeks_diff
- weeks_sub
- months_add
- months_diff
- months_sub
- years_add
- years_diff
- years_sub
- 字符串函数
- append_trailing_char_if_absent
- to_base64
- from_base64
- ascii
- length
- bit_length
- char_length
- lpad
- rpad
- lower
- lcase
- upper
- ucase
- initcap
- repeat
- reverse
- char
- concat
- concat_ws
- substr
- substring
- sub_replace
- ends_with
- starts_with
- trim
- ltrim
- rtrim
- null_or_empty
- not_null_or_empty
- hex
- unhex
- elt
- instr
- locate
- find_in_set
- replace
- left
- right
- strleft
- strright
- split_part
- split_by_string
- substring_index
- money_format
- parse_url
- convert_to
- extract_url_parameter
- uuid
- space
- sleep
- 日期函数
- 数据类型
- 数据管理
- 常见问题
- 合规说明
- 资源下载
- AB测试
reverse
reverse
description
Syntax
VARCHAR reverse(VARCHAR str)
ARRAY<T> reverse(ARRAY<T> arr)
将字符串或数组反转,返回的字符串或者数组的顺序和原来的顺序相反。
example
mysql> SELECT REVERSE('hello');
+------------------+
| REVERSE('hello') |
+------------------+
| olleh |
+------------------+
1 row in set (0.00 sec)
mysql> SELECT REVERSE('你好');
+------------------+
| REVERSE('你好') |
+------------------+
| 好你 |
+------------------+
1 row in set (0.00 sec)
mysql> set enable_vectorized_engine=true;
mysql> select k1, k2, reverse(k2) from array_test order by k1;
+------+-----------------------------+-----------------------------+
| k1 | k2 | reverse(`k2`) |
+------+-----------------------------+-----------------------------+
| 1 | [1, 2, 3, 4, 5] | [5, 4, 3, 2, 1] |
| 2 | [6, 7, 8] | [8, 7, 6] |
| 3 | [] | [] |
| 4 | NULL | NULL |
| 5 | [1, 2, 3, 4, 5, 4, 3, 2, 1] | [1, 2, 3, 4, 5, 4, 3, 2, 1] |
| 6 | [1, 2, 3, NULL] | [NULL, 3, 2, 1] |
| 7 | [4, 5, 6, NULL, NULL] | [NULL, NULL, 6, 5, 4] |
+------+-----------------------------+-----------------------------+
mysql> select k1, k2, reverse(k2) from array_test01 order by k1;
+------+-----------------------------------+-----------------------------------+
| k1 | k2 | reverse(`k2`) |
+------+-----------------------------------+-----------------------------------+
| 1 | ['a', 'b', 'c', 'd'] | ['d', 'c', 'b', 'a'] |
| 2 | ['e', 'f', 'g', 'h'] | ['h', 'g', 'f', 'e'] |
| 3 | [NULL, 'a', NULL, 'b', NULL, 'c'] | ['c', NULL, 'b', NULL, 'a', NULL] |
| 4 | ['d', 'e', NULL, ' '] | [' ', NULL, 'e', 'd'] |
| 5 | [' ', NULL, 'f', 'g'] | ['g', 'f', NULL, ' '] |
+------+-----------------------------------+-----------------------------------+
作者:超级管理员 创建时间:2023-06-14 17:20
最后编辑:超级管理员 更新时间:2024-09-05 21:06
最后编辑:超级管理员 更新时间:2024-09-05 21:06