1SQL是一種標(biāo)準(zhǔn),但是大部分 SQL 數(shù)據(jù)庫程序都擁有它們自己的私有擴展!每個數(shù)據(jù)庫使用SQL語句查詢數(shù)據(jù)庫中帶有某個字段的所有表名也不相同,下面分別以 MySQL、Oracle、SQLServer 查詢語句與大家分享。
2MySQL數(shù)據(jù)庫查詢帶有某個字段的所有表名:(1)精確查詢語句如下:SELECT * FROM information_schema.columns WHERE column_name='column_name';(2)模糊匹配查詢SELECT * FROM information_schema.columns WHERE column_name LIKE '%column_name%';
3Oracle數(shù)據(jù)庫查詢帶有某個字段的所有表名:(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數(shù)據(jù)庫查詢帶有某個字段的所有表名:(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 '%字段名%')