sybase数据库导出mysql_sybase数据库导出表结构

在不同平台上导数据时,只能用BCP命令,但是BCP命令不能导出数据库表结构,所以需进行数据库表结构的导出。

在sybase12.5版本以上,可以用如下方式导出表结构:

ddlgen –Usa –Pxxx –Ddb_name –Sxxx:port –Ooutput_file

其中db_name指所要导出的数据库名。

********************************************

低于sybase12.5版本的,得进行执行脚本的方式导出表结构。脚本文件内容如下:

use sybsystemprocs

go

if object_id('dbo.sp_ddl_create_table') is not null

drop procedure sp_ddl_create_table

print "Dropping sp_ddl_create_table"

go

create proc sp_ddl_create_table

as

-- Creates the DDL for all the user tables in the

-- current database

select right('create table ' + so1.name + '(' + '

', 255 * ( abs( sign(sc1.colid - 1) - 1 ) ) )+

sc1.name + ' ' +

st1.name + ' ' +

substring( '(' + rtrim( convert( char, sc1.length ) ) + ') ', 1,

patindex('%char', st1.name ) * 10 ) +

substring( '(' + rtrim( convert( char, sc1.prec ) ) + ', ' + rtrim(

convert( char, sc1.scale ) ) + ') ' , 1, patindex('numeric', st1.name ) * 10 ) +

substring( 'NOT NULL', ( convert( int, convert( bit,( sc1.status & 8 ) ) ) * 4 ) + 1,

8 * abs(convert(bit, (sc1.status & 0x80)) - 1 ) ) +

right('identity ', 9 * convert(bit, (sc1.status & 0x80)) ) +

right(',', 5 * ( convert(int,sc2.colid) - convert(int,sc1.colid) ) ) +

right(' )

' + 'go' + '

' + '

', 255 * abs( sign( ( convert(int,sc2.colid) - convert(int,sc1.colid) ) ) -

1 ) )

from sysobjects so1,

syscolumns sc1,

syscolumns sc2,

systypes st1

where so1.type = 'U'

and sc1.id = so1.id

and st1.usertype = sc1.usertype

and sc2.id = sc1.id

and sc2.colid = (select max(colid)

from syscolumns

where id = sc1.id)

order by so1.name, sc1.colid

go

if object_id('dbo.sp_ddl_create_table') is not null

begin

grant execute on sp_ddl_create_table to public

print "Created sp_ddl_create_table"

end

else

print "Failed to create sp_ddl_create_table"

go

**************************************************************

查看具体某数据库表结构方法如下,以查看nbcredit数据库表结构为例:

编辑脚本文件script.txt,保存在c:\,内容如下:

use nbcredit

go

sp_ddl_create_table

go

然后执行以下语名:isql –Usa –Pxxx –b –i script.txt –o scriptout.txt

其中scriptout.txt文件的内容即为整个数据库表结构。

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值