use 資料庫
select a.name as 表名,b.name as 欄位名,b.length as 字段長度,c.name 字段型別
from (select * from sysobjects where xtype='u') a join syscolumns b
on a.id=b.id
left join systypes c on b.xusertype=c.xusertype
order by 表名
以下都是異曲同工
select d.name,a.name ,b.name ,a.length, a.isnullable from syscolumns a, systypes b,sysobjects d where a.xtype=b.xusertype and a.id=d.id and d.xtype='u'
這個住處比較詳細不過就比較長
select
(case when a.colorder=1 then d.name else '' end)表名,
a.colorder 字段序號,
a.name 欄位名,
(case when columnproperty( a.id,a.name,'isidentity')=1 then '√'else '' end) 標識,
(case when (select count(*)
from sysobjects
where (name in
(select name
from sysindexes
where (id = a.id) and (indid in
(select indid
from sysindexkeys
where (id = a.id) and (colid in
(select colid
from syscolumns
where (id = a.id) and (name = a.name))))))) and
(xtype = 'pk'))>0 then '√' else '' end) 主鍵,
b.name 型別,
a.length 占用位元組數,
columnproperty(a.id,a.name,'precision') as 長度,
isnull(columnproperty(a.id,a.name,'scale'),0) as 小數字數,
(case when a.isnullable=1 then '√'else '' end) 允許空,
isnull(e.text,'') 預設值,
isnull(g.[value],'') as 字段說明
from syscolumns a left join systypes b
on a.xtype=b.xusertype
inner join sysobjects d
on a.id=d.id and d.xtype='u' and d.name<>'dtproperties'
left join syscomments e
on a.cdefault=e.id
left join sysproperties g
on a.id=g.id and a.colid = g.**allid
order by a.id,a.colorder
另外方法1:
select * from information_schema.tables
select * from information_schema.columns
另外方法2:
use 你的資料庫名
select * from sysobjects where xtype='u' and status>0
2:
select * from syscolumns where id =object_id('表名')
另外方法3:
exec sp_help
exec sp_tables
再來兩個比較好看的.
--查使用者表
select name from sysobjects where xtype='u' and status >0 order by name
--查出指定表名的字段資訊
select a.name from syscolumns a,sysobjects b where a.id=b.id and b.name=表名
order by a.name
列出MSSQL所有資料庫名 所有表名 所有欄位名
列出mssql所有資料庫名 所有表名 所有欄位名 1.獲取所有資料庫名 select name from master.sysdatabases order by name 2.獲取所有表名 select name from sysobjects where xtype u order by nam...
Oracle刪除乙個庫裡面的所有表
如果有刪除使用者的許可權,則可以 drop user user name cascade 加了cascade就可以把使用者連帶的資料全部刪掉。刪除後再建立該使用者。建立管理員使用者 create user 使用者名稱 identified by 密碼 default tablespace space...
Mssql 根據表名查詢所有字段資訊
select 表名 case when a.colorder 1 then d.name else end,表說明 case when a.colorder 1 then isnull f.value,else end,字段序號 a.colorder,欄位名 a.name,標識 case when ...