Leo
Leo

Reputation: 1919

How to insert multiple default values in a table

Imagine you have a table which all of its columns were created with the DEFAULT clause included, for example

BOX
----------
height
width
depth

currently I'd make the following query to use default values:

INSERT INTO BOX VALUES(DEFAULT,DEFAULT,DEFAULT);

is there any other way to do this in Oracle? Preferably to indicate insert clause to use all default values but without specifying it for every column.

Upvotes: 2

Views: 948

Answers (1)

peterm
peterm

Reputation: 92785

You can specify DEFAULT for one column and omit other columns.

INSERT INTO box (height) VALUES (DEFAULT);

As a result you'll get all columns with default values.

Here is SQLFiddle demo

Upvotes: 4

Related Questions