通过sql拼接表的下划线转驼峰
SELECT
-- COLUMN_NAME,
-- _分割之后的第一段
concat( SUBSTRING_INDEX(LOWER(column_name), '_', 1),
-- _分割之后的第二段
SUBSTR(
UPPER(column_name),
LENGTH(
SUBSTRING_INDEX(column_name, '_', 1)
) + 2,
1
),
SUBSTR(
LOWER(column_name),
LENGTH(
SUBSTRING_INDEX(column_name, '_', 1)
) + 3,
LENGTH(
SUBSTRING_INDEX(column_name, '_', 2)
) - LENGTH(
SUBSTRING_INDEX(column_name, '_', 1)
) - 2
), -- _分割之后的第三段
SUBSTR(
UPPER(column_name),
LENGTH(
SUBSTRING_INDEX(column_name, '_', 2)
) + 2,
1
),
SUBSTR(
LOWER(column_name),
LENGTH(
SUBSTRING_INDEX(column_name, '_', 2)
) + 3,
LENGTH(
SUBSTRING_INDEX(column_name, '_', 3)
) - LENGTH(
SUBSTRING_INDEX(column_name, '_', 2)
) - 2
),
-- _分割之后的第四段
SUBSTR(
UPPER(column_name),
LENGTH(
SUBSTRING_INDEX(column_name, '_', 3)
) + 2,
1
),
SUBSTR(
LOWER(column_name),
LENGTH(
SUBSTRING_INDEX(column_name, '_', 3)
) + 3,
LENGTH(
SUBSTRING_INDEX(column_name, '_', 4)
) - LENGTH(
SUBSTRING_INDEX(column_name, '_', 3)
) - 2
)),
column_comment
FROM
INFORMATION_SCHEMA.COLUMNS
WHERE
table_name = 'scd_cost_charge_item';
本文来自博客园,作者:格,转载请注明原文链接:https://www.cnblogs.com/yuangyuan/p/16449815.html