dbschema的使用

dbschema可以导出整个库的结构也可以导出某个表的结构

如:dbschema -d dbname -t tabname db.sql

就是导出tabname表的结构保存在db.sql这个文档里


USAGE:

    dbschema [-q] [-t tabname] [-s user] [-p user] [-r rolename] [-f procname]
 
            [-hd tabname] -d dbname [-w passwd] [-seq sequence]
 
            [-u [ia] udtname [all]] [-it [Type]] [-l [num]] [-ss [-si]]
 
[filename]


 
   -q      Suppress the db version from header

    -t      table name or "all" for all tables

    -s      synonyms created by user name
 
           or "all" for all users

    -p      permissions granted to user name
 
           or "all" for all users

    -r      create and grant of the role
 
           or "all" for all roles :Not a valid option for SE

    -f      SPL routine name
 
           or "all" for all SPL routines


 
   -hd     Histograms of the distribution for columns of
 
           of a specified table, a specific table column,
 
           or "all" for all tables.

    -d      database name

    -w      database password
 
  
 
   -seq    generate sequence specific syntax

    -u      Prints the definitions of user-defined data types

    -ui     Prints the definitions of user-defined data types,
 
           including type inheritance

    -ua     Prints the definitions of user-defined data types,
 
           including all functions and casts defined over a type

    -u all  Directs dbschema to include all the tables
 
           in the display of distributions
 
  
 
   -it     Type of isolation can be DR, CR, CS or RR
 
  
 
   -l      set lock mode to wait [number] optional


 
   -ss     generate server specific syntax

            filename is the name
 
           of file that the SQL
 
           script goes in.   
 
   -si    excludes the generation of index storage clauses for
 
          non-fragmented tables


dbschema 实用程序打印复制指定表、视图或数据库所需的 SQL 语句。它还显示 UPDATE STATISTICS 语句创建的分发。

     可以将 dbschema 实用程序用于以下用途:
显示 SQL 语句(模式),这是复制数据库或特定表、视图、同义词、序列或过程所必需的。
显示 Information Schema 视图的模式。
显示为数据库中的一个或多个表存储的分布信息。
显示有关用户定义的数据类型和行类型的信息。

    警告:使用 dbschema 实用程序可以增加数据库中的序列对象,而在生成的数字中创建间隔则可能不是那些需要序列化整数的应用程序所期望的。

    使用 dbschema 且只指定了数据库名称时,等价于使用带所有选项(除了 -hd 和 -ss 选项)的 dbschema。另外,如果为数据库创建了“信息模式”视图,则将显示此模式。例如:以下两个命令是等价的:
dbschema -d stores_demo
dbschema -s all -p all -t all -f all -d stores_demo

经常使用的导出数据库所有信息的语句:
dbschema -s all -p all -t all -f all -d stores_demo -ss stores.sql

 

dbschema 常用命令

1)导出数据库中所有的表结构到文件db.sql
 
  $>dbschema -d your_database -t all   db.sql 

2)导出数据库中所有的存储过程到文件db.sql
 
  $>dbschema -d your_database -f all   db.sql

3)导出数据库中的所有对象(包含表,存储过程,触发器。。。)到文件db.sql
 
  $>dbschema -d your_database db.sql

4)导出数据库中一个表的结构到文件db.sql
 
  $>dbschema -d your_database_name -t your_table_name db.sql

5)导出一个存储过程定义到文件db.sql
 
  $>dbschema -d your_database_name -f your_procedure_name   db.sql

6)如果导出更多的表的信息(EXTENT...)
 
  $>dbschema -d your_database_name -ss db.sql

7)导出数据库中对用户或角色的授权信息
 
  $>dbschema -d your_database_name -p all
 
  $>dbschema -d your_database_name -r all

8)导出数据库中的同义词

 

  $>dbschema -d your_database_name -s all

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值