kishram
kishram

Reputation: 103

insert single value across multiple columns in sql

I have a table with almost 27 columns(all of integer datatype) with first column being ID(PK). I wish to update all the values to some value say 500. is there any query to update without typing all the 27 column names like this.

UPDATE tbl_name SET a=500,b=500,c=500.....z=500 where ID = 1

Or else can i make any PL/SQL function which will fetch next next column by itself without providing the column name and set the value ?

Upvotes: 0

Views: 1671

Answers (2)

Arockia Nirmal
Arockia Nirmal

Reputation: 777

It is not possible in any db's. You need to mention the column names. Check the update specifications for most common db's mentioned in the below thread

How to UPDATE all columns of a record without having to list every column

Upvotes: 2

Whencesoever
Whencesoever

Reputation: 2296

You cannot do this. You always have to specify the column names while updating. If it is a proccess You will be reapeating You can write stored procedure doing it.

Upvotes: 1

Related Questions