当前位置:Gxlcms > mysql > 使用sql生成表对应的CRUD语句和表对应java实体类的实例变量

使用sql生成表对应的CRUD语句和表对应java实体类的实例变量

时间:2021-07-01 10:21:17 帮助过:44人阅读

该sql运行于mysql 无 SELECTCONCAT('SELECT ',GROUP_CONCAT(COLUMN_NAME),' FROM ',TABLE_NAME)FROMinformation_schema. COLUMNSWHERETABLE_NAME = 'worker'; 其中 表名为worker SELECTCONCAT("UPDATE worker SET ",GROUP_CONCAT(COLUMN_NAME,"= ()")," WHERE

该sql运行于mysql <无>
SELECT
	CONCAT(
		'SELECT ',
		GROUP_CONCAT(COLUMN_NAME),
		' FROM ',
		TABLE_NAME
	)
FROM
	information_schema. COLUMNS
WHERE
	TABLE_NAME = 'worker'; 
其中 表名为worker 
SELECT
	CONCAT(
		"UPDATE worker SET ",
		GROUP_CONCAT(
			COLUMN_NAME,
			"= ()"
		),
		" WHERE Id = "
	)
FROM
	information_schema. COLUMNS
WHERE
	TABLE_NAME = 'worker';
SELECT
    CONCAT(
        'INSERT INTO worker( ',
        GROUP_CONCAT(COLUMN_NAME),
        ') VALUES (',
        GROUP_CONCAT(
            CONCAT('()')
        ),
        ')'
    )
FROM
    information_schema. COLUMNS
WHERE
    TABLE_NAME = 'worker' ;
SELECT
    CONCAT(
        'private ',
        (
            CASE
            WHEN DATA_TYPE = 'varchar' THEN 'String '
            WHEN DATA_TYPE = 'datetime' THEN
                'Date '
            WHEN DATA_TYPE = 'int' THEN
                'int '
	    WHEN DATA_TYPE = 'float' THEN
                'float '
            END
        ),
        COLUMN_NAME,' ;	//',COLUMN_COMMENT
    )
FROM
    information_schema. COLUMNS
WHERE TABLE_NAME = 'worker' ;

人气教程排行