標籤:
很多人使用PD的時候就問有沒有製作自動升級指令碼的功能。其實是有的。
操作原理: 1、儲存原來的版本,另存新檔apm的檔案,產生一個Archive Model。 2、產生升級指令碼,需要選擇原來的版本
操作步驟: 1、開啟PDM檔案,選擇Save as .... 另存新檔,在彈出的視窗中選擇apm的檔案類型,輸入檔案名稱儲存即可。 2、修改相關的資料模型的內容,然後儲存。 3、選擇DataBase菜單中的modify database... 菜單 4、在彈出的視窗中設定升級指令碼的目錄及檔案名稱後,在synchronization頁框中的obtains database schema中選擇using an archive model: 選擇原先儲存的apm檔案。後面的其它頁框設定與產生指令碼的類似。
5、點一下確定,PD就會自動產生資料庫的對比資訊,彈出一個database synchronization視窗,這裡這個視窗裡列出了所有的差異資訊,你可以選擇需要升級的內容。點ok就可以看到升級指令碼了。
產生指令碼分析: 總體來講還是很智能化的一個工具。 比如增加一個列,產生就的指令碼就很簡單。指令碼如下: alter table SY_MsgSend add Column_8 CHAR(10) /
在刪除列的時候就充分體現出智能化的升級指令碼,如下所示,做了一個刪除列的操作會產生一系列的升級指令碼:
/*==============================================================*/
/* Database name: Database */
/* DBMS name: ORACLE Version 9i */
/* Created on: 2007-9-6 11:12:26 */
/*==============================================================*/alter table SY_MsgReceiver drop constraint FK_SY_MSGRE_SY_MSGREC_SY_MSGSE /drop table tmp_SY_MsgSend cascade constraints //*==============================================================*/
/* Table: tmp_SY_MsgSend */
/*==============================================================*/create table tmp_SY_MsgSend (
MS_ID NUMBER(10) not null,
MS_Content VARCHAR2(4000),
MS_SendTime DATE,
MS_Type VARCHAR2(4),
MS_Sender NUMBER(8),
MS_Status NUMBER(1) default 1 not null,
MS_MsgSource NUMBER(2) default 1 not null,
Column_8 CHAR(10) ) / insert into tmp_SY_MsgSend (MS_ID, MS_Content, MS_SendTime, MS_Type, MS_Sender, MS_Status, MS_MsgSource)
select MS_ID, MS_Content, MS_SendTime, MS_Type, MS_Sender, MS_Status, MS_MsgSource from SY_MsgSend /drop table SY_MsgSend cascade constraints //*==============================================================*/
/* Table: SY_MsgSend */
/*==============================================================*/create table SY_MsgSend (
MS_ID NUMBER(10) not null,
MS_Content VARCHAR2(4000),
MS_SendTime DATE,
MS_Type VARCHAR2(4),
MS_Sender NUMBER(8),
MS_Status NUMBER(1) default 1 not null,
MS_MsgSource NUMBER(2) default 1 not null,
constraint PK_SY_MSGSEND primary key (MS_ID) ) tablespace TBS_EOFFICE /insert into SY_MsgSend (MS_ID, MS_Content, MS_SendTime, MS_Type, MS_Sender, MS_Status, MS_MsgSource)
select MS_ID, MS_Content, MS_SendTime, MS_Type, MS_Sender, MS_Status, MS_MsgSource from tmp_SY_MsgSend //*==============================================================*/
/* Index: Index_47 */
/*==============================================================*/
create index Index_47 on SY_MsgSend ( MS_Sender ASC ) tablespace TBS_IDX_Eoffice /alter table SY_MsgReceiver add constraint FK_SY_MSGRE_SY_MSGREC_SY_MSGSE foreign key (MS_ID)
references SY_MsgSend (MS_ID) on delete cascade /
【轉】用PowerDesigner製作資料庫升級指令碼