Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

adding a column with a default value

Options
  • 11-07-2007 3:22pm
    #1
    Registered Users Posts: 1,552 ✭✭✭


    I need to add a column with a default value in sql plus so that when a row is added to the table this column will have this particular value.

    would it be something like this?

    alter table thetable add (new_column_name varchar2(100) default 'defaultvalue');


Comments

  • Registered Users Posts: 68,317 ✭✭✭✭seamus


    Indeed. Google says:

    ALTER TABLE table_name
    ADD(fieldname data_declaration constraint_definitions);

    If it operates like most other SQL implementations, the inclusion of a default value means that all historical data will also contain the default value for that column.


  • Registered Users Posts: 15,443 ✭✭✭✭bonkey


    Alternately, add the column, run an update, commit the change.


Advertisement