在同一个表中从一列向另一列插入值-SQL
我想从同一个SQL表中的现有列向新列插入值。现有列值和新列值应相同。 有什么建议吗 这将有助于您:在同一个表中从一列向另一列插入值-SQL,sql,oracle,Sql,Oracle,我想从同一个SQL表中的现有列向新列插入值。现有列值和新列值应相同。 有什么建议吗 这将有助于您: 更新表集合param1=newValue,其中param2=criteria更新它,正如您已经听说的那样。一点代码: 示例表和多行示例数据: SQL> create table test 2 (existing_column number, 3 new_column number); Table created. SQL> insert into t
更新表集合param1=newValue,其中param2=criteria更新它,正如您已经听说的那样。一点代码: 示例表和多行示例数据:
SQL> create table test
2 (existing_column number,
3 new_column number);
Table created.
SQL> insert into test (existing_column)
2 select level from dual connect by level <= 5;
5 rows created.
SQL> select * From test;
EXISTING_COLUMN NEW_COLUMN
--------------- ----------
1
2
3
4
5
提示:更新。这很有帮助。谢谢
SQL> update test set
2 new_column = existing_column
3 where existing_column <= 3;
3 rows updated.
SQL> select * From test;
EXISTING_COLUMN NEW_COLUMN
--------------- ----------
1 1
2 2
3 3
4
5
SQL>