-1

I have 1 record in table1(col1,col2,etc), i want insert same record by passing only one new value to col2. and table2(c1,c2,etc) have 2 records c2 is refering table1(col1) value, here also i want to do same cloning by passing col1 value to c2.how its possible?

1 Answers1

0

I think insert . . . select is what you want:

insert into table1 (col1, col2, . . . )
    select col1, <new value>, . . . 
    from table1;
Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786
  • Try to use ```WITH``` to separate the content that you want to insert. https://stackoverflow.com/questions/12552288/sql-with-clause-example but it will use more memory than necessary. – giubueno Jun 11 '19 at 14:57
  • @giubueno "It will use more memory than necessary" Why would it? CTEs are not always materialized - they are inlined by default. Yes, the optimizer has tendency to aggresively force materialization in cases where you are reusing CTEs in the query, or there are very complex joins, but a) It's probably not a case here b) It can be fixed with 'inline' optimizer hint. – piezol Jun 12 '19 at 07:55