I need to get the list of databases from a Firebird server in a computer. I want to select and backup whichever database I want. Microsoft SQL Server has that feature, I think you can see the databases connect a server. Is there such thing in Firebird? Or is there a workaround? I am working with Firebird 2.5, but if there is a version it is possible you can let me know.
-
I don't think so. To connect to a database you can use the servername and the path to the database in the filesystemof that server. So the server does not know anything about potentially existing databases until there is actually someone connecting to it. So it might be possible to find out what databases are currently in use (someone is connected to it) but not to what databases the server can possibly connect to and surface for a client. – Ralf Feb 03 '21 at 16:16
2 Answers
Firebird has no feature to list databases, because technically Firebird doesn't know which databases exist on a server (except those defined in aliases.conf/databases.conf, but those aren't exposed either).
For Firebird, a database is defined entirely by a database file that is either referenced by a full file path or an alias (which points to a file path). If the file exists, the Firebird process has sufficient access rights to the file, and the file has an On-Disk Structure (ODS) the server understands, you can connect to it.
This is different from SQL Server, where the server holds a list of databases, and you can only connect to databases defined in that list.

- 100,966
- 191
- 140
- 197
-
Hey so can i ask another question ? In microsoft sql there is for example database named temp and there cant be another database named temp but since FirebirdSQL doesn't hold databases in somewhere for listing or whatever. Can there be multiple databases with same name in fb ? – Icarsel Feb 03 '21 at 16:30
-
@lcarsel - database name is (local) file name. Can you have many different files with one and exactly the same path and name??? | There can be a flat list in `aliases.conf` (FB1/FB2) or `databases/conf` text file, but this is optional helper feature, so technically you can for every database have two connection strings, one via RAW file name and one via alias. And yes, AFAIR there is no spacial rules for alias tokens, so using alias crafted to match a local filename, one can even shadow some other database. – Arioch 'The Feb 04 '21 at 07:21
-
@lcarsel No, you can't have multiple databases with the same name, because a database connectiong string either directly, or indirectly through an alias or relative path, points to a specific file on the filesystem of the database server. On the other hand, it is possible that multiple distinct connection strings point to a single database file (eg an absolute path, a relative path, alias(es) and maybe through symbolic links). – Mark Rotteveel Feb 04 '21 at 14:26
Although Firebird does not keep track of databases like SQL Server, you might be able to accomplish what you want some other way. You said you want to pick and choose the database to backup. Do you have an off the shelve application to perform the backup, or will you develop one? Another question is if your databases are somewhat static, or do the databases on a particular server stay somewhat the same?
If the list of databases stays somewhat static and you will be developing a UI to perform/submit the database backup, I would do something like the following.
Create a database that will contain a table containing connection strings of the databases that you want backed up. Granted the table will need to be amended when you add/remove databases. Develop your UI to look to this table to pick the database to backup.
I've done something similar in the past. In my case it was poor-mans schema backup. I had a database contain and table of the relevant database connection strings, and I wrote an app that would iterate over that table list and connect to those databases and then perform metadata extracts, and then parse out the metadata extracts into individual objects and then pull in the individual objects into another database to store the schema.

- 100,966
- 191
- 140
- 197

- 1,510
- 10
- 14
-
Actually, i am not developing this system for my own use but for client use , so making the client add all the databases to a database is not what i am looking for i just want to get every database presented at client without client telling me anything and then from this list of db client selects the one he/she wants also program needs to work if selected db change location deleted copied somewhere else etc. so i am little bit stuck with Firebird in this but anyways thanks for you answer i will look into the ideas you gave thanks a lot !! – Icarsel Feb 06 '21 at 19:05