换数据库
1.建立数据库和相关表
drop database if exists imm_frontend;
如果imm_frontend 存在删除,不存在忽略
create database imm_frontend default charset=utf8;
创建数据库 imm_frontend 默认编码utf8 可以保存 utf8一个汉字占3个字节
drop table if exists `imm_frontend`.` friendstore `;
如果imm_frontend库的friendstore表存在删除,不存在忽略
CREATE TABLE `imm_frontend`.`friendstore` (
`id` int(11) NOT NULL auto_increment,
`storeId` int(11) NOT NULL default '0',
`friendStoreId` int(11) NOT NULL default '0',
`orderKey` int(11) NOT NULL default '0',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
在imm_frontend库中创建表friendstore,innodb引擎是使用外键,事务等功能
2.转移数据
######### friendstore ##########
增加friendstore表字段
## add a temporay column to identify which table the record immigrate from, 1 from brokerfriend, 2 from companybroker ##
alter table imm_frontend.friendstore add column friendType int(11);
把brokerfriend中brokerId ,friendBrokerId ,orderKey数据导入到friendstore中
## immigrate friendstore from brokerfriend ##
insert ignore into imm_frontend.friendstore (storeId, friendStoreId, orderKey, friendType) select f.brokerId, f.friendBrokerId, f.orderKey, 1 from frontend.brokerfriend f;
把companybroker中companyId, friendBrokerId, orderKey数据导入到friendstore中
## immigrate friendstore from companybroker ##
insert ignore into imm_frontend.friendstore (storeId, friendStoreId, orderKey,friendType) select f.companyId, f.friendBrokerId, orderKey, 2 from frontend.companybroker f;
更新storeId
## update storeId in friendstore, before this the storeId is actually the brokerId ##
update imm_frontend.friendstore friendstore, imm_frontend.store store, frontend.brokerperson p set friendstore.storeId=store.id where friendstore.storeId=p.id and p.userId=store.userId and friendstore.friendType=1;
## update storeId in friendstore, before this the storeId is actually the companyId ##
update imm_frontend.friendstore friendstore, imm_frontend.store store, frontend.brokercompany c set friendstore.storeId=store.id where friendstore.storeId=c.id and c.userId=store.userId and friendstore.friendType=2;
## update friendStoreId, before this the friendStoreId is actually the brokerId ##
update imm_frontend.friendstore friendstore, imm_frontend.store store, frontend.brokerperson p set friendstore.friendStoreId=store.id where friendstore.friendStoreId=p.id and p.userId=store.userId;
## drop temporay column friendType ##
alter table imm_frontend.friendstore drop column friendType;
######### friendstore end ##########
保存文件.sql 执行
分享到:
相关推荐
- 将MySQL数据库的数据转移到Oracle数据库。 - 当前MySQL数据库的备份文件为`.sql`文件,每个表一个文件,需要将这些文件的数据导入到Oracle数据库中。 #### 二、MySQL数据恢复 为了确保数据的完整性和准确性,...
### 如何备份MySQL数据库并转移到其他地方 #### 知识点概述 在IT行业中,数据库迁移是一项常见的操作,尤其对于MySQL这种广泛使用的数据库系统来说更是如此。本文将详细介绍如何通过命令行工具备份MySQL数据库,并...
### 如何将MySQL数据库转移到微软SQL Server 2005 #### 引言 随着企业对数据管理和存储需求的增长,数据库迁移成为了一项常见的任务。本文档提供了详细的指南,介绍了如何将MySQL数据库迁移到微软SQL Server 2005的...
提到的博客文章“将MySQL数据库转移到SqlServer2008数据库”可能提供了具体的步骤和工具。常见的迁移工具包括: - **SQL Server Migration Assistant (SSMA)**:微软官方的工具,支持多种数据库向SQL Server的迁移...
1. 运行waterMain,该程序连接onenet云平台,获取4条河流的最新数据信息,处理数据后,连接MySQL数据库,只把最新的数据信息存入数据库中 2. 可部署到自己服务器中与毕设代码1结合使用 爱吃凉拌辣芒果 2022年6月...
2. **数据导出**:使用MySQL的`mysqldump`命令,将MySQL数据库的数据和结构导出为SQL脚本。例如: ``` mysqldump -u [username] -p[password] [database_name] > dump.sql ``` 这会创建一个包含CREATE TABLE语句...
总之,MySQL-Front为MySQL数据库的管理和操作提供了便捷的方式,其导出功能使得数据库结构可以方便地以PDF和HTML形式共享,这对数据文档化和跨平台沟通具有重要意义。熟练掌握这些操作,将有助于提高数据库管理的...
1.使用人员可以指定迁移数据库类型 如:(orcal,sqlServer,csv 迁移至mysql) 2.在迁移数据库时,可以只迁移指定字段. 3.开发多任务的平台,按权重去执行任务,如:权重为1,1,2,3,4 那么1,1的权重一起执行,执行完毕后2...
本资源摘要信息涵盖了腾讯云 MySQL 云数据库产品认证的所有知识点,涵盖了云数据库 MySQL 产品认证、DTS 数据迁移、SQL 优化、公有云 MySQL 初始化、高可用性和容灾等方面的知识点。 云数据库 MySQL 产品认证是指...
【Java代码 MySql导出到SqlLite】是一种技术实践,它涉及到使用Java编程语言来实现一个功能,该功能能够将MySQL数据库中的数据高效地导出到SQLite数据库文件中。这一过程通常用于数据迁移、备份或者在不同环境之间...
这个系统特别适用于那些需要跨平台管理数据或者需要在Sql Server和Mysql数据库之间保持数据一致性的企业。以下是对这个系统的关键知识点的详细解释: 1. **数据同步**:数据同步是该系统的主打功能,它可以实现在...
mysql4数据库转移到mysql5,首先将文件的编码转换为utf-8 如果使用editplus,打开文件,
该命令将数据库转移到新服务器。 Oracle 数据备份和还原 Oracle 数据备份和还原也可以使用 exp 和 imp 命令来实现。exp 命令用于导出数据,而 imp 命令用于导入数据。 exp userid=system/manager owner=username1...
5. **数据迁移**:在确认无误后,工具会执行实际的数据迁移,将MSsql数据库中的数据导入到MySQL数据库。 6. **测试与验证**:迁移完成后,用户需要对目标MySQL数据库进行测试,确保所有功能都能正常运行,数据的...
1. **数据迁移**:它能够将SQL Server数据库中的表结构、数据、索引、视图、存储过程等完整地迁移到MySQL数据库中。这一步骤确保了目标数据库与源数据库的一致性。 2. **兼容性检查**:在迁移前,工具可能会对源...
8. **数据传输**:可以将数据从一个数据库转移到另一个数据库,或者在多个数据库之间进行数据同步,适用于多环境下的数据迁移。 9. **数据同步**:提供实时数据同步,使多用户共享的数据库保持最新状态。 10. **...
这款工具提供了高效且可靠的解决方案,帮助IT专业人员在不同数据库平台之间无缝地转移数据和结构。 在数据库移植过程中,MySQL Migration Toolkit提供了以下几个关键知识点: 1. **数据迁移**:该工具支持将数据从...
"mysql数据库转换成SQLserver数据库"这个主题主要涵盖以下几个关键知识点: 1. **数据迁移**:数据迁移是从一个数据库系统到另一个数据库系统的数据传输过程。在这个过程中,我们需要确保所有数据完整无损地从MySQL...
MySQL数据库架构主要包括以下几个核心组件: 1. **客户端/服务器架构**: - **客户端**:通过多种编程语言接口连接MySQL服务器。 - **服务器**:处理客户端请求、执行查询、返回结果并管理数据存储。 2. **SQL层...