Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

adding a column with a default value

  • 11-07-2007 03:22PM
    #1
    Registered Users, Registered Users 2 Posts: 1,559 ✭✭✭


    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, Registered Users 2 Posts: 68,173 ✭✭✭✭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, Registered Users 2 Posts: 15,443 ✭✭✭✭bonkey


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


Advertisement