是否有从标识列迁移到Hilo键的实用方法? [英] Is there a practical way of migrating from identity columns to hilo keys?

查看:66
本文介绍了是否有从标识列迁移到Hilo键的实用方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的数据库在很大程度上取决于标识列.但是,由于我们现在已将所有应用程序移至NHibernate,因此我想研究使用HiLo,这似乎是NHibernate推荐的.有什么策略可以做到这一点,或者需要注意一些常见的问题?

I work with a database that depends heavily on identity columns. However as we have now moved all applications over to NHibernate I wanted to look into using HiLo as seems to be recommended with NHibernate. Are there any strategies to do this, or any common problems to watch out for?

推荐答案

如果这是有关将现有应用程序迁移到以前使用过自动ID并包含旧数据需要迁移的hilos的问题,那么...这将是我最好的选择(虽然没有尝试过!-欢迎发表评论!):

If this is a question about migrating an existing application to hilos which previously used auto ids, and has old data in it which needs to be migrated... then this would be my best bet (not tried it though! - comments welcome!) :

  • 将您的列类型ID更改为bigints
  • 找出当前任何表中的最高id值.
  • 在hilo源表中将您的下一个高"值设置为高于在ID中找到的值

如果这当然只能解决Identity列的问题,那么将应用程序迁移到NHibernate时架构中不需要更改的其他任何内容.

If course this only addresses issues with the identity column, not anything else in your schema that might need to change if you are moving an app to NHibernate.

这篇关于是否有从标识列迁移到Hilo键的实用方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆