当我登录sql server时。我看到许多数据库,但没有访问某些数据库。所以我只想列出使用链接名称访问数据库。我想运行这段代码
select name
FROM [linkedname].sys.sysdatabases
WHERE HAS_DBACCESS(name) = 1"
答案 0 :(得分:0)
MySQL
SELECT name, HAS_DBACCESS(name) FROM sys.databases;
SQL Server
SHOW GRANTS FOR 'jeffrey'@'localhost';
或以下任何一种方式
SHOW GRANTS;
SHOW GRANTS FOR CURRENT_USER;
SHOW GRANTS FOR CURRENT_USER();
结果
+------------------------------------------------------------------+
| Grants for jeffrey@localhost |
+------------------------------------------------------------------+
| GRANT USAGE ON *.* TO `jeffrey`@`localhost` |
| GRANT SELECT, INSERT, UPDATE ON `db1`.* TO `jeffrey`@`localhost` |
+------------------------------------------------------------------+
参考文献:dev.mysql.com
答案 1 :(得分:0)
您可以找到您有权访问的数据库列表。
SELECT name
FROM sys.sysdatabases
WHERE HAS_DBACCESS(name) = 1