[英]How to prevent Spring Boot/Hibernate from converting entity column names from PascalCase to snake_case?
[英]Change the values in a column from PascalCase to snake_case using SQL
我有一張雪花表,看起來像這樣:
--------------------
| fieldname |
--------------------
|thisIsTestOne |
|thisIsTestTwo |
|this_test |
--------------------
我需要將列中的 PascalCase 值轉換為 snake_case。 注意:如果它們是 PascalCase,我只想將它們轉換為 snake_case。 output 應該是這樣的;
-------------------- ---------------------
| fieldname | newfieldname |
-------------------- ---------------------
|thisIsTestOne |this_is_test_one |
|thisIsTestTwo |this_is_test_two |
|this_test |this_test |
-------------------- ---------------------
您應該能夠使用REGEXP_REPLACE
在小寫字符后跟大寫字符之間插入下划線,然后將LOWER
轉換為小寫,即
SELECT LOWER(REGEXP_REPLACE(fieldname, '([a-z])([A-Z])', '\\1_\\2'))
FROM yourtable
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.