這個問題,在之前就有寫過,但是想找到語句還是記不得,這里主要提及我自己有用到的數據庫mysql和oracle
1、mysql
這個是自己安裝的,所有配置都是默認配置沒有改變,所以保存表名的表還是information_schema.tables,語句如下:
--獲取數據庫中所有用戶名,表名 select table_schema 用戶名,table_name 表名 from information_schema.tables --獲取'test'用戶下所有表 select table_schema 用戶名,table_name 表名 from information_schema.tables where table_schema='test' --判斷'test'用戶下是否有'user'表 select * from information_schema.tables where table_schema='test' and table_name='user' --在mysql里面表名、用戶名可以不區分大小寫,譬如下面語句也可以查詢出結果 select * from information_schema.tables where table_schema='TEST' and table_name='uSer'
2、Oracle
這個不是我的數據庫,而oralce中保存表名的表在網上也是眾說紛紜,我最終找到的表是all_tables,而且它保存的表名作為字符串是區分大小寫的
--取某個表 select * from all_tables WHERE upper(OWNER) LIKE '用戶名大寫' AND upper(TABLE_NAME) LIKE '表名大寫' --取庫中所有表 select * from all_tables select * from all_tables@想要的遠程庫