How can I drop a “not null” constraint in Oracle when I don't know the name of the constraint?

前端 未结 7 1134
花落未央
花落未央 2020-12-07 20:10

I have a database which has a NOT NULL constraint on a field, and I want to remove this constraint. The complicating factor is that this constraint has a system-defined nam

7条回答
  •  离开以前
    2020-12-07 21:01

    To discover any constraints used, use the code below:

    -- Set the long data type for display purposes to 500000.
    
    SET LONG 500000
    
    -- Define a session scope variable.
    
    VARIABLE output CLOB
    
    -- Query the table definition through the DBMS_METADATA package.
    
    SELECT dbms_metadata.get_ddl('TABLE','[Table Described]') INTO :output FROM dual;
    

    This essentially shows a create statement for how the referenced table is made. By knowing how the table is created, you can see all of the table constraints.

    Answer taken from Michael McLaughlin's blog: http://michaelmclaughlin.info/db1/lesson-5-querying-data/lab-5-querying-data/ From his Database Design I class.

提交回复
热议问题