对不起,这个问题看起来很愚蠢,但我尝试了1个小时搜索,没有找到任何东西。 因此,当我说:
时,我使用liquibase处理多个数据库(例如MSSQL,Oracle和MySQL) addColumn(tableName:ABC_TEST){ column(name:IS_ACTIVE,type:boolean)}如何知道类型boolean是否会转换为适合每个数据库的类型? 是否有任何文档可以找到数据类型映射?如果我想添加一个外键列,那么我应该使用哪种类型的? 解决方案
结帐此问题(和答案)以查看liquibase提供的可用类型。
在我对此问题的回答中,有一个指向相关的liquibase类来完成对数据库特定类型的转换。
当您创建主键为liquibase type的表时,liquibase会将其转换为数据库特定类型。 然后你的外键应该只使用相同的类型,liquibase会翻译它。
例如,查看课程 BigIntType 。 使用liquibase,您只需使用liquibase类型: BIGINT 。 在Oracle DB上,它将转换为(NUMBER,38,0)。 在MSSQL上它会翻译成(BIGINT)。
Sorry, this question seems stupid, but I tried 1 hour searching and didn't find anything. So I'm using liquibase for multiple databases(e.g. MSSQL, Oracle and MySQL), when I say:
addColumn(tableName: "ABC_TEST") { column(name: "IS_ACTIVE", type: "boolean") }How do I know if the type "boolean" will be converted to proper types for each database? And is there any documentation I can find for the data type mapping? If I want to add one more column which is foreign key, which type should I use?
解决方案Checkout this question (and answers) to see the available types that liquibase offers.
In my answer to that question there is a link to the relevant liquibase classes that do the translation to the db specific types.
When you created the table that has the primary key with a "liquibase type" then liquibase will have translated this to the db specific type. Then your foreign key should just use the same type and liquibase will translate this likewise.
E.g. check out the class BigIntType. With liquibase you would just use the "liquibase type": BIGINT. On Oracle DBs it will translate to ("NUMBER", 38,0). On MSSQL it will translate to ("BIGINT").
更多推荐
Liquibase数据类型映射文档
发布评论