如何在 Oracle Table 创建期间定义列时添加命名检查约束?

How to add Named Check Constraint while defining the Column during Table creation in Oracle?

我有以下 CREATE table 查询:

-- Create table
CREATE TABLE USER2 (
--  Column definitions
    OID NUMBER(19,0) NOT NULL,
    CREATION_TIME TIMESTAMP (6) NOT NULL,
    LAST_MOD_TIME TIMESTAMP (6) NOT NULL,
    NAME VARCHAR2(500 CHAR) NOT NULL,

--  Other columns

--  Primary key constraint
    CONSTRAINT USER_PK
        PRIMARY KEY (OID),

--  Foreign key constraints

--  List of foreign key constraints

--  Unique key constraints

--  List of unique key constraints

--  Check constraints
    CONSTRAINT USER_OID_NOTNULL_CK
        CHECK (OID IS NOT NULL),
    CONSTRAINT USER_CTM_NOTNULL_CK
        CHECK (CREATION_TIME IS NOT NULL),
    CONSTRAINT USER_LMT_NOTNULL_CK
        CHECK (LAST_MOD_TIME IS NOT NULL),
    CONSTRAINT USER_NME_NOTNULL_CK,

--  List of check constraints
);

当它在 Oracle 11g 中执行时,它会创建重复的检查约束;一组包含我明确指定的检查约束,另一组包含自动生成的检查约束,这些约束由数据库本身生成,正如我在列定义中指定的 NOT NULL

当我没有在列定义中指定 NOT NULL 时,来自 SQL 开发人员,在 table 定义视图中,列显示为 Nullable Yes

我希望列显示为 Nullable No 并且 Check Constraints 也将被命名。我怎样才能做到这一点?

无需双重 NOT NULL 规范,只需在定义列时命名 NOT NULL 约束,例如:

...
CREATION_TIME TIMESTAMP (6) constraint SCOPING2_CTM_NOTNULL_CK NOT NULL,
...