獲取資料名稱 表名 欄位名 字段型別

2021-07-23 17:04:10 字數 901 閱讀 5218



1. 獲取所有資料庫名:

select * from master..sysdatabases

2. 獲取資料庫物件:

select * from sysobjects

xtype  代表型別c = check 約束

d = 預設值或 default 約束

f = foreign key 約束

l = 日誌

fn = 標量函式

if = 內嵌表函式

p = 儲存過程

pk = primary key 約束(型別是 k)

rf = 複製篩選儲存過程

s = 系統表

tf = 表函式

tr = 觸發器

u = 使用者表

uq = unique 約束(型別是 k)

v = 檢視

x = 擴充套件儲存過程

3. 獲取表的所有字段:

select * from syscolumns where id=object_id('tablename')

select * from sys.extended_properties where major_id=object_id('tablename')

*其中 major_id 為 表id [object_id('tablename')],minor_id 對應syscolumns的colorder欄位

4..獲取資料庫所有型別 :

select * from systypes

* 其中xtype與3中的xtype對應



資料庫修改表名,欄位名 字段型別

修改表 1 修改表的名稱呢 alter table 表名 rename to 新的名字 demo alter table ta1 rename to ta0 2 新增乙個新字段 alter table 表名 add 新字段 欄位的型別 demo alter table ta0 add unames ...

取Oracle 表名 欄位名

檢視oracle 資料庫中本使用者下的所有表 select table name from user tables 檢視oracle 資料庫中所有使用者下的所有表 select user,table name from all tables 檢視oracle 資料庫中本使用者下的所有列 select...

取Oracle 表名 欄位名

取 oracle 表名 欄位名 注釋等實用語句 sql 檢視oracle 資料庫中本使用者下的所有表 select table name from user tables 檢視oracle 資料庫中所有使用者下的所有表 select user,table name from all tables 檢...