dbschema的使用

来源:互联网 发布:房产php源码 编辑:程序博客网 时间:2024/06/05 00:26

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

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

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


USAGE:

    dbschema[-q] [-t tabname] [-s user] [-p user] [-r rolename] [-fprocname]
 
           [-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    generatesequence 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

    -uall  Directs dbschema to include all thetables
 
          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 goesin.   
 
  -si    excludesthe 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 -ssstores.sql

 

dbschema 常用命令

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

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

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

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

5)导出一个存储过程定义到文件db.sql
 
  $>dbschema -dyour_database_name -fyour_procedure_name   db.sql

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

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

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

 

  $>dbschema -dyour_database_name -s all

原创粉丝点击