2006年世界杯歌曲_冰岛世界杯排名 - guoyunzhan.com

  • 首页
  • 世界杯黑马
  • 世界杯直播app
  • 世界杯小组赛规则
  • 2025-06-25 05:12:59

    PowerDesigner的基本使用

    目录

    数据库模型1、New Model2、创建数据库模型3、创建表4、导出为sql语句导出全部表导出指定表

    5、运行测试

    导出为EXCEL导出所有表导出单张表

    将name自动填充到注释(comment)comment赋值到name设置导出SQL的编码检查设计的表有没有问题导入sql生成模型改变name时code跟着改变导入excel为model查找

    数据库模型

    通过PowerDesigner建立数据库模型,生成sql语句以后,去数据库执行即可建表。

    1、New Model

    以下两种都可以

    2、创建数据库模型

    New Model以后出现以下窗口,按照1-2-3操作即可

    3、创建表

    建表 点击图示后,鼠标变为表格图示,空白处点击后创建一张表,相当于数据库的表。 编辑表 点击后创建的表如下图示,在palette选择鼠标箭头,双击该表就能编辑。 设置名称 编辑列 主键自增 关联主外键 点击palette,选择如图所示标志,然后关联起来,直接拉就可以 双击这个箭头,可以看到父表子表关联完成,然后指定他们的关联字段。 可以看到关联的字段已经设定好

    4、导出为sql语句

    导出全部表

    选择好直接确定,就是导出所有表

    导出指定表

    在上步的基础上,选择selection,找到大的模块,然后选择tables,然后选中要导出的某张表

    5、运行测试

    打开数据库,运行生成的sql文件,成功

    导出为EXCEL

    导出所有表

    tools-execute commands-edit/run script 然后在窗口中粘贴代码点RUN执行 执行完毕所有表将会生成在同一个EXCEL表格粘贴代码

    '******************************************************************************

    Option Explicit

    Dim rowsNum

    rowsNum = 0

    '-----------------------------------------------------------------------------

    ' Main function

    '-----------------------------------------------------------------------------

    ' Get the current active model

    Dim Model

    Set Model = ActiveModel

    If (Model Is Nothing) Or (Not Model.IsKindOf(PdPDM.cls_Model)) Then

    MsgBox "The current model is not an PDM model."

    Else

    ' Get the tables collection

    '创建EXCEL APP

    dim beginrow

    DIM EXCEL, SHEET, SHEETLIST

    set EXCEL = CREATEOBJECT("Excel.Application")

    EXCEL.workbooks.add(-4167)'添加工作表

    EXCEL.workbooks(1).sheets(1).name ="表结构"

    set SHEET = EXCEL.workbooks(1).sheets("表结构")

    EXCEL.workbooks(1).sheets.add

    EXCEL.workbooks(1).sheets(1).name ="目录"

    set SHEETLIST = EXCEL.workbooks(1).sheets("目录")

    ShowTableList Model,SHEETLIST

    ShowProperties Model, SHEET,SHEETLIST

    EXCEL.workbooks(1).Sheets(2).Select

    EXCEL.visible = true

    '设置列宽和自动换行

    sheet.Columns(1).ColumnWidth = 20

    sheet.Columns(2).ColumnWidth = 20

    sheet.Columns(3).ColumnWidth = 20

    sheet.Columns(4).ColumnWidth = 40

    sheet.Columns(5).ColumnWidth = 10

    sheet.Columns(6).ColumnWidth = 10

    sheet.Columns(1).WrapText =true

    sheet.Columns(2).WrapText =true

    sheet.Columns(4).WrapText =true

    '不显示网格线

    EXCEL.ActiveWindow.DisplayGridlines = False

    End If

    '-----------------------------------------------------------------------------

    ' Show properties of tables

    '-----------------------------------------------------------------------------

    Sub ShowProperties(mdl, sheet,SheetList)

    ' Show tables of the current model/package

    rowsNum=0

    beginrow = rowsNum+1

    Dim rowIndex

    rowIndex=3

    ' For each table

    output "begin"

    Dim tab

    For Each tab In mdl.tables

    ShowTable tab,sheet,rowIndex,sheetList

    rowIndex = rowIndex +1

    Next

    if mdl.tables.count > 0 then

    sheet.Range("A" & beginrow + 1 & ":A" & rowsNum).Rows.Group

    end if

    output "end"

    End Sub

    '-----------------------------------------------------------------------------

    ' Show table properties

    '-----------------------------------------------------------------------------

    Sub ShowTable(tab, sheet,rowIndex,sheetList)

    If IsObject(tab) Then

    Dim rangFlag

    rowsNum = rowsNum + 1

    ' Show properties

    Output "================================"

    sheet.cells(rowsNum, 1) =tab.name

    sheet.cells(rowsNum, 1).HorizontalAlignment=3

    sheet.cells(rowsNum, 2) = tab.code

    'sheet.cells(rowsNum, 5).HorizontalAlignment=3

    'sheet.cells(rowsNum, 6) = ""

    'sheet.cells(rowsNum, 7) = "表说明"

    sheet.cells(rowsNum, 3) = tab.comment

    'sheet.cells(rowsNum, 8).HorizontalAlignment=3

    sheet.Range(sheet.cells(rowsNum, 3),sheet.cells(rowsNum, 7)).Merge

    '设置超链接,从目录点击表名去查看表结构

    '字段中文名 字段英文名 字段类型 注释 是否主键 是否非空 默认值

    sheetList.Hyperlinks.Add sheetList.cells(rowIndex,2), "","表结构"&"!B"&rowsNum

    rowsNum = rowsNum + 1

    sheet.cells(rowsNum, 1) = "字段中文名"

    sheet.cells(rowsNum, 2) = "字段英文名"

    sheet.cells(rowsNum, 3) = "字段类型"

    sheet.cells(rowsNum, 4) = "注释"

    sheet.cells(rowsNum, 5) = "是否主键"

    sheet.cells(rowsNum, 6) = "是否非空"

    sheet.cells(rowsNum, 7) = "默认值"

    '设置边框

    sheet.Range(sheet.cells(rowsNum-1, 1),sheet.cells(rowsNum, 7)).Borders.LineStyle = "1"

    'sheet.Range(sheet.cells(rowsNum-1, 4),sheet.cells(rowsNum, 9)).Borders.LineStyle = "1"

    '字体为10号

    sheet.Range(sheet.cells(rowsNum-1, 1),sheet.cells(rowsNum, 7)).Font.Size=10

    Dim col ' running column

    Dim colsNum

    colsNum = 0

    for each col in tab.columns

    rowsNum = rowsNum + 1

    colsNum = colsNum + 1

    sheet.cells(rowsNum, 1) = col.name

    'sheet.cells(rowsNum, 3) = ""

    'sheet.cells(rowsNum, 4) = col.name

    sheet.cells(rowsNum, 2) = col.code

    sheet.cells(rowsNum, 3) = col.datatype

    sheet.cells(rowsNum, 4) = col.comment

    If col.Primary = true Then

    sheet.cells(rowsNum, 5) = "Y"

    Else

    sheet.cells(rowsNum, 5) = " "

    End If

    If col.Mandatory = true Then

    sheet.cells(rowsNum, 6) = "Y"

    Else

    sheet.cells(rowsNum, 6) = " "

    End If

    sheet.cells(rowsNum, 7) = col.defaultvalue

    next

    sheet.Range(sheet.cells(rowsNum-colsNum+1,1),sheet.cells(rowsNum,7)).Borders.LineStyle = "3"

    'sheet.Range(sheet.cells(rowsNum-colsNum+1,4),sheet.cells(rowsNum,9)).Borders.LineStyle = "3"

    sheet.Range(sheet.cells(rowsNum-colsNum+1,1),sheet.cells(rowsNum,7)).Font.Size = 10

    rowsNum = rowsNum + 2

    Output "FullDescription: " + tab.Name

    End If

    End Sub

    '-----------------------------------------------------------------------------

    ' Show List Of Table

    '-----------------------------------------------------------------------------

    Sub ShowTableList(mdl, SheetList)

    ' Show tables of the current model/package

    Dim rowsNo

    rowsNo=1

    ' For each table

    output "begin"

    SheetList.cells(rowsNo, 1) = "主题"

    SheetList.cells(rowsNo, 2) = "表中文名"

    SheetList.cells(rowsNo, 3) = "表英文名"

    SheetList.cells(rowsNo, 4) = "表说明"

    rowsNo = rowsNo + 1

    SheetList.cells(rowsNo, 1) = mdl.name

    Dim tab

    For Each tab In mdl.tables

    If IsObject(tab) Then

    rowsNo = rowsNo + 1

    SheetList.cells(rowsNo, 1) = ""

    SheetList.cells(rowsNo, 2) = tab.name

    SheetList.cells(rowsNo, 3) = tab.code

    SheetList.cells(rowsNo, 4) = tab.comment

    End If

    Next

    SheetList.Columns(1).ColumnWidth = 20

    SheetList.Columns(2).ColumnWidth = 20

    SheetList.Columns(3).ColumnWidth = 30

    SheetList.Columns(4).ColumnWidth = 60

    output "end"

    End Sub

    导出单张表

    将name自动填充到注释(comment)

    '把pd中那么name想自动添加到comment里面

    '如果comment为空,则填入name;如果不为空,则保留不变,这样可以避免已有的注释丢失.

    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

    if trim(tab.comment)="" then '如果有表的注释,则不改变它.如果没有表注释.则把name添加到注释里面.

    tab.comment = tab.name

    end if

    Dim col ' running column

    for each col in tab.columns

    if trim(col.comment)="" then '如果col的comment为空,则填入name,如果已有注释,则不添加;这样可以避免已有注释丢失.

    col.comment= col.name

    end if

    next

    end if

    next

    Dim view 'running view

    for each view in folder.Views

    if not view.isShortcut and trim(view.comment)="" 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赋值到name

    '代码二:将Comment中的字符COPY至Name中

    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

    设置导出SQL的编码

    检查设计的表有没有问题

    导入sql生成模型

    2. 选好数据库类型点击确定 3. 选择要导入的sql,可多选,选好点确定就生成了

    改变name时code跟着改变

    菜单栏Tools→General Options 选中Name to Code mirroring是name跟着code改变,不选中是不跟着改变

    导入excel为model

    x1.Workbooks.Open “C:\Users\w4523\Desktop\数据管控\工作表.xlsx” x1.Workbooks(1).Worksheets(“Sheet1”).Activate 这里设置excel路径和sheet位置

    Option Explicit

    Dim mdl ' the current model

    Set mdl = ActiveModel

    If (mdl Is Nothing) Then

    MsgBox "There is no Active Model"

    End If

    Dim HaveExcel

    Dim RQ

    RQ = vbYes 'MsgBox("Is Excel Installed on your machine ?", vbYesNo + vbInformation, "Confirmation")

    If RQ = vbYes Then

    HaveExcel = True

    ' Open & Create Excel Document

    Dim x1 '

    Set x1 = CreateObject("Excel.Application")

    x1.Workbooks.Open "C:\Users\w4523\Desktop\数据管控\工作表.xlsx"

    x1.Workbooks(1).Worksheets("Sheet1").Activate

    Else

    HaveExcel = False

    End If

    a x1, mdl

    sub a(x1,mdl)

    dim rwIndex

    dim tableName

    dim colname

    dim table

    dim col

    dim count

    'on error Resume Next

    For rwIndex = 1 To 1000 step 1

    With x1.Workbooks(1).Worksheets("Sheet1")

    'MsgBox "生成数据表结构共计1 ="+CStr(.Cells(2,2).Value ), vbOK + vbInformation, "表"

    If .Cells(rwIndex, 1).Value = "" Then

    Exit For

    End If

    If .Cells(rwIndex, 3).Value = "" Then

    set table = mdl.Tables.CreateNew

    table.Name = .Cells(rwIndex , 1).Value

    table.Code = .Cells(rwIndex , 2).Value

    count = count + 1

    Else

    colName = .Cells(rwIndex, 1).Value

    set col = table.Columns.CreateNew

    'MsgBox .Cells(rwIndex, 1).Value, vbOK + vbInformation, "列"

    col.Name = .Cells(rwIndex, 1).Value

    'MsgBox col.Name, vbOK + vbInformation, "列"

    col.Code = .Cells(rwIndex, 2).Value

    col.Comment = .Cells(rwIndex,3).Value

    col.DataType = .Cells(rwIndex, 4).Value

    End If

    End With

    Next

    MsgBox "生成数据表结构共计" + CStr(count), vbOK + vbInformation, "表"

    Exit Sub

    End sub

    excel格式如下

    查找

    查找的时候默认是全匹配,就是得一模一样,可以用*模糊查询

    看完秒懂!为什么六安要读作“lù ān”
    王者荣耀杨玉环羞花什么时候上线-杨玉环羞花上线时间介绍
    世界杯直播app

    友情链接:

    ©Copyright © 2022 2006年世界杯歌曲_冰岛世界杯排名 - guoyunzhan.com All Rights Reserved.