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';
标签:INDEX,name,驼峰,column,SUBSTRING,SUBSTR,LENGTH,sql,下划线 From: https://www.cnblogs.com/RedOrange/p/17091716.html