將表結構轉換成實體欄位

qq_38807792發表於2020-12-08
SELECT
	CONCAT(
	CHAR ( 13 ),
	"/** ",
	COLUMN_COMMENT,
	"*/",
	CHAR ( 10 ),
	'private  ',
CASE
	data_type 
	WHEN 'varchar' THEN
	'String' 
	WHEN 'char' THEN
	'String' 
	WHEN 'text' THEN
	'String' 
	WHEN 'int' THEN
	'Integer' 
	WHEN 'tinyint' THEN
	'Integer' 
	WHEN 'decimal' THEN
	'double' 
	WHEN 'double' THEN
	'double' 
	WHEN 'float' THEN
	'double' ELSE 'String' 
	END,
	" ",
	column_name,
	"; " 
) AS resultString,
column_name,
data_type,
column_comment 
FROM
	information_schema.COLUMNS 
WHERE
	table_name = 'table_name'

 

相關文章