濮阳杆衣贸易有限公司

主頁 > 知識庫 > oracle 使用sql獲取數(shù)據(jù)庫表、表的字段的多種方法

oracle 使用sql獲取數(shù)據(jù)庫表、表的字段的多種方法

熱門標(biāo)簽:開封智能外呼系統(tǒng)廠家 外呼線路外顯本地號碼 美圖秀秀地圖標(biāo)注 百度地圖標(biāo)注素材 征服眼公司地圖標(biāo)注 征服者火車站地圖標(biāo)注 阿爾巴尼亞地圖標(biāo)注app 人工智能地圖標(biāo)注自己能做嗎 word地圖標(biāo)注方向
--第一種方法: 查詢dba_tab_columns
復(fù)制代碼 代碼如下:

select COLUMN_NAME,DATA_TYPE,DATA_LENGTH
from dba_tab_columns
where table_name =upper('表名')
order by COLUMN_NAME

--這種方法需要有DBA權(quán)限

--第二種方法: 查詢user_tab_cols
select COLUMN_NAME,DATA_TYPE,DATA_LENGTH
from user_tab_cols
where table_name=upper('表名')

order by COLUMN_NAME
--這種方法只能查找當(dāng)前用戶下的表

--第三種方法: 查詢ALL_TAB_COLUMNS
select distinct COLUMN_NAME,DATA_TYPE,DATA_LENGTH
from ALL_TAB_COLUMNS
WHERE TABLE_NAME= upper('表名')
--這種方法可以查詢所有用戶下的表

---------------------------補充-------------------------------------------------------------
復(fù)制代碼 代碼如下:

--增加字段
alter table cw_srcbpb
add (SRCBPB_RJBPBL varchar2(100) );
alter table cw_srcbpb
modify (SRCBPB_RJBPBL number(30,3) );
--Oracle查看所有表和字段

--獲取表:

select table_name from user_tables; --當(dāng)前用戶的表
select table_name from all_tables; --所有用戶的表
select table_name from dba_tables; --包括系統(tǒng)表

select table_name from dba_tables where owner='LBSP'; --獲取用戶***所擁有的表這里的用戶名要記得是用大寫的。
-- 獲取表字段:其實這里是根據(jù)用戶的權(quán)限來獲取字段的屬性(表名要大寫)

select * from user_tab_columns where Table_Name='用戶表';--獲取用戶表的所有字段還有字段的屬性。

select * from all_tab_columns where Table_Name='用戶表';--獲取用戶表的所有字段還有字段的屬性。所屬用戶是***

select * from dba_tab_columns where Table_Name='用戶表';--獲取用戶表的所有字段還有字段的屬性。所屬用戶是***

--獲取表注釋:

select * from user_tab_comments

--user_tab_comments:table_name,table_type,comments

--相應(yīng)的還有dba_tab_comments,all_tab_comments,這兩個比user_tab_comments多了ower列。

--獲取字段注釋:
select * from user_col_comments
--user_col_comments:table_name,column_name,comments
--相應(yīng)的還有dba_col_comments,all_col_comments,這兩個比user_col_comments多了ower列。
--查詢出用戶所有表的索引
select * from user_indexes
--查詢用戶表的索引(非聚集索引):
select * from user_indexes where uniqueness='NONUNIQUE'
--查詢用戶表的主鍵(聚集索引):
select * from user_indexes where uniqueness='UNIQUE'
--查詢表的索引
select t.*,i.index_type from user_ind_columns t,user_indexes i where t.index_name = i.index_name and
t.table_name='NODE'
--查詢表的主鍵
select cu.* from user_cons_columns cu, user_constraints au where cu.constraint_name = au.constraint_name and
au.constraint_type = 'P' AND cu.table_name = 'NODE'
--查找表的唯一性約束(包括名稱,構(gòu)成列):
select column_name from user_cons_columns cu, user_constraints au where cu.constraint_name=au.constraint_name and
cu.table_name='NODE'
--查找表的外鍵
select * from user_constraints c where c.constraint_type = 'R' and c.table_name='STAFFPOSITION'
--查詢外鍵約束的列名:
select * from user_cons_columns cl where cl.constraint_name = 外鍵名稱
--查詢引用表的鍵的列名:
select * from user_cons_columns cl where cl.constraint_name = 外鍵引用表的鍵名
您可能感興趣的文章:
  • 在oracle 數(shù)據(jù)庫查詢的select 查詢字段中關(guān)聯(lián)其他表的方法
  • 解析如何查看Oracle數(shù)據(jù)庫中某張表的字段個數(shù)
  • oracle刪除表字段和oracle表增加字段
  • oracle獲取當(dāng)前用戶表、字段等詳細信息SQL
  • Oracle 查詢表信息獲取表字段及字段注釋
  • Oracle刪除表、字段之前判斷表、字段是否存在

標(biāo)簽:酒泉 淮南 六安 海北 葫蘆島 宜春 孝感 泰安

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《oracle 使用sql獲取數(shù)據(jù)庫表、表的字段的多種方法》,本文關(guān)鍵詞  oracle,使用,sql,獲取,數(shù)據(jù)庫,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《oracle 使用sql獲取數(shù)據(jù)庫表、表的字段的多種方法》相關(guān)的同類信息!
  • 本頁收集關(guān)于oracle 使用sql獲取數(shù)據(jù)庫表、表的字段的多種方法的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    四子王旗| 通辽市| 武胜县| 盐边县| 海淀区| 岳普湖县| 沙田区| 宁明县| 和硕县| 阿拉善盟| 张家口市| 正镶白旗| 广宗县| 聂荣县| 和平县| 黑龙江省| 客服| 京山县| 金华市| 西林县| 永德县| 冀州市| 塔河县| 南丹县| 吉首市| 宾川县| 双流县| 资中县| 安福县| 新疆| 阳新县| 响水县| 陆丰市| 普定县| 同心县| 改则县| 大冶市| 南投市| 绥滨县| 威宁| 西丰县|