欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

使用SQL查詢所有數(shù)據(jù)庫名和表名問題

 更新時間:2022年11月22日 08:54:22   作者:思想永無止境  
這篇文章主要介紹了使用SQL查詢所有數(shù)據(jù)庫名和表名問題,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教

MySQL中查詢所有數(shù)據(jù)庫名和表名

查詢所有數(shù)據(jù)庫

show databases;

查詢指定數(shù)據(jù)庫中所有表名

方法一、

use 數(shù)據(jù)庫名

show tables;

方法二、

select table_name from information_schema.tables where table_schema='數(shù)據(jù)庫名' and table_type='BASE TABLE';

查詢指定表中的所有字段名

select column_name from information_schema.columns where table_schema='數(shù)據(jù)庫名' and table_name='表名';

查詢指定表中的所有字段名和字段類型

show create table 表名;

或者

select column_name,data_type from information_schema.columns where table_schema='數(shù)據(jù)庫名' and 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';--表名要全大寫

以上為個人經(jīng)驗,希望能給大家一個參考,也希望大家多多支持腳本之家。

相關文章

最新評論