Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
306 views
in Technique[技术] by (71.8m points)

database - Inserting additional same no of rows but with negative value in oracle

[Actually I have a million records but I have taken an example in picture.

Initial table contains 3 records but the result I need is same 3 rows + same number of rows (same data) but with negative values....So resulted table has 6 records in pic

The question is initially I have million of records with positive values

But the resulted table I need is both previous data and insert same copy of data with negative values… If I have 100 records...The resulted table contains 200 records (100 positive and 100 negative records)

]1

question from:https://stackoverflow.com/questions/65882401/inserting-additional-same-no-of-rows-but-with-negative-value-in-oracle

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

use INSERT INTO .. SELECT as follows:

insert into your_Table
select a, -B, -c from your_table

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...