937670 wrote:Never ever use max(id) +1 combined with an insert statement. This is always wrong. You mentioned that the id is already autogenerated. i guess by some database trigger. In this case simply do not insert anything into the ID column.
I apologize for not mentioning my requirement clearly. My table is having more than 100 columns. Every time user will pass a new value and an auto generated id will be inserted in the table. Rest of the columns will have default values.
My concern is while writing the insert statement I want to enter only the id which will be max(id)+1
and new user name. Also I am trying to avoid writing rest of the columns.So you are lazy. This is ok. I think lazyness is a good attribute for most programmers. (for example: don't repeat yourself design pattern)
You still need to remove a few columns from the list, like ID and name column. but otherwise there is not much to do. The select needs like 5 minutes to write, which is faster than typing 20 column names manually. And you won't make any copy&paste errors.
select column_name||',' from user_tab_columns where table_name = 'YOURTABLE';