Basic Oracle Concepts and Programming Question:
How To Specify Default Values in INSERT Statement using Oracle?
Answer:
If a column is defined with a default value in a table, you can use the key word DEFAULT in the INSERT statement to take the default value for that column. The following tutorial exercise gives a good example:
INSERT INTO ggl_links VALUES (102,
'http://www.globalguideline.com',
NULL,
0,
DEFAULT);
1 row created.
SELECT * FROM ggl_links;
<pre> ID URL NOTES COUNTS CREATED
----- ------------------------ -------- ------- ---------
101 http://www.globalguideline.com NULL 0 30-Jul-08
102 http://www.globalguideline.com NULL 0 07-MAY-06</pre>
INSERT INTO ggl_links VALUES (102,
'http://www.globalguideline.com',
NULL,
0,
DEFAULT);
1 row created.
SELECT * FROM ggl_links;
<pre> ID URL NOTES COUNTS CREATED
----- ------------------------ -------- ------- ---------
101 http://www.globalguideline.com NULL 0 30-Jul-08
102 http://www.globalguideline.com NULL 0 07-MAY-06</pre>
Previous Question | Next Question |
How To Insert a New Row into a Table in Oracle? | How To Omit Columns with Default Values in INSERT Statement in Oracle? |