How to find the current database server name with SQL?
Posted in 2008
Topics: Storage & Space Management, Networking & sqlhosts Configuration
I want to know if there is a better way to find the name of the
current database name with SQL.
select dbservername, dbsname from sysmaster:systabnames st, systablest where t.tabid = 1 and t.partnum = st.partnum ;
was the one that I came up with but it seems like there should be
something akin to
dbservername which gives you the instance name, but I couldn't find
it.
Here are all of the dbinfo things that I found:
|--DBINFO------------------------------------------------------->
>--(--+-'dbspace'--,--+-tblspace_num-+-----------------------------------+--)--|
| '-
expression---' |
+-+-'sqlca.sqlerrd1'-
+---------------------------------------------+
|
'-'sqlca.sqlerrd2'-' |
|
(1) |
'------+-'sessionid'---------------------------------------------
+-'
+-'dbhostname'--------------------------------------------
+
+-+-'version'--,--'specifier'-+---------------------------
+
| '-'serial8'-----------------'
|
| (2)
|
'------+-'coserverid'-----------------------------------
+-'
+-'coserverid'--,--table.column--,--'currentrow'-+
'-'dbspace'--,--table.column--,--'currentrow'----'
dbinfo-dbspace
dbinfo-sessionid
dbinfo-serial8
dbinfo-dbhostname
dbinfo-sqlca.sqlerrd1
dbinfo-sqlca.sqlerrd2
dbinfo-utc_to_datetime
dbinfo-utc_current
dbinfo-get_tz
dbinfo-version
dbinfo-version
dbinfo-version
dbinfo-version
dbinfo-version
dbinfo-version
dbservername
server_info
sitename
are some of the things that I found but I couldn't find a database one.
This is not necessarily better:
select odb_dbname
from sysmaster:sysopendb
where odb_sessionid = dbinfo('sessionid')
and odb_dbname <> 'sysmaster'
> -----Original Message-----
> From: informix-list-bounces@iiug.org
> [mailto:informix-list-bounces@iiug.org]On Behalf Of bozon
> Sent: Thursday, June 05, 2008 9:44 AM
> To: informix-list@iiug.org
> Subject: How to find the current database server name with SQL?
>
>
> I want to know if there is a better way to find the name of the
> current database name with SQL.
>
> select dbservername, dbsname from sysmaster:systabnames st, systables> t where t.tabid = 1 and t.partnum = st.partnum ;
>
> was the one that I came up with but it seems like there should be
> something akin to
>
> dbservername which gives you the instance name, but I couldn't find
> it.
>
> Here are all of the dbinfo things that I found:
>
> |--DBINFO------------------------------------------------------->
>
> >--(--+-'dbspace'--,--+-tblspace_num-+------------------------
> -----------+--)--|
> | '-
> expression---' |
> +-+-'sqlca.sqlerrd1'-
> +---------------------------------------------+
> |
> '-'sqlca.sqlerrd2'-' |
> |
> (1) |
>
> '------+-'sessionid'---------------------------------------------
> +-'
>
> +-'dbhostname'--------------------------------------------
> +
>
> +-+-'version'--,--'specifier'-+---------------------------
> +
> | '-'serial8'-----------------'
> |
> | (2)
> |
> '------+-'coserverid'-----------------------------------
> +-'
> +-'coserverid'--,--table.column--,--'currentrow'-+
> '-'dbspace'--,--table.column--,--'currentrow'----'
>
> dbinfo-dbspace
> dbinfo-sessionid
> dbinfo-serial8
> dbinfo-dbhostname
> dbinfo-sqlca.sqlerrd1
> dbinfo-sqlca.sqlerrd2
> dbinfo-utc_to_datetime
> dbinfo-utc_current
> dbinfo-get_tz
> dbinfo-version
> dbinfo-version
> dbinfo-version
> dbinfo-version
> dbinfo-version
> dbinfo-version
>
> dbservername
> server_info
> sitename
>
> are some of the things that I found but I couldn't find a
> database one.
> _______________________________________________
> Informix-list mailing list
> Informix-list@iiug.org
> http://www.iiug.org/mailman/listinfo/informix-list
>
Notice of Confidentiality: **This E-mail and any of its attachments may contain
Lincoln National Corporation proprietary information, which is privileged, confidential,
or subject to copyright belonging to the Lincoln National Corporation family of
companies. This E-mail is intended solely for the use of the individual or entity to
which it is addressed. If you are not the intended recipient of this E-mail, you are
hereby notified that any dissemination, distribution, copying, or action taken in
relation to the contents of and attachments to this E-mail is strictly prohibited
and may be unlawful. If you have received this E-mail in error, please notify the
sender immediately and permanently delete the original and any copy of this E-mail
and any printout. Thank You.**
On 5 Чер, 15:44, bozon <cur...@crowson1.com> wrote: > I want to know if there is a better way to find the name of the > current database name with SQL. select 'database ' || trim(odb_dbname) || ';' from sysmaster:sysopendb where odb_sessionid=dbinfo('sessionid') and odb_iscurrent='Y';