Monday, 15 February 2010

oracle - Not update existing records with default value of new column -


I have a table with some records

I have a TIMESTAMP < / Code> I want to add the type of column ( LAST_MODIFIED ) I want to set the code to SYSDATE for the default value.

But I want to make sure that when this column is added, the current record does not get this column value to SYSDATE . How to get it?

You should do this as two separate actions: add a column and set the default value .

  SQL & gt; Create table some_data (id integer); Table sql and gt; Add some data to the level that & lt; = 5; SQL and GT in 5 rows; Change the table; Add some data; Table change sql & gt; Modify the table some_data date_modified default sysdate; Table change sql & gt; Some of the data values ​​(6); 1 line sql and gt; Select * some data *; ID DATE_MODIFIED --------------------------------------- --------- ---- 1 2 3 4 5 6 17.03.2015 Selected 6 rows  

No comments:

Post a Comment