程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 數據庫知識 >> SyBase數據庫 >> SyBase綜合文章 >> Sybase中如何用工具生成DDL腳本

Sybase中如何用工具生成DDL腳本

編輯:SyBase綜合文章
當前位置: 火魔網 » 數據庫 » Sybase

Sybase中如何用工具生成DDL腳本

更新: 2011-08-03字體: 【 】點擊: 4  

如果要制作一個相同的數據庫備份,但又擔心現有的建庫腳本跟已有數據庫不一致,那就需要從已有數據庫中導出一份一模一樣的數據字典。

最常用的方法有如下2種:

1、采用PowerDesigner的反向工程來導出DDL。

2、采用Sybase自帶的DDL生成工具ddlgen。

下面著重描述下ddlgen的用法。

ddlgen的描述:

A Java-based tool that generates definitions for server- and database-level
objects in Adaptive Server. ddlgen supports Adaptive Server version 11.9.2 and
later.
程序所在目錄:

Windows平台下:$Sybase/sybcent32
Unix/Linux平台下:$Sybase_HOME/ASEP/bin

用法:

1、存儲過程
ddlgen -Usa -P -Sip:port -Duserdb -TP -N% -O proc.ddl
2、數據庫
ddlgen -Usa -P -Sip:port -Duserdb -TDB -Nuserdb -O db.ddl
3、表結構
ddlgen -Usa -P -Sip:port -Duserdb -TU -N% -O table.ddl
4、視圖
ddlgen -Usa -P -Sip:port -Duserdb -TV -N% -O vIEw.ddl

注意:

1、正常只要導出這些就可以了。當然如果你定義了觸發器或需要導出用戶信息都可以。

2、導出數據庫的情況下,已經包含了導出表結構定義。如果不需要創建數據庫,可以只導表結構定義。

3、表結構定義的所有外鍵是在最後的,因此無需擔心表的先後順序。

4、用戶權限必須是數據庫的dbo或sa。

語法:

ddlgen

    -Ulogin
    -PpassWord
    -Shost_name : port_number
    [-Tobject_type]
    [-Nobject_name]
    [-Ddatabase_name]
    [-Xextended_object_type]
    [-Ooutput_file]
    [-Eerror_file]
Or
ddlgen -v

參數說明:

-U login
    specifIEs a login name, and is case-sensitive.
-P passWord
    specifIEs your passWord.
-Shost_name : port_number
    specifIEs the host name or IP address of Adaptive Server, as well as its port
    number. Separate host_name and port_number with a colon, without spaces
    before or after it.
    Note You must use the -S option because ddlgen does not connect to a default
    server, and does not support interface files.
-Tobject_type
    specifIEs the type of object you are creating. If you do not use -T, ddlgen
    creates a DDL for the default database of login. Table 6-3 lists object types
    for -T.

-Nobject_name
    specifies the fully qualifIEd name of the object you are creating, such as
    -Ndb_name.owner.table.index.
    The -N option:
        is required if you specify any object_type other than DB (database) in
        the -T parameter.
        accepts wildcards with the use of %.
    Use -N% to generate a DDL for all items of a specific object type on your
    server.
-Ddatabase_name
    specifIEs the name of the database for the object you specify in the -N option.
    The default is the user’s default database.
-Xextended_object_type
    differentiates user tables (OU) from proxy tables (OD) when you specify a
    table as your object type (-TU). If object_type (-T) is U (table) and -X is not
    specifIEd, ddlgen generates DDL for both user tables and proxy tables. To
    generate a DDL only for:
        user tables – use the OU extended object type with the -X option.
        proxy tables – use the OD extended object type with the -X option.
-Ooutput_file
    specifIEs an output file for the generated DDL. If you do not specify -O, the
    DDL you create appears in a console window.
-Eerror_file
    specifIEs a log file for recording errors. If you do not specify -E, the
    generated errors appear in a console window.
-v
    displays the version and copyright message of ddlgen and returns to the
    Operating system.

Object type描述:

C cache
D default
DB database
DBD database device
DPD dump device
EC execution class
EG engine group
GRP group
I index
L login
P stored procedure
R rule
RO role
RS remote server
SGM segment
TR trigger
U table
UDD user-defined datatype
USR user
V vIEw
XP extended stored procedure

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved