If you only look at Unix implementations, you'll get some interesting ideas about how ODBC works. None of these implementations are 100% comparable to the reference implementation on Windows, produced by the maintainer of the ODBC spec, i.e., Microsoft.
There are two ODBC driver managers commonly found on Unix. iODBC, whose documentation relevant to this question is here, is maintained and supported by my employer. UnixODBC is the other, and was discussed in other answers. These are meant to be API equivalent to each other and to the Windows implementation, as both are platform-agnostic implementations of the standard.
In simple terms, odbcinst.ini
is a registry and configuration file for ODBC drivers in an environment, while odbc.ini
is a registry and configuration file for ODBC DSNs (Data Source Names), typically based on drivers registered in the other.
You had a few specific questions...
1) I have a line Driver = /path/to/file/.so
in both files and the values sometimes differ. Does this even make sense? If so, which prevails?
The Driver = /path/to/file.so
should generally be the same in both files when both are expressed as paths. In odbc.ini
, this entry may instead be Driver = {name of driver}
where the name is as indexed in odbcinst.ini
. Generally speaking, settings in odbc.ini
prevail over conflicting settings in odbcinst.ini
if such exist.
2) Is odbcinst.ini
a JavaScript-like "prototype" for odbc.ini
? In other words, if I am creating a number of DSNs with common settings, can I promote common settings from odbc.ini
into odbcinst.ini
?
No, odbcinst.ini
is not a "prototype" in this way. odbcinst.ini
settings are relevant to the driver, but not to the DSNs based on that driver.
3) What is the difference between Driver
and Setup
in odbcinst.ini
? They seem to have the same values. Are these settings database-specific or are they universal?
In odbcinst.ini
, the Driver =
refers to the driver library, and Setup =
to the setup library. The latter is entirely optional, and when it does exist, it may but need not be used during a data connection; it is primarily intended for use by an ODBC Administrator when "setting up" such connections, to be saved as DSNs. Sometimes, these libraries are found in the same physical file, but they need not be, and, for instance, are typically not in the OS X environment.