h-you / branches / ddl / 20180411_SQL.txt @ 353
履歴 | 表示 | アノテート | ダウンロード (4.13 KB)
| 1 | 342 | h-you | -- ????i?????t?f?[?^ |
|---|---|---|---|
| 2 | DROP TABLE IF EXISTS constructionprogressdate_OLD; |
||
| 3 | |||
| 4 | CREATE TABLE constructionprogressdate_OLD As |
||
| 5 | Select |
||
| 6 | * |
||
| 7 | from |
||
| 8 | constructionprogressdate; |
||
| 9 | |||
| 10 | drop table if exists constructionprogressdate cascade; |
||
| 11 | |||
| 12 | create table constructionprogressdate( |
||
| 13 | ConstructionCode decimal (10, 0) not null comment '?H?????' |
||
| 14 | , ConstructionStatusFlg decimal (2, 0) not null comment '???H?????' |
||
| 15 | , PreviousStatusFlg decimal (2, 0) comment '??X?O???' |
||
| 16 | , ChangeDate datetime not null comment '?????t' |
||
| 17 | , ChangePersonCode decimal (8, 0) not null comment '???S????' |
||
| 18 | , EntryDate datetime not null comment '?o?^???t' |
||
| 19 | , UpdateDate datetime not null comment '?X?V???t' |
||
| 20 | , constraint constructionprogressdate_PKC primary key (ConstructionCode, ChangeDate) |
||
| 21 | ) comment '????i?????t?f?[?^'; |
||
| 22 | |||
| 23 | create index ConstrProg_Index1 |
||
| 24 | on constructionprogressdate(ConstructionCode); |
||
| 25 | |||
| 26 | create index ConstrProg_Index2 |
||
| 27 | on constructionprogressdate(ConstructionStatusFlg); |
||
| 28 | |||
| 29 | create index ConstrProg_Index3 |
||
| 30 | on constructionprogressdate(ChangeDate); |
||
| 31 | |||
| 32 | Insert |
||
| 33 | INTO constructionprogressdate |
||
| 34 | Select |
||
| 35 | * |
||
| 36 | from |
||
| 37 | constructionprogressdate_OLD; |
||
| 38 | |||
| 39 | -- ?H???????o??f?[?^ |
||
| 40 | drop table if exists ConstrLedgerExpenses cascade; |
||
| 41 | |||
| 42 | create table ConstrLedgerExpenses ( |
||
| 43 | ConstructionCode decimal(10,0) unsigned not null comment '?H???R?[?h' |
||
| 44 | , SeqNo decimal(5,0) not null comment '?}??' |
||
| 45 | , NameCode decimal(5,0) unsigned not null comment '?o??R?[?h' |
||
| 46 | , ExpensesRaito decimal(4,2) not null comment '?o??' |
||
| 47 | , ExpensesValue decimal(10,0) not null comment '?o????z' |
||
| 48 | , EntryDate datetime not null comment '?o?^???t' |
||
| 49 | , UpdateDate datetime not null comment '?X?V???t' |
||
| 50 | , constraint ConstrLedgerExpenses_PKC primary key (ConstructionCode, SeqNo, NameCode) |
||
| 51 | ) comment '?H???????o??f?[?^' ; |
||
| 52 | |||
| 53 | create index ConstrLedgerExpenses_Index1 |
||
| 54 | on ConstrLedgerExpenses(ConstructionCode); |
||
| 55 | |||
| 56 | create index ConstrLedgerExpenses_Index2 |
||
| 57 | on ConstrLedgerExpenses(SeqNo); |
||
| 58 | |||
| 59 | create index ConstrLedgerExpenses_Index3 |
||
| 60 | on ConstrLedgerExpenses(NameCode); |
||
| 61 | |||
| 62 | Insert |
||
| 63 | INTO constrledgerexpenses |
||
| 64 | select |
||
| 65 | A.ConstructionCode |
||
| 66 | , 1 |
||
| 67 | , A.ComponentCode |
||
| 68 | , A.AmountConfigRate |
||
| 69 | , A.ExecutionAmount |
||
| 70 | , A.EntryDate |
||
| 71 | , A.UpdateDate |
||
| 72 | from |
||
| 73 | constructionledgerdetail As A |
||
| 74 | where |
||
| 75 | A.GroupCount = 1 |
||
| 76 | And A.ComponentCode = 3; |
||
| 77 | |||
| 78 | Insert |
||
| 79 | INTO constrledgerexpenses |
||
| 80 | select |
||
| 81 | A.ConstructionCode |
||
| 82 | , 2 |
||
| 83 | , A.ComponentCode |
||
| 84 | , A.AmountConfigRate |
||
| 85 | , A.ExecutionAmount |
||
| 86 | , A.EntryDate |
||
| 87 | , A.UpdateDate |
||
| 88 | from |
||
| 89 | constructionledgerdetail As A |
||
| 90 | where |
||
| 91 | A.GroupCount = 1 |
||
| 92 | And A.ComponentCode = 1; |
||
| 93 | |||
| 94 | Insert |
||
| 95 | INTO constrledgerexpenses |
||
| 96 | select |
||
| 97 | A.ConstructionCode |
||
| 98 | , 3 |
||
| 99 | , A.ComponentCode |
||
| 100 | , A.AmountConfigRate |
||
| 101 | , A.ExecutionAmount |
||
| 102 | , A.EntryDate |
||
| 103 | , A.UpdateDate |
||
| 104 | from |
||
| 105 | constructionledgerdetail As A |
||
| 106 | where |
||
| 107 | A.GroupCount = 1 |
||
| 108 | And A.ComponentCode = 2; |
||
| 109 | |||
| 110 | |||
| 111 | -- ?????o???}?X?^ |
||
| 112 | DROP TABLE IF EXISTS departmentexpensesmaster_OLD; |
||
| 113 | |||
| 114 | CREATE TABLE departmentexpensesmaster_OLD As |
||
| 115 | Select |
||
| 116 | * |
||
| 117 | from |
||
| 118 | departmentexpensesmaster; |
||
| 119 | |||
| 120 | drop table if exists departmentexpensesmaster cascade; |
||
| 121 | |||
| 122 | create table departmentexpensesmaster ( |
||
| 123 | DepartmentCode decimal(5,0) unsigned not null comment '?????R?[?h' |
||
| 124 | , ExpensesPeriod smallint(6) not null comment '?????' |
||
| 125 | , NameCode decimal(5,0) unsigned not null comment '?o??R?[?h' |
||
| 126 | , NameString varchar(100) not null comment '????' |
||
| 127 | , DisplayOrder decimal(5,0) unsigned not null comment '?\????' |
||
| 128 | , ExpensesRaito decimal(4,2) not null comment '?o??' |
||
| 129 | , DeleteFlg decimal(1,0) not null comment '???t???O' |
||
| 130 | , EntryDate datetime not null comment '?o?^???t' |
||
| 131 | , UpdateDate datetime not null comment '?X?V???t' |
||
| 132 | , constraint departmentexpensesmaster_PKC primary key (DepartmentCode,ExpensesPeriod,NameCode) |
||
| 133 | ) comment '?????o???}?X?^' ; |
||
| 134 | |||
| 135 | Insert |
||
| 136 | INTO departmentexpensesmaster |
||
| 137 | select |
||
| 138 | A.DepartmentCode |
||
| 139 | , A.ExpensesPeriod |
||
| 140 | , A.NameCode |
||
| 141 | , B.NameString |
||
| 142 | , A.DisplayOrder |
||
| 143 | , A.ExpensesRaito |
||
| 144 | , A.DeleteFlg |
||
| 145 | , A.EntryDate |
||
| 146 | , A.UpdateDate |
||
| 147 | from |
||
| 148 | departmentexpensesmaster_OLD As A |
||
| 149 | LEFT JOIN divisionmaster AS B |
||
| 150 | ON B.DivisionCode = 3 |
||
| 151 | And B.NameCode = A.NameCode; |
||
| 152 | |||
| 153 | commit; |