1

DB2 v10.1 database on WINDOWS 7

I have three tables:

1.table Rase

     id  Rases   Length
     1   Moscow  300
     2   Krasno   400

2.table Plan

    id  Name    Date
    1   ТУ124   10.12.1987
    2   Ан24    10.01.1998

3.table Kril

     ID      COLOR            WEIGH    
      1      green            124,56
      2      blue             187,40
      3      black            231,00

Need to display data in a normalized table ALL_D, as presented below: ID - Primary Key Plan - a reference to Plan.Name Kril - a reference to Kril.Color Race - a reference to Race.Rases Time_Start-departure time (CURRENT TIMESTAMP)

  1. table ALL_D
     ID   Name  Color     Rases        Time_Start
     1   ТУ124  Green     Moscow    2011-10-25-19.12.30.000000
     2   АН24   Blue      Krasno    2011-10-27-17.14.30.000000

I do not understand how to perform this task.

4

1 に答える 1

0

これは基本的な結合クエリです。

insert into all_d
    select rase.id, plan.name, kril.color, rase.rases, 
           current timestamp as time_start
        from rase
        join plan on plan.id = rase.id
        join kril on kril.id = rase.id

join-- 3 つすべてのテーブルに共通する ID のみがinner join返されます。

更新:結果テーブルへの挿入も追加されました。

于 2012-10-04T11:44:28.777 に答える