您好,登錄后才能下訂單哦!
這篇文章主要介紹如何使用SQL語句查詢MySQL,SQLServer,Oracle所有數(shù)據(jù)庫名和表名,字段名,文中介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們一定要看完!
MySQL中查詢所有數(shù)據(jù)庫名和表名
查詢所有數(shù)據(jù)庫
show databases;
查詢指定數(shù)據(jù)庫中所有表名
select table_name from information_schema.tables where table_schema='database_name' and table_type='base table';
查詢指定表中的所有字段名
select column_name from information_schema.columns where table_schema='database_name' and table_name='table_name';
查詢指定表中的所有字段名和字段類型
select column_name,data_type from information_schema.columns where table_schema='database_name' and table_name='table_name';
SQLServer中查詢所有數(shù)據(jù)庫名和表名
查詢所有數(shù)據(jù)庫
select * from sysdatabases;
查詢當前數(shù)據(jù)庫中所有表名
select * from sysobjects where xtype='U'; xtype='U':表示所有用戶表,xtype='S':表示所有系統(tǒng)表。
查詢指定表中的所有字段名
select name from syscolumns where id=Object_Id('table_name');
查詢指定表中的所有字段名和字段類型
select sc.name,st.name from syscolumns sc,systypes st where sc.xtype=st.xtype and sc.id in(select id from sysobjects where xtype='U' and name='table_name');
Oracle中查詢所有數(shù)據(jù)庫名和表名
查詢所有數(shù)據(jù)庫
由于Oralce沒有庫名,只有表空間,所以Oracle沒有提供數(shù)據(jù)庫名稱查詢支持,只提供了表空間名稱查詢。
select * from v$tablespace;--查詢表空間(需要一定權限)
查詢當前數(shù)據(jù)庫中所有表名
select * from user_tables;
查詢指定表中的所有字段名
select column_name from user_tab_columns where table_name = 'table_name';--表名要全大寫
查詢指定表中的所有字段名和字段類型
select column_name, data_type from user_tab_columns where table_name = 'table_name';-
使用SQL語句查詢MySQL,SQLServer,Oracle所有數(shù)據(jù)庫名和表名,字段名的SQL語句,簡單明了
以上是“如何使用SQL語句查詢MySQL,SQLServer,Oracle所有數(shù)據(jù)庫名和表名,字段名”這篇文章的所有內容,感謝各位的閱讀!希望分享的內容對大家有幫助,更多相關知識,歡迎關注億速云行業(yè)資訊頻道!
免責聲明:本站發(fā)布的內容(圖片、視頻和文字)以原創(chuàng)、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關證據(jù),一經查實,將立刻刪除涉嫌侵權內容。