使用SQL查詢所有資料庫名和表名及欄位名

2021-10-06 04:37:15 字數 1724 閱讀 1619

oracle中查詢所有資料庫名和表名

1.查詢所有資料庫

由於oralce沒有庫名,只有表空間,所以oracle沒有提供資料庫名稱查詢支援,只提供了表空間名稱查詢。

select * from v$tablespace;--查詢表空間(需要一定許可權)

2.查詢當前資料庫中所有表名

select * from user_tables;

3.查詢指定表中的所有欄位名

select column_name from user_tab_columns where table_name = 'table_name';--表名要全大寫

4.查詢指定表中的所有欄位名和字段型別

select column_name, data_type from user_tab_columns where table_name = 'table_name';--表名要全大寫

mysql中查詢所有資料庫名和表名

1.查詢所有資料庫

show databases;

2.查詢指定資料庫中所有表名

select table_name from information_schema.tables where table_schema='database_name' and table_type='base table';

3.查詢指定表中的所有欄位名

select column_name from information_schema.columns where table_schema='database_name' and table_name='table_name';

4.查詢指定表中的所有欄位名和字段型別

select column_name,data_type from information_schema.columns where table_schema='database_name' and table_name='table_name';

sqlserver中查詢所有資料庫名和表名

1.查詢所有資料庫

select * from sysdatabases;

2.查詢當前資料庫中所有表名

select * from sysobjects where xtype='u';

xtype='u':表示所有使用者表,xtype='s':表示所有系統表。

3.查詢指定表中的所有欄位名

select name from syscolumns where id=object_id('table_name');

4.查詢指定表中的所有欄位名和字段型別

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');

出處:你所做的一切努力並不會立即給你想要的一切,但可以讓你逐漸成為你想成為的那一種人!

使用SQL查詢所有資料庫名和表名

show databases select table name from information schema.tables where table schema database name and table type base table select column name from inf...

使用SQL查詢所有資料庫名和表名

show databases select table name from information schema.tables where table schema database name andtable type base table select column name from info...

列出MSSQL所有資料庫名 所有表名 所有欄位名

列出mssql所有資料庫名 所有表名 所有欄位名 1.獲取所有資料庫名 select name from master.sysdatabases order by name 2.獲取所有表名 select name from sysobjects where xtype u order by nam...