1、查詢出所有的使用者表
select * from user_tables 可以查詢出所有的使用者表
select owner,table_name from all_tables; 查詢所有表,包括其他使用者表
通過表名過濾需要將字母作如下處理
select * from user_tables where table_name = upper('表名')
因為無論你建立表的時候表名名字是大寫還是小寫的,create語句執行通過之後,對應的user_tables表中的table_name欄位都會自動變為大寫字母,
所以必須通過內建函式upper將字串轉化為大寫字母進行查詢,否則,即使建表語句執行通過之後,通過上面的查詢語句仍然查詢不到對應的記錄。
2、查詢出使用者所有表的索引select * from user_indexes
3、查詢使用者表的索引(非聚集索引):select * from user_indexes where uniqueness='nonunique'
4、查詢使用者表的主鍵(聚集索引):select * from user_indexes where uniqueness='unique'
5、查詢表的索引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'
6、查詢表的主鍵
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'
7、查詢表的唯一性約束(包括名稱,構成列):
select column_name from user_cons_columns cu, user_constraints au
where cu.constraint_name=au.constraint_name and cu.table_name='node'
8、查詢表的外來鍵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 = 外來鍵引用表的鍵名
9、查詢表的所有列及其屬性
方法一: select * from user_tab_columns where table_name=upper('表名');
方法二: select cname,coltype,width from col where tname=upper('表名');
Oracle 常用命令
1 檢視當前所有物件 sql select from tab 2 建乙個和a表結構一樣的空表 sql create table b as select from a where 1 2 sql create table b b1,b2,b3 as select a1,a2,a3 from a whe...
oracle常用命令
create insert delete select 建立使用者必須在sys超級管理員下 連線到超級管理員 conn sys as sysdba sys zhuangyan system zhuangyan scott tiger 查出所有 clerk 辦事員 的姓名及其部門名稱,部門的人數.找出...
oracle 常用命令
建立臨時表空間 02createtemporarytablespace os temp 03tempfile c oracle product 10.2.0 oradata os temp.dbf 04size100m 05autoextendon 06next100m maxsize 1024m ...