powerDesigner使用教程【原创】

如何配置powerDesigner 15 以及逆向工程导出数据库表结构。

powerDesigner使用教程【原创】_第1张图片

powerDesigner使用教程【原创】_第2张图片

powerDesigner使用教程【原创】_第3张图片

powerDesigner使用教程【原创】_第4张图片

PDM文件路径  D:\Program Files (x86)\Sybase\PowerDesigner 16

oracle 11g 用户名及口令都是yudexiao

oracle_home

D:\orcl\asus1\product\11.2.0\dbhome_1

tns_admin

F:\orclClient\instantclient_11_2_x64

 

client

F:\orclClient\instantclient_11_2_x64

F:\orclClient\instantclient_11_2_x32

 

TNSNAMES.ORA-------

GTGISMANAGER =

  (DESCRIPTION =

    (ADDRESS_LIST =

      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.200)(PORT = 1521))

    )

    (CONNECT_DATA =

      (SERVICE_NAME = orcl)

    )

  )

 

 

jdk

C:\ProjectOne\Java\jdk1.7.0_51

 

问题一:Could not initialize JavaVM

 

在网上查了许多资料,

 

有的地方说jdk安装在program Files文件里面, 可能因为这个空格的原因造成的,  我先把jdk装在了C:\java目录下面

 

还是不行, 我使用的jdk64位的又重新安装了一个windows x86版本的jdk, 改了一下JAVA_HOME

 

其他设置如下,我使用的15.3版本的powerdesigner

 

1.系统变量-classpath:加入mysql jar包的地址(例如C:\mysql-connector-java-3.1.13-bin.jar)

 

2.powerdesigner-Tools-General Options-Variables 修改JAR,JAVA,JAVAC,JAVADOCValue

 

例如 JARValue:         C:\Java\jdk1.6.0_30\bin\jar.exe

 

      JAVAValue:        C:\Java\jdk1.6.0_30\bin\java.exe

 

      JAVACValue:      C:\Java\jdk1.6.0_30\bin\javac.exe

 

      JAVADOCValue:  C:\Java\jdk1.6.0_30\bin\javadoc.exe

 

3.powerdesigner-Database-Configure Data Connections-Connection Profiles

 

点击Add Data source图标, 依次填入连接信息

 

例如:Connection profile name:MySQL

 

Description:                  MySQL

 

Connection type:JDBC

 

DBMS type:        MySQL

 

User name:         root

 

Password:         123

 

JDBC driver class:      com.mysql.jdbc.Driver

 

JDBC connetion URL:jdbc:mysql://localhost:3306/database

 

JDBC driver jar files:    C:\mysql-connector-java-3.1.13-bin.jar

问题二:如何配置绿色版oracle client

client有两种:一种是安装包里有setup.exe文件的,另一种是绿色免安装的,使用的时候需要在环境变量中配置。配置如下:


powerDesigner使用教程【原创】_第5张图片

绿色免安装版的安装包如下:

powerDesigner使用教程【原创】_第6张图片

没有setup.exe文件


问题三:PD学习网站及PD的使用小小感悟

推荐学习powerDesigner的视频网站,网址如下:http://video.1kejian.com/computer/soft/76527/

 

1、客户端引发的思考

本次安装配置PowerDesigner,遇到很多困惑,虽然很多网友提示安装客户端,但是这次并没有用到客户端的配置,安装问题,主要问题怀疑在sqldeveloper上,sqldeveloper并不像PL/SQL developer那样,需要配置。

以下网友帖子上的观点:

PL/SQL相对来说开发和管理上的功能更强大些,用的人也多些

SQL DE跨平台性能好,迁移功能挺强大,图形显示功能也不错

网友Palm

 

网友inthirties

呵呵

 

plsql還是比較主流的,在開發和管理上都比較方便,還支持導入。導出功能, 不過需要安裝Oracle的客戶端,并且需要配置tnsname。這是我覺得,他稍微弱勢的一點。

Oracle psql dev呢,是Oracle自帶的工具,11g已經內嵌到數據庫的安裝里去了,也提供比較好的開發和管理的功能,但是相對plsql來說,要弱一些,不過其中帶有的migration tools是我鐘情于此工具的一點。 可以對異構或者同構的數據庫進行數據遷移,我在mysqlms sql上都做個不是很復雜的遷移,還是很方便和實用的,而且該工具最好的一點是 java開發,使用的jdbc的連接方式,所以即使沒有安裝客戶端也可以通過thin的方式連接

這兩個工具在開發和管理上 plsql dev 勝出一籌

但是在遷移功能和跨平臺上 sql dev又亮點多多。

你根據你自己的情況來進行選擇吧。

 

2ODBCJDBC之间的那点小事儿

本次PowerDesigner的安装配置,在ODBC  Machine Data Source选项上徘徊的时间,还真不少,挺多的。网友提示,搞Java用的驱动程序应该是JDBC。下面就ODBCJDBC之间的区别、联系做百度学习。

JDBC, 全称为Java DataBase Connectivity standard, 它是一个面向对象应用程序接口API, 通过它可访问各类关系数据库JDBC也是java核心类库的一部分。

 

    JDBC的最大特点是它独立于具体的关系数据库。与ODBC (Open Database Connectivity)类似, JDBC API 中定义了一些Java类分别用来表示与数据库的连接(connections, SQL语句(SQL statements, 结果集(result sets)以及其它的数据库对象, 使得Java程序能方便地与数据库交互并处理所得的结果。使用JDBC, 所有Java程序(包括Java applications , appletsservlet)都能通过SQL语句或存储在数据库中的过程(stored procedures)来存取数据库。

 

    要通过JDBC来存取某一特定的数据库,必须有相应的JDBC driver,它往往是由生产数据库的厂家提供,是连接JDBC API与具体数据库之间的桥梁。

 

    通常,Java程序首先使用JDBC API来与JDBC Driver Manager交互,由JDBC Driver Manager载入指定的JDBC drivers, 以后就可以通过JDBC API来存取数据库。

ODBC(Open Database Connectivity,开放数据库互连)微软公司开放服务结构(WOSAWindows Open Services Architecture)中有关数据库的一个组成部分,它建立了一组规范,并提供了一组对数据库访问的标准API(应用程序编程接口)。这些API利用SQL来完成其大部分任务。ODBC本身也提供了对SQL语言的支持,用户可以直接将SQL语句送给ODBC

{1.微软的东西比较复杂}

 

一个基于ODBC的应用程序对数据库的操作不依赖任何DBMS,不直接与DBMS打交道,所有的数据库操作由对应的DBMSODBC驱动程序完成。也就是说,不论是FoxProAccess还是Oracle数据库,均可用ODBC API进行访问。由此可见,ODBC的最大优点是能以统一的方式处理所有的数据库。

{1.ODBC也是处理所有DB,微软帝国的东西必须有其霸道的一面}

 

 

一个完整的ODBC由下列几个部件组成:

 

应用程序(Application)

 

ODBC管理器(Administrator)。该程序位于Windows 95控制面板(Control Panel)32ODBC内,其主要任务是管理安装的ODBC驱动程序和管理数据源。

 

驱动程序管理器(Driver Manager)。驱动程序管理器包含在ODBC32.DLL中,对用户是透明的。其任务是管理ODBC驱动程序,是ODBC中最重要的部件。

 

ODBC API

 

ODBC 驱动程序。是一些DLL,提供了ODBC和数据库之间的接口。 DLL:应用程序扩展)

 

数据源。数据源包含了数据库位置和数据库类型等信息,实际上是一种数据连接的抽象。

 

各部件之间的关系如图下图所示:

 

 

应用程序要访问一个数据库,首先必须用ODBC管理器注册一个数据源,管理器根据数据源提供的数据库位置、数据库类型及ODBC驱动程序等信息,建立起ODBC与具体数据库的联系。这样,只要应用程序将数据源名提供给ODBCODBC就能建立起与相应数据库的连接。

 

ODBC中,ODBC API不能直接访问数据库,必须通过驱动程序管理器与数据库交换信息。驱动程序管理器负责将应用程序对ODBC API的调用传递给正确的驱动程序,而驱动程序在执行完相应的操作后,将结果通过驱动程序管理器返回给应用程序。

 

在访问ODBC数据源时需要ODBC驱动程序的支持。用Visual C++ 5.0安装程序可以安装SQL ServerAccessParadoxdBaseFoxProExcelOracle Microsoft Text等驱动程序.在缺省情况下,VC5.0只会安装SQL ServerAccessFoxProdBase的驱动程序.如果用户需要安装别的驱动程序,则需要重新运行VC 5.0的安装程序并选择所需的驱动程序。

powerDesigner使用教程【原创】_第7张图片

问题:powerdesigner逆向工程,从数据库导出PDM

powerDesigner使用教程【原创】_第8张图片

DataBase-->configure Connections-->Connection Profiles-->左上角Properties-->Connection Profile Definition-->Test Connection

问题:powerdesigner如何将表格导入DataBase

powerDesigner使用教程【原创】_第9张图片

DataBase-->configure Connections-->Connection Profiles-->左上角Properties-->Connection Profile Definition-->Test Connection


问题:powerdesigner如何将表格导入DataBase

powerDesigner使用教程【原创】_第10张图片


powerDesigner使用教程【原创】_第11张图片



问题:如何通过VB脚本将Name批量转成Comment

 

Option   Explicit

ValidationMode   =   True

InteractiveMode   =   im_Batch

Dim   mdl   '   the   current   model

'   get   the   current   active   model

Set   mdl   =   ActiveModel

If   (mdl   Is   Nothing)   Then

      MsgBox   "There   is   no   current   Model "

ElseIf   Not   mdl.IsKindOf(PdPDM.cls_Model)   Then

      MsgBox   "The   current   model   is   not   an   Physical   Data   model. "

Else

      ProcessFolder   mdl

End   If

'   This   routine   copy   name   into   comment   for   each   table,   each   column   and   each   view

'   of   the   current   folder

Private   sub   ProcessFolder(folder)

      Dim   Tab   'running     table

      for   each   Tab   in   folder.tables

            if   not   tab.isShortcut   then

                  tab.comment   =   tab.name

                  Dim   col   '   running   column

                  for   each   col   in   tab.columns

                          col.name = col.comment                     

next

            end   if

      next

      Dim   view   'running   view

      for   each   view   in   folder.Views

            if   not   view.isShortcut   then

                  view.comment   =   view.name

            end   if

      next

      '   go   into   the   sub-packages

      Dim   f   '   running   folder

      For   Each   f   In   folder.Packages

            if   not   f.IsShortcut   then

                  ProcessFolder   f

            end   if

      Next

end   sub

 

 

'代码一:Name中的字符COPYComment中  

  

  

Option   Explicit   

ValidationMode   =   True   

InteractiveMode   =   im_Batch  

  

Dim   mdl   '   the   current   model  

  

'   get   the   current   active   model   

Set   mdl   =   ActiveModel   

If   (mdl   Is   Nothing)   Then   

      MsgBox   "There   is   no   current   Model "   

ElseIf   Not   mdl.IsKindOf(PdPDM.cls_Model)   Then   

      MsgBox   "The   current   model   is   not   an   Physical   Data   model. "   

Else   

      ProcessFolder   mdl   

End   If  

  

'   This   routine   copy   name   into   comment   for   each   table,   each   column   and   each   view   

'   of   the   current   folder   

Private   sub   ProcessFolder(folder)   

      Dim   Tab   'running     table   

      for   each   Tab   in   folder.tables   

            if   not   tab.isShortcut   then   

                  tab.comment   =   tab.name   

                  Dim   col   '   running   column   

                  for   each   col   in   tab.columns   

                        col.comment=   col.name   

                  next   

            end   if   

      next  

  

      Dim   view   'running   view   

      for   each   view   in   folder.Views   

            if   not   view.isShortcut   then   

                  view.comment   =   view.name   

            end   if   

      next  

  

      '   go   into   the   sub-packages   

      Dim   f   '   running   folder   

      For   Each   f   In   folder.Packages   

            if   not   f.IsShortcut   then   

                  ProcessFolder   f   

            end   if   

      Next   

end   sub

 

 

 

 

    '代码二:Comment中的字符COPYName中   

      

    Option   Explicit   

    ValidationMode   =   True   

    InteractiveMode   =   im_Batch  

      

    Dim   mdl   '   the   current   model  

      

    '   get   the   current   active   model   

    Set   mdl   =   ActiveModel   

    If   (mdl   Is   Nothing)   Then   

          MsgBox   "There   is   no   current   Model "   

    ElseIf   Not   mdl.IsKindOf(PdPDM.cls_Model)   Then   

          MsgBox   "The   current   model   is   not   an   Physical   Data   model. "   

    Else   

          ProcessFolder   mdl   

    End   If  

      

    Private   sub   ProcessFolder(folder)   

    On Error Resume Next  

          Dim   Tab   'running     table   

          for   each   Tab   in   folder.tables   

                if   not   tab.isShortcut   then   

                      tab.name   =   tab.comment  

                      Dim   col   '   running   column   

                      for   each   col   in   tab.columns   

                      if col.comment="" then  

                      else  

                            col.name=   col.comment   

                      end if  

                      next   

                end   if   

          next  

      

          Dim   view   'running   view   

          for   each   view   in   folder.Views   

                if   not   view.isShortcut   then   

                      view.name   =   view.comment   

                end   if   

          next  

      

          '   go   into   the   sub-packages   

          Dim   f   '   running   folder   

          For   Each   f   In   folder.Packages   

                if   not   f.IsShortcut   then   

                      ProcessFolder   f   

                end   if   

          Next   

    end   sub  

powerDesigner使用教程【原创】_第12张图片

问题:如何通过VB脚本将Name批量转成Comment

 

Option   Explicit

ValidationMode   =   True

InteractiveMode   =   im_Batch

Dim   mdl   '   the   current   model

'   get   the   current   active   model

Set   mdl   =   ActiveModel

If   (mdl   Is   Nothing)   Then

      MsgBox   "There   is   no   current   Model "

ElseIf   Not   mdl.IsKindOf(PdPDM.cls_Model)   Then

      MsgBox   "The   current   model   is   not   an   Physical   Data   model. "

Else

      ProcessFolder   mdl

End   If

'   This   routine   copy   name   into   comment   for   each   table,   each   column   and   each   view

'   of   the   current   folder

Private   sub   ProcessFolder(folder)

      Dim   Tab   'running     table

      for   each   Tab   in   folder.tables

            if   not   tab.isShortcut   then

                  tab.comment   =   tab.name

                  Dim   col   '   running   column

                  for   each   col   in   tab.columns

                          col.name = col.comment                     

next

            end   if

      next

      Dim   view   'running   view

      for   each   view   in   folder.Views

            if   not   view.isShortcut   then

                  view.comment   =   view.name

            end   if

      next

      '   go   into   the   sub-packages

      Dim   f   '   running   folder

      For   Each   f   In   folder.Packages

            if   not   f.IsShortcut   then

                  ProcessFolder   f

            end   if

      Next

end   sub

 

 

'代码一:Name中的字符COPYComment中  

  

  

Option   Explicit   

ValidationMode   =   True   

InteractiveMode   =   im_Batch  

  

Dim   mdl   '   the   current   model  

  

'   get   the   current   active   model   

Set   mdl   =   ActiveModel   

If   (mdl   Is   Nothing)   Then   

      MsgBox   "There   is   no   current   Model "   

ElseIf   Not   mdl.IsKindOf(PdPDM.cls_Model)   Then   

      MsgBox   "The   current   model   is   not   an   Physical   Data   model. "   

Else   

      ProcessFolder   mdl   

End   If  

  

'   This   routine   copy   name   into   comment   for   each   table,   each   column   and   each   view   

'   of   the   current   folder   

Private   sub   ProcessFolder(folder)   

      Dim   Tab   'running     table   

      for   each   Tab   in   folder.tables   

            if   not   tab.isShortcut   then   

                  tab.comment   =   tab.name   

                  Dim   col   '   running   column   

                  for   each   col   in   tab.columns   

                        col.comment=   col.name   

                  next   

            end   if   

      next  

  

      Dim   view   'running   view   

      for   each   view   in   folder.Views   

            if   not   view.isShortcut   then   

                  view.comment   =   view.name   

            end   if   

      next  

  

      '   go   into   the   sub-packages   

      Dim   f   '   running   folder   

      For   Each   f   In   folder.Packages   

            if   not   f.IsShortcut   then   

                  ProcessFolder   f   

            end   if   

      Next   

end   sub

 

 

 

 

    '代码二:Comment中的字符COPYName中   

      

    Option   Explicit   

    ValidationMode   =   True   

    InteractiveMode   =   im_Batch  

      

    Dim   mdl   '   the   current   model  

      

    '   get   the   current   active   model   

    Set   mdl   =   ActiveModel   

    If   (mdl   Is   Nothing)   Then   

          MsgBox   "There   is   no   current   Model "   

    ElseIf   Not   mdl.IsKindOf(PdPDM.cls_Model)   Then   

          MsgBox   "The   current   model   is   not   an   Physical   Data   model. "   

    Else   

          ProcessFolder   mdl   

    End   If  

      

    Private   sub   ProcessFolder(folder)   

    On Error Resume Next  

          Dim   Tab   'running     table   

          for   each   Tab   in   folder.tables   

                if   not   tab.isShortcut   then   

                      tab.name   =   tab.comment  

                      Dim   col   '   running   column   

                      for   each   col   in   tab.columns   

                      if col.comment="" then  

                      else  

                            col.name=   col.comment   

                      end if  

                      next   

                end   if   

          next  

      

          Dim   view   'running   view   

          for   each   view   in   folder.Views   

                if   not   view.isShortcut   then   

                      view.name   =   view.comment   

                end   if   

          next  

      

          '   go   into   the   sub-packages   

          Dim   f   '   running   folder   

          For   Each   f   In   folder.Packages   

                if   not   f.IsShortcut   then   

                      ProcessFolder   f   

                end   if   

          Next   

    end   sub  

如何去除引号,字段的引号

菜单DataBase-->Edit Current DBMS-->General-->Script-->

powerDesigner使用教程【原创】_第13张图片

如何让name列显示中文:

tools-->modeloptions-->naming convention-->display,选择NAM

powerDesigner使用教程【原创】_第14张图片

PowerDesigner导出脚本里包含视图

     

    打开使用MySQL5.0PDM之后,在菜单里选择

    Database-> Edit   Current   DBMS..

    确认DBMS使用的是MySQL5.0

    打开左端树状结构Script-> Objects-> View  

    选中Create,在右端的Value中写入

    create   VIEW   [%R%?[   if   not   exists]]   %VIEW%

    as

    %SQL%

    选中Drop,在右端的Value中写入  

    drop   table   if   exists   %VIEW%

    选中Enable,在右端的Value中选择Yes

    确定保存。

以上操作虽然能run 脚本,但是生成的是table table名字是xxx_view,

 

 

 

 

 

 

导入数据库

2、向数据库中导入表

 

(1)powerDesinger中,Database-->Generate Database...

  选择要导入的表,以及是否生成脚本文件,如果不生成脚本文件,就选择odbcGeneration,不过,如果直接往数据库中导入,一般不太容易成功,我导的时候,报了很多的error,后来查了一下,是因为powerDesigner生成的Sql语句表名,字段名都自动加上了双引号,所以导入的时候出现问题。不过据说这个问题可以通过你在建表的时候全部字母大写来解决,我没试过,大家可以试试

(2)我是导出的.sql脚本文件,再将所有的双引号转换成空格

(3)进入oracle服务器,怎样连,这里就不说了,将这个.sql文件放到$oracle_home目录下,在命令行下敲入

SQL>@文件名.sql

  就OK

问题:Could not Initialize JavaVM

如果出现   Could not Initialize JavaVM!   则说明JAVA环境配置错误,首先power designer需要在32位jdk环境下运行,可以先下载32位的jdk(如果用odbc连接那么另当别论),

然后设置环境变量  ,在这里我是建立了一个批处理文件,直接设置环境变量

set JAVA_HOME=C:\Program Files (x86)\Java\jdk1.8.0_25

set CLASSPATH=%JAVA_HOME%\lib;%JAVA_HOME%\lib\tools.jar

set path=C:\Program Files (x86)\Java\jdk1.8.0_25\bin

除了  上面这几个还需要在 工具--->常规选项--->varibles    里面设置一下四个选项(JAR,JAVA,JAVAC,JAVADOC)的路径如下图所示   



你可能感兴趣的:(powerDesigner)