如何解决将关系数据从 MSSQL (Azure SQL Server) 移动到 MySQL 数据库
将大型数据集从 MSSQL (Azure SQL Server) 复制到自托管 MySQL 数据库的正确方法是什么?为了增加一些复杂性,需要每天晚上更新网络应用使用的价格、产品等。
目前我们有一个 Node.js 脚本,它可以逐表查询所有内容,并在 MySQL 数据库中创建具有相同数据、外键和主键的行。这适用于较小的表。主要问题是客户和价格表,以及它们之间的多对多关系。目前,MSSQL 中的 CustomersPrices 表具有定义的关系,并且有超过 4400 万行。客户表本身只有 3000 行,而价格只有 50 万行。
下面是来自 MSSQL 的客户、价格和客户价格的架构:
model CustomersPrices {
PriceID Int?
CustomerID Int?
Private_Label String?
Customers Customers? @relation(fields: [CustomerID],references: [ID])
Prices Prices? @relation(fields: [PriceID],references: [ID])
}
model Customers {
ID Int @id @default(autoincrement())
No_ String?
Name String?
Customer_Price_Group String?
Customer_Disc__Group String?
Customer_PL_Price_Group String?
Customer_PL_Disc__Group String?
PL_Text String?
Closed_Status String?
Credit_Limit__LCY_ Decimal?
Current_Balance__LCY_ Decimal?
Remaining_Limit__LCY_ Decimal?
Salesperson_Code String?
Responsibility_Center String?
Address String?
Address_2 String?
Post_Code String?
City String?
Shipment_Method_Code String?
Bill_to_Customer_No_ String?
Show_Limit_Info Int?
Primary_Contact_No_ String?
InsertedDatetime DateTime
SalesPersonID Int?
Salesperson Salesperson? @relation(fields: [SalesPersonID],references: [ID])
Contact Contact[]
CustomersPrices CustomersPrices[]
Sales_Header Sales_Header[]
}
model Prices {
ID Int @id @default(autoincrement())
Item_No_ String?
Variant_Code String?
Sales_Type String?
Sales_Code String?
Unit_of_Measure_Code String?
Sales_Minimum_Quantity Decimal?
Unit_Price Decimal?
Discount_Minimum_Quantity Decimal?
Discount_Pct Decimal?
Starting_Date DateTime?
Ending_Date DateTime?
InsertedDatetime DateTime
ProductID Int?
Products Products? @relation(fields: [ProductID],references: [ID])
CustomersPrices CustomersPrices[]
}
按照我们的指示,我们无法直接将 MSSQL 用于 Web 应用程序。
目前我们正在尝试将 Node.js 与 Prisma.io(用于 MySQL)和 Tedious(用于查询 MSSQL)一起使用。
此刻感觉真的被困住了。你会如何建造这个?提前致谢。
解决方法
您不想务实地这样做。有一些工具可以解决数据迁移问题。查看如何使用 MySQL Workbench 来完成此操作:https://www.mysql.com/products/workbench/migrate/
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。