sql 获取表字段名称

有时候需要些插入语句需要写字段名称,但由于字段很多所有比较麻烦。用以下的语句就可以直接把所有字段名称查出来直接用了

select GROUP_CONCAT(COLUMN_NAME) from information_schema.COLUMNS where table_name = 'activity_info';  

 

合并不同数据库中相同的表:表id 增加100(这个数字根据表自身的大小来增加)

insert into saas_award_pool_redniu_integration.activity
(Id,ActivityName,CreationTime,CreatorUserId,DeleterUserId,DeletionTime,Description,EndDateTime,HostCompany,IsActivated,IsDeleted,IsGeoRequired,IsVaild,LastModificationTime,LastModifierUserId,PublicAccountId,RuleDescription
,ServicePhoneNumber,StartDateTime,TenantId,Url)
select
Id+100,ActivityName,CreationTime,CreatorUserId,DeleterUserId,DeletionTime,Description,EndDateTime,HostCompany,IsActivated,IsDeleted,IsGeoRequired,IsVaild,LastModificationTime,LastModifierUserId,PublicAccountId,RuleDescription
,ServicePhoneNumber,StartDateTime,TenantId,Url
from saas_award_pool_redniu.activity

 

posted on 2019-09-19 17:33  Leegj  阅读(7775)  评论(0编辑  收藏  举报