--讀取庫中的所有庫
select name from master..sysdatabases order by name
--讀取庫中的所有表名
select name from master..sysobjects where xtype='u' order by name
--讀取指定表的所有列名
select name from syscolumns where id=(select max(id) from sysobjects where xtype='u' and name='表名')
獲取資料庫
表名和字段
sqlserver
中各個系統表的作用
sysaltfiles 主資料庫 儲存資料庫的檔案
syscharsets 主資料庫 字符集與排序順序
sysconfigures 主資料庫 配置選項
syscurconfigs 主資料庫 當前配置選項
sysdatabases 主資料庫 伺服器
中的資料庫
syslanguages 主資料庫 語言
syslogins 主資料庫 登陸帳號資訊
sysoledbusers 主資料庫 鏈結伺服器登陸資訊
sysprocesses 主資料庫 程序
sysremotelogins主資料庫 遠端登入帳號
syscolumns 每個資料庫 列
sysconstrains 每個資料庫 限制
sysfilegroups 每個資料庫 檔案組
sysfiles 每個資料庫 檔案
sysforeignkeys 每個資料庫 外部關鍵字
sysindexs 每個資料庫 索引
sysmenbers 每個資料庫
角色成員
sysobjects 每個資料庫 所有資料庫物件
syspermissions 每個資料庫 許可權
systypes 每個資料庫 使用者定義資料型別
sysusers 每個資料庫 使用者
//用什麼方法可以得到乙個表中所有的列名。sql
語句。select 列名=name from syscolumns where id=object_id(n'要查的表名')
use gpstrudy
select name="name" from syscolumns where id=object_id(n'booktable')
獲得欄位的屬性
//這是從一段**中考出來的,使用的是using system.data.oledb;
public int gettablefields(string tablename,out string fields,out string fieldtypes)
...{
try
...{
oledbcommand dc = m_oledb.createcommand();//建立乙個執行物件用於執行sql
查詢 dc.commandtext = "select * from " + tablename;
dc.transaction = m_oletrans;
oledbdatareader dr = dc.executereader();//執行sql
C 中如何獲取資料庫中表的資訊和列的資訊
c 中如何獲取資料庫中表的資訊和列的資訊 獲取表的資訊 conn.open string restrictions new string 4 restrictions 1 dbo datatable table conn.getschema tables restrictions conn.clos...
查詢資料庫中表的資訊
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 ...
查詢資料庫中表資訊等
有時候需要匯出某使用者下的所有table view sequence trigger等資訊,下面的sql可以將這些資訊select出來 select from user tables select from user views select from user sequences select f...