SQL to add column and comment in table in single command

后端 未结 4 1874
無奈伤痛
無奈伤痛 2021-02-11 13:09

I am using Oracle 11g for my web application. I want to add a column and a comment to an existing table. I can do that easily with the below commands

ALTER TABLE         


        
4条回答
  •  醉梦人生
    2021-02-11 13:22

    No, you can't.

    There's no reason why you would need to. This is a one-time operation and so takes only an additional second or two to actually type and execute.

    If you're adding columns in your web application this is more indicative of a flaw in your data-model as you shouldn't need to be doing it.


    In response to your comment that a comment is a column attribute; it may seem so but behind the scenes Oracle stores this as an attribute of an object.

    SQL> desc sys.com$
     Name                                      Null?    Type
     ----------------------------------------- -------- ----------------------------
     OBJ#                                      NOT NULL NUMBER
     COL#                                               NUMBER
     COMMENT$                                           VARCHAR2(4000)
    
    SQL>
    

    The column is optional and sys.col$ does not contain comment information.

    I assume, I have no knowledge, that this was done in order to only have one system of dealing with comments rather than multiple.

提交回复
热议问题