>데이터 베이스 >MySQL 튜토리얼 >Sqlserver2005 Sqlcmd查看数据库/表/字段的命令

Sqlserver2005 Sqlcmd查看数据库/表/字段的命令

WBOY
WBOY원래의
2016-06-07 15:34:201285검색

Sqlcmd是sqlserver自带的命令行工具,可以在不打开企业管理器的时候访问本地或者远程的数据库,对数据库进行管理。 Sqlcmd连接数据库:sqlcmd -S 10.78.1.99 -U sa -P sa C:/Users/1232sqlcmd -S 10.78.1.99 -U sa -P sa 1 1.查询数据库 select name from ma

Sqlcmd是sqlserver自带的命令行工具,可以在不打开企业管理器的时候访问本地或者远程的数据库,对数据库进行管理。

Sqlcmd连接数据库:sqlcmd -S 10.78.1.99 -U sa -P sa

C:/Users/1232>sqlcmd -S 10.78.1.99 -U sa -P sa
1>

 

1.查询数据库
select name from master.dbo.sysdatabases

1> select name from master.dbo.sysdatabases
2> go
name
---------------------------------------------------------
master
tempdb
model
msdb
pubs
Northwind
COMMON_SECURITY
FlowEng
LTS
SUNDB
UTL
(11 行受影响)

 

2.查询数据库中的表
select name from sysobjects where xtype='U'

1> use master
2> go
已将数据库上下文改为 'master'。
1> select name from sysobjects where xtype='U'
2> go
name
------------------------------------------------------
spt_monitor
spt_values
spt_fallback_db
spt_fallback_dev
spt_fallback_usg
dtproperties
spt_provider_types
aofax_send_task
aofax_recv_task
FAXRECV
Pboc
spt_datatype_info_ext
MSreplication_options
spt_datatype_info
spt_server_info

(15 行受影响)


3.查询表中的列
select c.name,c.length from syscolumns c inner join sysobjects t on c.id = t.id and t.name='spt_monitor'

1> select c.name,c.length from syscolumns c inner join sysobjects t on c.id = t.id and t.name='spt_monitor'
2> go
name                                                                                                                             length
-------------------------------------------------------------------------------------------------------------------------------- ------
lastrun                                                                                                                               8
cpu_busy                                                                                                                              4
io_busy                                                                                                                               4
idle                                                                                                                                  4
pack_received                                                                                                                         4
pack_sent                                                                                                                             4
connections                                                                                                                           4
pack_errors                                                                                                                           4
total_read                                                                                                                            4
total_write                                                                                                                           4
total_errors                                                                                                                          4

(11 行受影响)

 

至于怎么打印出表字段的类型这个可以连查systypes表。

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.