2MySQL資料庫查詢帶有某個欄位的所有表名:(1)精確查詢語句如下:SELECT * FROM information_schema.columns WHERE column_name="column_name";(2)模糊匹配查詢SELECT * FROM information_schema.columns WHERE column_name LIKE "%column_name%";
3Oracle資料庫查詢帶有某個欄位的所有表名:(1)精確查詢語句如下:SELECT column_name,table_name FROM user_tab_columns WHERE column_name="column_name";(2)模糊匹配查詢SELECT column_name,table_name,FROM user_tab_columns WHERE column_name LIKE "%column_name%";
4SQLServer資料庫查詢帶有某個欄位的所有表名:(1)精確查詢語句如下:SELECT [name] FROM [庫名].[dbo].sysobjects WHERE id IN (SELECT id FROM [庫名].[dbo].syscolumns WHERE name = "欄位名")(2)模糊匹配查詢SELECT [name] FROM [庫名].[dbo].sysobjects WHERE id IN (SELECT id FROM [庫名].[dbo].syscolumns WHERE name LIKE "%欄位名%")
1SQL是一種標準,但是大部分 SQL 資料庫程式都擁有它們自己的私有擴充套件!每個資料庫使用SQL語句查詢資料庫中帶有某個欄位的所有表名也不相同,下面分別以 MySQL、Oracle、SQLServer 查詢語句與大家分享。
2MySQL資料庫查詢帶有某個欄位的所有表名:(1)精確查詢語句如下:SELECT * FROM information_schema.columns WHERE column_name="column_name";(2)模糊匹配查詢SELECT * FROM information_schema.columns WHERE column_name LIKE "%column_name%";
3Oracle資料庫查詢帶有某個欄位的所有表名:(1)精確查詢語句如下:SELECT column_name,table_name FROM user_tab_columns WHERE column_name="column_name";(2)模糊匹配查詢SELECT column_name,table_name,FROM user_tab_columns WHERE column_name LIKE "%column_name%";
4SQLServer資料庫查詢帶有某個欄位的所有表名:(1)精確查詢語句如下:SELECT [name] FROM [庫名].[dbo].sysobjects WHERE id IN (SELECT id FROM [庫名].[dbo].syscolumns WHERE name = "欄位名")(2)模糊匹配查詢SELECT [name] FROM [庫名].[dbo].sysobjects WHERE id IN (SELECT id FROM [庫名].[dbo].syscolumns WHERE name LIKE "%欄位名%")