on ‎2011 Apr 04 5:06 PM
What sql query can give me name of all databases ? Like for Sqlserver it is SELECT NAME FROM SYS.DATABASES and for Mysql we can use SHOW DATABASES. I need to run this sql via a jdbc call.
Thanks!
Request clarification before answering.
Note that unlike some of the other RDBMSes, SQL Anywhere does not have a "master database" so you cannot get a list of all databases that are on a computer.
Once you are connected to a server you can get the list of all databases running on the server to which you are connected by using
select db_name( number ) from sa_db_list();
See the documentation for more information.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I think Mark's select would do the same but show it in rows rather than columns (and without the risk of you trying to query a database that wasn't in the results from sa_db_list), the problem I have is sa_db_list() is only returning one database.
Unless (as I said before) I'm missing something simple.
This will only show you databases running on the current engine/server. If you have multiple instances of SQL Anywhere running, they will need to be queried per-server.
| User | Count |
|---|---|
| 8 | |
| 5 | |
| 4 | |
| 4 | |
| 3 | |
| 3 | |
| 2 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.