Subject | Is it possible to perform such insert? |
---|---|
Author | un_spoken |
Post date | 2012-11-18T13:22:15Z |
Hi guys.
Here it is: a standard insert:
INSERT INTO MYTABLE SELECT * FROM MYTABLE WHERE RECORD_ID = 50;
This query will make me a copy of a row in a table and I do not need to explicitly give the names of all columns, very convenient.
However, I would like to do something like this:
I want to copy all fields but two of them I want to have an explict value - I do not want to copy them from the table.
Standard method of inserting such values would be:
INSERT INTO MYTABLE SELECT EXPLICT_VAL1, EXPLICT_VAL2, T.COULMN3, T.COLUMN4 FROM MYTABLE T WHERE T.RECORD_ID = 50;
However the problem is, that my table has a lot of columns and it will change in the future (new columns will come). When new column appear in a table, I would have to modify this query by adding that column to the SELECT list.
Can not I do something like this:
INSERT INTO MYTABLE SELECT EXPLICT_VAL1, EXPLICT_VAL2, T.*(ALL BUT FIRST TWO COLUMNS) FROM MYTABLE T WHERE T.RECORD_ID = 50;
Thank you for your time.
Here it is: a standard insert:
INSERT INTO MYTABLE SELECT * FROM MYTABLE WHERE RECORD_ID = 50;
This query will make me a copy of a row in a table and I do not need to explicitly give the names of all columns, very convenient.
However, I would like to do something like this:
I want to copy all fields but two of them I want to have an explict value - I do not want to copy them from the table.
Standard method of inserting such values would be:
INSERT INTO MYTABLE SELECT EXPLICT_VAL1, EXPLICT_VAL2, T.COULMN3, T.COLUMN4 FROM MYTABLE T WHERE T.RECORD_ID = 50;
However the problem is, that my table has a lot of columns and it will change in the future (new columns will come). When new column appear in a table, I would have to modify this query by adding that column to the SELECT list.
Can not I do something like this:
INSERT INTO MYTABLE SELECT EXPLICT_VAL1, EXPLICT_VAL2, T.*(ALL BUT FIRST TWO COLUMNS) FROM MYTABLE T WHERE T.RECORD_ID = 50;
Thank you for your time.