Categories:
.NET (357)
C (330)
C++ (183)
CSS (84)
DBA (2)
General (7)
HTML (4)
Java (574)
JavaScript (106)
JSP (66)
Oracle (114)
Perl (46)
Perl (1)
PHP (1)
PL/SQL (1)
RSS (51)
Software QA (13)
SQL Server (1)
Windows (1)
XHTML (173)
Other Resources:
How To Add a New Column to an Existing Table with a Default Value
How To Add a New Column to an Existing Table with a Default Value? - Oracle DBA FAQ - Managing Oracle Database Tables
✍: FYIcenter.com
If you want to add a new column to an existing table, and insert a default value in this column on all existing data rows, you can use the ALTER TABLE ... ADD statement with the DEFAULT clause. Here is an example script:
SQL> CREATE TABLE emp_dept_90 2 AS SELECT * FROM employees WHERE department_id=90; Table created. SQL> ALTER TABLE emp_dept_90 2 ADD (vacation NUMBER DEFAULT 10); Table altered. SQL> SELECT first_name, last_name, vacation 2 FROM emp_dept_90; FIRST_NAME LAST_NAME VACATION -------------------- ------------------------- ---------- Steven King 10 Neena Kochhar 10 Lex De Haan 10
As you can see, the "DEFAULT 10" clause did inserted 10 to all existing data rows.
2007-05-03, 4698👍, 0💬
Popular Posts:
How do we host a WCF service in IIS? Note: - The best to know how to host a WCF in IIS is by doing a...
How do I force the Dispose method to be called automatically, as clients can forget to call Dispose ...
Is XHTML Element Name Case Sensitive? - XHTML Tutorials - Introduction To Tag and Attribute Syntax Y...
What Is Posting? Posting is an event that writes Inserts, Updates and Deletes in the forms to the da...
How can I implement a variable field width with printf? That is, instead of something like %8d, I wa...