mysql纵向分别用视图合并数据

mysql纵向分别用视图合并数据,第1张

SELECT fields INTO OUTFILE 'file_name'

[{FIELDS | COLUMNS} 字段

[TERMINATED BY 'string'] 字段之间分隔符号

[[OPTIONALLY] ENCLOSED BY 'char'] 字段被包含在char中间

[ESCAPED BY 'char'] 忽略字段里出现的char

]

[LINES

[STARTING BY 'string'] 忽略开头是string的行

[TERMINATED BY 'string'] 行分隔符

]

FROM test_table

LOAD DATA [LOW_PRIORITY | CONCURRENT] [LOCAL] INFILE 'file_name'

[REPLACE | IGNORE] 遇到重复的时候处理方法,替换或者是忽略

INTO TABLE tbl_name 导入数据的目的表名

[PARTITION (partition_name,...)] 分区选择

[CHARACTER SET charset_name] 字符集

[{FIELDS | COLUMNS} 字段

[TERMINATED BY 'string'] 字段之间分隔符号

[[OPTIONALLY] ENCLOSED BY 'char'] 字段被包含在char中间

[ESCAPED BY 'char'] 忽略字段里出现的char

]

[LINES

[STARTING BY 'string'] 忽略开头是string的行

[TERMINATED BY 'string'] 行分隔符

]

[IGNORE number {LINES | ROWS}] 忽略行/列

[(col_name_or_user_var,...)] 目的表的表字段名或者用户变量名

[SET col_name = expr,...] 设置表字段值

1、忽略表之间的关联关系

ALTER TABLE db2.dbo.table NOCHECK CONSTRAINT 关系名

2、--将没有重复的数据合并

insert into db2.dbo.table(field1,field2...) select field1,field2... from db1.dbo.table a where a.username not in (select username from db2.dbo.table)

3、将重复的数据写入临时表

select field1,field2... into 新的临时表 from db1.dbo.table a where a.username in (select username from db2.dbo.table)


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/6158241.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-03-16
下一篇 2023-03-16

发表评论

登录后才能评论

评论列表(0条)

保存