Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Oracle: insert without columns specification

I have an oracle table with a sequence and a trigger to autoincrement a column. Now I want to make an insert. Normally I should write:

INSERT INTO table (column1, column2,...) VALUES (value1, value2)

but I just want to insert a record with no default values. How to do this in Oracle?

`Mysql`: INSERT INTO table () VALUES ()

`Mssql`: INSERT INTO table default VALUES 

`Oracle:` INSERT INTO table (column1, column2,...) VALUES (default, default,...)

Is this the only way? I have to list all columns?

like image 264
Neo Avatar asked Jul 15 '11 09:07

Neo


People also ask

How can insert data without specifying column in SQL?

There are two ways of using INSERT INTO statement for inserting rows: Only values: First method is to specify only the value of data to be inserted without the column names. INSERT INTO table_name VALUES (value1, value2, value3,…); table_name: name of the table.

How do you insert a record without a column list?

INSERT statements can also be executed without the specification of column names. To execute an INSERT statement without typing the column names, specify the values in the same order that the columns appear in the table. Look at Example-F, which inserts an additional record into the Toys table.

When inserting data in a table do you always have to specify a list of all column names you are inserting values for?

As long as you have the right number of columns in your INSERT statement, and as long as all the values except KEYBOARD are some numeric data type, and as long as you have suitable permissions, this should work. INSERT INTO INVOICE VALUES( 1,1,'KEYBOARD',1,15,5,75);


1 Answers

INSERT INTO table (column1) VALUES (default);

The rest will be defaulted!

like image 107
Tony Andrews Avatar answered Jan 04 '23 06:01

Tony Andrews