mysql - Azure 表存储 MySQL 列中导入的表名称

标签 mysql azure azure-table-storage

我想知道是否可以保留导入到 Azure 表存储中的表的名称?是否可以将相同列结构的多个数据库导入到Azure表存储中?

在购买 Azure 表存储之前我会问这个问题,我只是想确保它能够满足我需要做的任何事情。

更新: 所以我有一个大约有 500 个表的数据库,它们都有相对相同的列用户名、电子邮件、哈希、盐、名称、IP 等...有些表​​只有用户名和电子邮件,而其他表则或多或少。然而,最终所有表的列拼写都完全相同。我想创建一个包含所有列的 Azure 表存储。然后导入所有表。 SO 缺少列的表在它们没有的列中只会有 null 。但我想将表名导入到列中。因此,如果导入 table1,则一列将被命名为“数据库名称”,并且 table1 的名称将在其中,依此类推。

更新2: 那么是否可以做这样的事情。如图所示here

 CustomerEntity customer1 = new CustomerEntity("Harp", "Walter");
 customer1.Email = "Walter@contoso.com";
 customer1.PhoneNumber = "425-555-0101";

我想要

WebsiteEntity website1 = new WebsiteEntity("Google");
website1.Username = "username1"
website1.email = "email@gmail.com"

我想我的意思是可以将我导入的表名放入上面显示的 WebsiteEntity 中吗?如果它位于正在导入的 SQL 表中,那么会自动创建类似 .username 和 .email 的文件吗?就像专栏一样。因此表 1 包含用户名和电子邮件列,并命名为 Google,因此导入网站实体时将是 Google,并且将自动创建 website1.username 和 website1.email。

提前谢谢您,我对此很陌生。

更新3: 经过进一步研究,我的问题是我可以将 MySQL 数据库中的每个表导入到自己的分区中吗?

最佳答案

每个azure表实体都有分区键和行键,实体的分区和行键唯一标识表中的实体。我们可以使用MySQL表名作为分区键,使用MySQL主键作为行键。这样我们就可以使用分区键来知道我们的实体来自哪里。

比如,如果MySQL中有一个名为User的表,则创建一个实体

public class UserEntity : TableEntity
{
    public UserEntity(string tablename, string primarykey)
    {
        this.PartitionKey = "User";
        this.RowKey = primarykey;
    }

    public UserEntity() { }

    public string UserName { get; set; }

    public string Email { get; set; }
}

并为 MySQL person 表创建 Person。

public class PersonEntity : TableEntity
{
    public UserEntity(string tablename, string primarykey)
    {
        this.PartitionKey = "Person";
        this.RowKey = primarykey;
    }

    public PersonEntity() { }

    public string UserName { get; set; }

    public string Email { get; set; }

    public string Password { get; set; }

}

然后我们从MySQL读取数据。并使用 MySQL 中的值创建实体,插入到 Azure 表中。引用this article了解如何开始使用 Azure 表。

这是 Azure 存储资源管理器的结果。我们可以从“Person”MySQL 表中知道第一个实体,从“User”MySQL 表中知道第二个实体。这是一个简单的成就。如果您有特殊要求,请创建新的Azure表结构。

enter image description here

关于mysql - Azure 表存储 MySQL 列中导入的表名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39060059/

相关文章:

Azure表存储: Order by

mysql - 在以下查询中包含周数中的日期

java - 为 RESTful web 服务设置 MySQL 和 Apache

python-3.x - Azure Python 函数中导入模块错误 (Linux)

python - Raspbian下使用Python访问Azure存储上的表服务

azure - 如何将我的 Azure 表存储数据移动到高级存储帐户?

php - 存储经常添加/删除的列

php - 使用 php 从具有多个条目的数据库中获取名称列表

node.js - 我们如何使用访问 token 来授权我们的rest api?

.net - Windows AppFabric 到底是什么?