Liquibase 如何映射 Oracle 的布尔类型?

16 浏览
0 Comments

Liquibase 如何映射 Oracle 的布尔类型?

已知事实:Oracle不原生支持布尔类型。

因此,建议使用Char(1)或Number(1)并创建约束来限制值为Y/N或0/1。

话虽如此。

在为Oracle数据库创建布尔类型时,Liquibase会创建一个Number(1)。

有人知道它是否也会创建数据库约束吗?

即:\"check(bool in (0,1))\"

参考网址:http://dba-presents.com/index.php/liquibase/29-liquibase-3-3-x-data-types-mapping-table

admin 更改状态以发布 2023年5月21日
0
0 Comments

创建日志:



   
      
        
      
   

运行脚本

liquibase --changeLogFile=bool_test.xml update

显示表定义

c:>sqlplus arthur/password
SQL*Plus: Release 12.1.0.1.0 Production on Tue Dec 20 18:19:21 2016
Copyright (c) 1982, 2013, Oracle.  All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
SQL> select dbms_metadata.get_ddl('TABLE', 'BOOL_TEST') from dual;
DBMS_METADATA.GET_DDL('TABLE','BOOL_TEST')
--------------------------------------------------------------------------------
  CREATE TABLE "ARTHUR"."BOOL_TEST"
   (    "SOME_FLAG" NUMBER(1,0)
   ) SEGMENT CREATION DEFERRED
  PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
 NOCOMPRESS LOGGING
  TABLESPACE "USERS"

0