Server name vs database name - confused

Hi All,
I am looking at the API for OracleDataSource, this is what the docs say:
databaseName String Name of the particular database on the server. Also known as the SID in Oracle terminology.
serverName String Name of the database server
I know the databaseName and also can find it using select name from v$database;
But how do I find the server name? Any file or command which can be used to find this info?
Thanks in advance

one server....
SQL> select host_name servername,instance_name sid from v$instance;
SERVERNAME SID
hostname DB

Similar Messages

  • Restore 9i Database to Another Server but Same Database Name

    hi experts,
    This is 9i on Windows.
    I want to restore my RMAN backup from production server to my test server.
    I know the db names have to be the same for RMAN to work.
    Can I restore from my full backup -- test server, then change the db name on the test server? The database name on test needs to be different to prevent someone from accidentally connecting to test but thinking it is production.
    Is this possible to do?
    Again, 9i on Windows.
    Thanks, John

    Hi piontkdd
    I do this in 9i all time, without using duplicate.
    General idea:
    Copy rman backups to test server
    create dummy init.ora with production database name.
    if you want, SET NEWNAME for different filesystem and restore datafiles.
    Recover database. Open database.
    alter database rename global_name to 'whatever'
    shutdown and then mount. use nid.sh to change the DBID and Database name (Can't remember how you do this on windows). shutdown and set up your new spfile/init.ora and change your services with oradim.exe
    could you elaborate the same steps i have the scenario to make sure my production database works fine in case of any disaster , on the production machine itself i have to restore database.
    Oracle=9.2 Solaris=9 Veritas=6.0
    Regards

  • How can i identify the environment name or database name in the PL/SQL code

    Hi,
    I am using UTL_FILE to genearate the files.,
    My problem is, I have to design the common sql file , which can be executed in 2 diffrent environments ( Say QA & DEV ) , with no parameters. It has to identify the environment and based on the environment , it has to generate the concern files.,
    The only change needs to be incorporated is , file names , which will change based on the environment.,
    can nay one tell me , how can i identify the environment name or database name in the PL/SQL code ??
    Raja

    In this case, USEC_GI_DEV.NA.XXXNET.NET is a TNS alias. That alias exists only on the client machine. There is no way to access that information on the database server.
    You would have to find something in the v$database or v$instance table that uniquely identifies the database (and you may need some help from the DBAs to do this because you need to ensure that the data element you choose is compatible with whatever refresh process(es) are used in your environment).
    Now, if you are writing a stand-alone SQL*Plus script, SQL*Plus, as a client tool, does have access to the TNS alias in later versions. But that is a client-side determination, not a server-side determination.
    Justin

  • SQL1013N  The database alias name or database name "FCS" could not be found

    Hi All,
    Solution manager is running on win2003 server with db2 database.When i m trying to connect db2 from command promt i m getting error.I m following these step.
    1.Loging with db2 user
    2.In command promt when i m tring to check the cfg file getting error.
    DB2 get db cfg for fcs.
    SQL1013N  The database alias name or database name "FCS" could not be found.
    SQLSTATE=42705
    I m pasting the snapshot of of database manager.
    C:\>db2 get snapshot for dbm
                Database Manager Snapshot
    Node name                                      =
    Node type                                      = Enterprise Server Edition with
    local and remote clients
    Instance name                                  = DB2
    Number of database partitions in DB2 instance  = 1
    Database manager status                        = Active
    Product name                                   = DB2 v9.1.600.703
    Service level                                  = s081007 (WR21415)
    Private Sort heap allocated                    = 0
    Private Sort heap high water mark        = 0
    Post threshold sorts                                = Not Collected
    Piped sorts requested                          = 0
    Piped sorts accepted                           = 0
    Start Database Manager timestamp      = 07/29/2010 11:35:25.534766
    Last reset timestamp                           =
    Snapshot timestamp                             = 08/03/2010 18:43:14.492590
    Remote connections to db manager               = 0
    Remote connections executing in db manager     = 0
    Local connections                              = 0
    Local connections executing in db manager      = 0
    Active local databases                         = 0
    High water mark for agents registered          = 2
    High water mark for agents waiting for a token = 0
    Agents registered                              = 2
    Agents waiting for a token                     = 0
    Idle agents                                    = 0
    Committed private Memory (Bytes)               = 11141120
    Switch list for db partition number 0
    Buffer Pool Activity Information  (BUFFERPOOL) = OFF
    Lock Information                        (LOCK) = OFF
    Sorting Information                     (SORT) = OFF
    SQL Statement Information          (STATEMENT) = OFF
    Table Activity Information             (TABLE) = OFF
    Take Timestamp Information         (TIMESTAMP) = ON  07/29/2010 11:35:25.534766
    Unit of Work Information                 (UOW) = OFF
    Agents assigned from pool                      = 2542
    Agents created from empty pool                 = 4
    Agents stolen from another application         = 0
    High water mark for coordinating agents        = 2
    Max agents overflow                            = 0
    Hash joins after heap threshold exceeded       = 0
    Total number of gateway connections            = 0
    Current number of gateway connections          = 0
    Gateway connections waiting for host reply     = 0
    Gateway connections waiting for client request = 0
    Gateway connection pool agents stolen          = 0
    Memory usage for database manager:
        Memory Pool Type                           = Database Monitor Heap
           Current size (bytes)                    = 65536
           High water mark (bytes)                 = 65536
           Configured size (bytes)                 = 327680
        Memory Pool Type                           = Other Memory
           Current size (bytes)                    = 10092544
           High water mark (bytes)                 = 10092544
           Configured size (bytes)                 = 4292870144
    KIndly suggest me where i m getting wrong.
    REgards

    Dear Sir,
           Please check the DB2DART log
    Command line output:
    C:\Users\Administrator.MAXXMOBILEDLH>db2dart db2smn /CHST /WHAT DBBP OFF
                        DB2DART Processing completed with error!
                            Complete DB2DART report found in:
    C:\PROGRAMDATA\IBM\DB2\DB2COPY1\DB2\DART0000\DB2SMN.RPT
    db2smn.rpt:
    Error: Failed sqledosd API on open system database directory.
    SQL1057W  The system database directory is empty.
    Error: This phase encountered an error and did not complete.
                        DB2DART Processing completed with error!
                                      WARNING:                       
                        The inspection phase did not complete!        
                            Complete DB2DART report found in:
    C:\PROGRAMDATA\IBM\DB2\DB2COPY1\DB2\DART0000\DB2SMN.RPT
        _______    D A R T    P R O C E S S I N G    C O M P L E T E    _______"
    Please help me to sort out this issue!!
    Our Solution Manager is down.
    Regards!!!

  • Refresh tool and table name containing database name in Mysql

    Hi,
    when refreshing the database schema and my table name contains a database name (for example "my_other_db.my_other_table"), the refresh tool never sees weather "my_other_db.my_other_table" already exists or not. so it always generates a create-table-statement (which is syntactically correct, but of course fails, because that table exists already).
    Is there known workaround for it? I am using Mysql 5.0.x, jdbc driver 5.0.7, Kodo 4.1.4 (but this problem was there before).
    Right now i'm deleting the database names from my package.jdo-files, then doing the refresh command and after that i put back the database names. At runtime Kodo works very well with the database name before the table name.
    Thanks very much,
    Markus

    1. For WBS element under consideration, get OBJNR from PRPS table
    2. Get PO numbers from COEP where OBJNR = PRPS-OBJNR obtained in step 1

  • Service name and database name are different.

    Hi,
    I had created a database with name PROD, latter i changed DB name to PRODT as per management request.
    But i notice the following things.
    1. At OS level ORACLE_SID variable is still PROD.(.bash_profile too have this entries)
    2. From sql prompt DB_NAME is PRODT.
    3. In Listener service name is showing PRODT and instance name is PROD.
    can any one please explain me, why oracle is behaving like this.
    Our all the applications are working fine with out any issues till now.
    [oracle@qual ~]$ echo $ORACLE_SID
    PROD
    [oracle@qual ~]$ sqlplus '/ as sysdba'
    SQL*Plus: Release 10.2.0.1.0 - Production on Tue Mar 5 10:35:01 2013
    Copyright (c) 1982, 2005, Oracle. All rights reserved.
    Connected to an idle instance.
    SQL> startup
    ORACLE instance started.
    Total System Global Area 608174080 bytes
    Fixed Size 1220868 bytes
    Variable Size 209719036 bytes
    Database Buffers 394264576 bytes
    Redo Buffers 2969600 bytes
    Database mounted.
    Database opened.
    SQL> select name from v$database;
    NAME
    PRODT
    SQL> !lsnrctl status
    LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 05-MAR-2013 10:38:30
    Copyright (c) 1991, 2005, Oracle. All rights reserved.
    Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=qual.com)(PORT=1521)))
    STATUS of the LISTENER
    Alias LISTENER
    Version TNSLSNR for Linux: Version 10.2.0.1.0 - Production
    Start Date 05-MAR-2013 10:36:54
    Uptime 0 days 0 hr. 1 min. 35 sec
    Trace Level off
    Security ON: Local OS Authentication
    SNMP OFF
    Listener Parameter File /u001/app/oracle/product/10.2.0/network/admin/listener.ora
    Listener Log File /u001/app/oracle/product/10.2.0/network/log/listener.log
    Listening Endpoints Summary...
    (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=qual.com)(PORT=1521)))
    (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC0)))
    Services Summary...
    Service "PLSExtProc" has 1 instance(s).
    Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
    Service "PRODT" has 1 instance(s).
    Instance "PROD", status READY, has 2 handler(s) for this service...
    Service "PRODT_XPT" has 1 instance(s).
    Instance "PROD", status READY, has 2 handler(s) for this service...
    The command completed successfully
    SQL> exit
    Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
    With the Partitioning, OLAP and Data Mining options
    [oracle@qual ~]$

    Hello,
    I had created a database with name PROD, latter i changed DB name to PRODT as per management request.Using NID ?
    But i notice the following things.
    1. At OS level ORACLE_SID variable is still PROD.(.bash_profile too have this entries)ORACLE_SID is the instance name. Changing DB name does not change the instance name. You can manually change it by creating a new PFILE/SPFILE and Password file for the new instance.
    2. From sql prompt DB_NAME is PRODT.Yes, as you have changed the DB name from PROD to PRODT.
    3. In Listener service name is showing PRODT and instance name is PROD.Database name is PRODT and the instance associated with it is PROD. There can be multiple instances for a single database.
    Regards,
    Shivananda

  • Can we enable Database Name box while scheduling report

    Hi, I am boxi administrator and I am working on a unique client requirement. I don't know if it needs to be in administration forum or crystal reports.   we are using crystal reports  and  We are on boxi R2 SP3 on IIS.
    We have 8 DB servers for load balancing ( look www.intersystems.com for details of how). We want to publish report in BOXI and user will then schedule report. We don't want multiple copies as it will be difficult to maintain at several places. So please rule out the possibility of  8 copies of same Crystal report connected to each 8 DB servers.
    When user schedules report then we want to load balance the DB servers i.e. we have defined 8 ODBC connections on each application servers and want to use all ODBC ( DB) for each report. When we schedule reports then I see server name and Database name is disabled in Database logon properties.
    Please let me know if this  is possible. We will be using standard infoview to schedule reports.
    Thanks,

    This is not feasible. I figured out one option that is using Virtual IP with Load balancer. We can load balance ODBC using this. This is tested in another project of state govt.
    Thanks,

  • Change database name - Crystal10 and Visual Studio 2005

    <p>Hi there,</p>
    <p>
    I have about 150 crystal reports in my development environment. I need to move them into the testing environment. Every environment has its own database and every database is names '[client name]_[environment]' so I get things like client1_dev, client1_test, client1_prod, etc. The reports are very, very unhappy when moving from dev to test. I have googled this a fair bit and have attempted the stuff on:
    </p>
    http://www.codeproject.com/KB/aspnet/crystalwithaspdotnet.aspx
    <br/>
    http://www.tek-tips.com/faqs.cfm?fid=5374
    <br/>
    <p>
    and a few others and have gotten no where. I spent a couple of days working on this and am now over budget and late. I need a fix and fast.
    </p>
    <p>
    I have two ideas I have been working on and both have failed out right.<br/>
    Idea 1 - during run time:<br/>
      - loop through everything thing in sight and set the database information on it<br/>
      - that one looks like:<br/>
    <br/>
    <pre>
    using CrystalDecisions.Shared;
    using CDCRE = CrystalDecisions.CrystalReports.Engine;
    using CrystalDecisions.CrystalReports.Engine;
    using CrystalDecisions.Web;
    public abstract class ReportBase : Page
         ...snip....
        protected virtual void DoLoad(CrystalReportViewer ReportViewer)
            ReportDocument reportDocument = new ReportDocument();
            SetReportInfo(reportDocument);
            SetParameters(reportDocument);
            DumpParameters(reportDocument);
        protected virtual void SetReportInfo(ReportDocument reportDocument)<br/>
            db_Reports.Reports reportInfo = new ReportsClass();
            CriteriaID = reportInfo.InsertCriteria(CommonUtils.GetLanguagePrefix(), CurrentForm["criteria"].Trim() +
    CurrentForm["extracriteria"].Trim(), CSecuritySession.UserSessionInfo.iUserId, string.Empty, CurrentForm["param1"]);
            ADODB._Recordset rs = reportInfo.GetReportInfo(CommonUtils.GetLanguagePrefix(), ModuleName, ReportID, CSecuritySession.UserSessionInfo.iUserId);
            // report to load
            HttpContext.Current.Trace.Warn("Loading the report", rs.Fields["vReportName"].Value as string);
            reportDocument.Load(rs.Fields["vReportName"].Value as string);
            // connection info
            reportDocument.DataSourceConnections[0].SetConnection(rs.Fields["vSQLServer"].Value as string, rs.Fields["vDatabase"].Value as string, false);
            HttpContext.Current.Trace.Warn("Setting connection information",
                string.Format("Server Name:[{0}] Database Name:[{1}]", reportDocument.DataSourceConnections[0].ServerName, reportDocument.DataSourceConnections[0].DatabaseName));
            // logon info
            reportDocument.DataSourceConnections[0].SetLogon(rs.Fields["vUsername"].Value as string, rs.Fields["vPassword"].Value as string);
            HttpContext.Current.Trace.Warn("Setting Logon Information",
                string.Format("Username: [{0}] Password: [{1}]", reportDocument.DataSourceConnections[0].UserID, reportDocument.DataSourceConnections[0].Password));
            DumpConnInfo(reportDocument);
            DumpSubReportConnInfo(reportDocument);
            // reportname / page title
            ReportName = rs.Fields["vDescription"].Value as string;               
        private void DumpSubReportConnInfo(ReportDocument reportDocument)
            foreach (Section sec in reportDocument.ReportDefinition.Sections)
                foreach (ReportObject ro in sec.ReportObjects)
                    if (ro is SubreportObject)
                        SubreportObject sro = (ro as SubreportObject);
                        DumpConnInfo(sro.OpenSubreport(sro.SubreportName));
        protected virtual void DumpConnInfo(ReportDocument reportDocument)
            foreach(CDCRE.Table table in reportDocument.Database.Tables)
                Trace.Warn(string.Format("Connection info[{0}]", table.Name),
                    string.Format("database: {0} Server: {1} User ID: {2} Pwd: {3}",
                    table.LogOnInfo.ConnectionInfo.DatabaseName,
                    table.LogOnInfo.ConnectionInfo.ServerName,
                    table.LogOnInfo.ConnectionInfo.UserID,
                    table.LogOnInfo.ConnectionInfo.Password));
                foreach(NameValuePair2 nvp in table.LogOnInfo.ConnectionInfo.Attributes.Collection)
                    Trace.Warn("connection attributes", string.Format("{0} = {1}", nvp.Name, nvp.Value));
                    if (string.Compare(nvp.Name as string, "QE_LogonProperties", true) == 0)
                        DbConnectionAttributes dca = nvp.Value as DbConnectionAttributes;
                        Trace.Warn("connection attributes - QE_LogonProperties", "processing the 'QE_LogonProperties'. Is null [" + (null == dca).ToString() + "]" );                   
                        foreach (NameValuePair2 nvp1 in dca.Collection)
                            Trace.Warn("connection attributes - QE_LogonProperties", string.Format("{0} = {1}", nvp1.Name, nvp1.Value));
                Trace.Warn("----------------------");           
        protected virtual void DumpParameters(ReportDocument reportDocument)
            HttpContext.Current.Trace.Write("--------------------------");
            HttpContext.Current.Trace.Write(" Dumping Parameters ");
            HttpContext.Current.Trace.Write("--------------------------");
            for (int i = 0; i < reportDocument.ParameterFields.Count; i++)
                if (string.IsNullOrEmpty(reportDocument.ParameterFields<i>.ReportName))
                    HttpContext.Current.Trace.Write(string.Format("[{0}] {1}", i, reportDocument.ParameterFields<i>.Name), GetParamValue(reportDocument.ParameterFields<i>));
                else
                    HttpContext.Current.Trace.Warn(string.Format("SubReport Parameter [{0}] {1}", i, reportDocument.ParameterFields<i>.Name), GetParamValue(reportDocument.ParameterFields<i>));
            HttpContext.Current.Trace.Write("--------------------------");
    </pre>
    <br/>
      - this one always errors out with a can't find database type connection and spits out the old database message.<br/>
      - as you can see there is a stack of tracing in there. all of the trace messages make it look like it is hitting the right database. I have no clue why this isn't working.<br/>
    <br/>
    Idea 2 - fix up reports before moving to the other environments:<br/>
      - I figured I would write a little app that would crawl through the directories of reports and fix them up<br/>
      - I read a few examples of this online and none of them seem to work with Crystal 10. They work with some of our legacy Crystal 8 reports (I have been testing this all over the place) but not with 10.<br/>
      - the last function is the interesting one.<br/>
      - that one looks like:<br/><br/>
    <pre>
    using System;
    using System.Collections;
    using System.Collections.Generic;
    using System.Text;
    using System.IO;
    using System.Reflection;
    using System.Diagnostics;
    namespace crystal_10_switch
        public class Changer
            protected CRAXDDRT.Application app;
            protected object missing = Missing.Value;
            protected string currentFolder = string.Empty;
            protected string OdbcName;
            protected string DBName;
            protected ICollection Folders;
            public Changer(string OdbcName, string DBName, ICollection Folders)
                this.OdbcName = OdbcName;
                this.DBName = DBName;
                this.Folders = Folders;
                app = new CRAXDDRT.Application();
                string junk = Console.ReadLine();
            public virtual void Switch()
                foreach (string dir in Folders)
                    SwitchDir(dir);
            protected virtual void SwitchDir(string dir)
                DirectoryInfo di = new DirectoryInfo(dir);
                FileInfo[] files = di.GetFiles("*.rpt", SearchOption.AllDirectories);
                currentFolder = di.FullName;
                foreach (FileInfo file in files)
                    Trace.WriteLine("Processing the report: " + file.FullName);
                    Trace.Indent();               
                    SwitchFile(file);
                    Trace.Unindent();
            protected virtual void SwitchFile(FileInfo file)
                CRAXDDRT.Report rpt = app.OpenReport(file.FullName, missing);
                SwitchTable(rpt);
                SwitchSubreports(rpt);
                SaveReport(rpt, file);
            protected virtual void SwitchSubreports(CRAXDDRT.Report rpt)
                Trace.Indent();
                foreach (CRAXDDRT.Section section in rpt.Sections)
                    foreach (CRAXDDRT.IReportObject robj in section.ReportObjects)
                        if (robj is CRAXDDRT.ISubreportObject)
                            CRAXDDRT.ISubreportObject sub = (robj as CRAXDDRT.ISubreportObject);
                            Trace.WriteLine("Processing sub report: " + sub.Name);                       
                            SwitchTable(sub.OpenSubreport());                       
                Trace.Unindent();
            protected virtual void SwitchTable(CRAXDDRT.Report rpt)
                Trace.Indent();
                foreach (CRAXDDRT.IDatabaseTable table in rpt.Database.Tables)
                    Trace.WriteLine(" Processing table: " + table.Name);
                    // this one line should do it
                    (table.ConnectionProperties["Database"] as CRAXDDRT.IConnectionProperty).Value = DBName;
                    // but it didn't so try this
                    (table.ConnectionProperties["UseDSNProperties"] as CRAXDDRT.IConnectionProperty).Value = "1";
                    // read that this 'might' work
                    table.SetLogOnInfo(OdbcName, DBName, missing, missing);
                    // but it didn't so I tried this with the user anme and password set
                    table.SetLogOnInfo(OdbcName, DBName, "XXXXX", "XXXXX");
                    // read that this is requiried, but it does nothing
                    table.Name = table.Name;
                    // this causes issues - the map fields thing pops up which is way not cool
                    //table.Location = table.Name;              
                Trace.Unindent();
        }//class
    }//namespace
    </pre>
    <br/>
    At this point I really don't care which one will work the best, I am just desperate for a working solution. Any help, any at all would be greatly appreciated.<br/>
    <br/>
    Thanks<br/>
    <br/>
    -Cam<br/><br/>

    This is a typical requirement of most application and is relatively trivial to implement. There are a lot of samples and documentation on our support site (links below). Also, search these forums for code snippets that will help you. BTW., do not use the craxDDrt.dll as you are not licensed to use it.
    To look for downloads:
    https://websmp130.sap-ag.de/sap(bD1lbiZjPTAwMQ==)/bc/bsp/spn/bobj_download/main.htm
    Articles:
    https://www.sdn.sap.com/irj/sdn/businessobjects-articles
    Notes:
    https://www.sdn.sap.com/irj/scn/advancedsearch?cat=sdn_ossnotes&query=&adv=true
    Samples:
    https://wiki.sdn.sap.com/wiki/display/BOBJ/CrystalReportsfor.NETSDK+Samples
    Dev. Library and API reference:
    http://help.sap.com/businessobject/product_guides/boexir31/en/crsdk_net_dg_12_en.chm
    http://help.sap.com/businessobject/product_guides/boexir31/en/crsdk_net_apiRef_12_en.chm
    My recommendations:
    https://www.sdn.sap.com/irj/boc/index?rid=/library/uuid/2081b4d9-6864-2b10-f49d-918baefc7a23&overridelayout=true
    https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/208edbbf-671e-2b10-d7b5-9b57a832e427
    https://www.sdn.sap.com/irj/boc/index?rid=/library/uuid/702ab443-6a64-2b10-3683-88eb1c3744bc&overridelayout=true
    Ludek
    Edited by: Ludek Uher on Jul 21, 2009 8:38 AM

  • How to remove database name from SQL query

    We have an MS SQL server with several databases that are of the same schema but have different data.  We do this for testing different environments.  We are using Crystal reports for the first time and we are having trouble changing the database location in the designer.  If update the data source location to the same database server, but different database name, the data still comes from the original database used when creating the report.  We look at the SQL query and it contains the database name and does not change when updating the data source.  Therefore the data always comes from the database used when originally creating the report.
    How can I remove the database name from the SQL query so the proper database is used when testing the report?

    Hi C F
    Please ensure you have followed the procedure mentioned below:
    In Crystal Reports, there are two ways to set the location of the data source your report points to, depending on your connection type.
    For ODBC and Native Connections:
    1. On the 'Database' menu, click 'Set Datasource Location'.
    2. In the 'Current Data Source' section, click the data source to be changed. You must click each individual table in the data source one by one. If the data source is a stored procedure you will not see individual tables.
    NOTE     In Crystal Reports 10, XIR1, and XIR2, if you are mapping from a data source such as a stored procedure where the report designer can not determine which fields should be mapped automatically, you will see a 'Mapping' dialog box where you can manually map fields, as in the procedure cited above.
    3. In the 'Replace with' section, click the data source you want the report to use.
    4. Click 'Update'.
    5. Close the 'Set Datasource Location' window.
    The report now points to the new location.
    For Native Connections Only:
    1. On the 'Database' menu, click 'Set Datasource Location'.
    2. In the 'Current Data Source' section, click 'Properties' to expand it and right-click 'Database Name: <path to database>'.
    3. Click 'Edit' and then type the path to the
    new data source location.
    4. Close the 'Set Datasource Location' window.
    The report now points to the new location.
    Regards
    Girish

  • How to find the logins,program name and databases for a session id?

    I used the following the following query.
    select pr.spid ,pr.dbid,pr.program_name,pr.loginame,ss.session_id,ss.host_name,ss.login_time,db.name from master.dbo.sysprocesses pr,sys.dm_exec_sessions ss,sys.databases db
    where pr.spid = ss.session_id and pr.dbid = db.database_id
    order by ss.login_time desc
    Is spid in master.dbo.sysprocesses the same as session_id in sys.dm_exec_sessions and dbid in master.dbo.sysprocesses the same as database_id in sys.databases?
    My intention is to get the active sessions with the program name,login Name and database name corresponding to the session?

    1)Why you included the clause session_id > 50?
    Sessions with session_id <= 50 are system processes.
    2)Is there any problem with the query I used?
    You query was better than Latheesh's. To wit, his query will only show the database for sessions who are actually running something.
    On SQL 2005 and SQL 2008, this is the best solution:
    SELECT  des.session_id, des.[status], des.login_name,
            d.name AS database_name, des.program_name
    FROM    sys.dm_exec_sessions des
    JOIN    sys.sysprocesses p ON des.session_id = p.spid
    LEFT JOIN sys.databases d ON p.dbid = d.database_id
    WHERE   des.session_id > 50
      AND   p.ecid =0
    ORDER BY des.session_id;
    The condition p.ecid = 0 is needed to weed out extra rows when there are parallism in force.
    On SQL 2012, you don't need sysprocesses, but this works:
    SELECT  des.session_id, des.[status], des.login_name,
            d.name AS database_name, des.program_name
    FROM    sys.dm_exec_sessions des
    LEFT JOIN sys.databases d ON des.database_id = d.database_id
    WHERE   des.session_id > 50
    ORDER BY des.session_id;
    Erland Sommarskog, SQL Server MVP, [email protected]

  • Rman backup and restore on another box with the same database name

    Hi,
    I am using the following script to backup the database, I want to restore the backup on another server with same database name but different datafile locations , Can some one help me in the restoration please.
    #set oracle_sid=LIVE
    run {
    allocate channel t1 type disk;
    backup database plus archivelog delete input format 'D:\Backup\ORACLE\LIVE\df_t%t_s%s_p%p';
    backup current controlfile;
    release channel t1;
    Thanks

    You need to use "set newname" before you restore your database.
    You can refer this http://docs.oracle.com/cd/E11882_01/backup.112/e10642/rcmdupad.htm
    RMAN> connect target /
    connected to target database: TEST (DBID=2033933270)
    RMAN> run
    2> {
    3> startup nomount;
    4> restore controlfile from 'location/DF_T770331608_S104_P1';
    5> alter database mount;
    6> restore database;
    7> recover database;
    8> alter database open resetlogs;
    9> }Also, you have connected to the database TEST, so is the TEST database the new database that you want to create using restore method ?
    If yes, then how the status of the database is OPEN ? The database status should be nomount before you restore the controlfile.
    If the database is not started, then:
    RMAN shows as "connected to target database: TEST (not started)
    If the database is in nomount stage, then
    RMAN shows as "connected to target database: TEST (not mounted)
    If the database is in mount stage, then
    RMAN shows as "connected to target database: TEST (DBID=xxxxxxxx, not open)
    If the database is open mode, then
    RMAN shows as "connected to target database: TEST (DBID=xxxxxx)
    In the output you mentioned, RMAN is showing the status of the database as opened. So if TEST is the database you are creating, then it has to be in nomount stage. In your case, it looks like TEST is the primary database from which you have taken the backup.

  • Confusing with the Global Database Name and Instance Name

    Dear fellow DBA's and Experts,
    Good Day.
    We presently have an existing database registered (on V2 Exadata) with global database name as BIDEV.domainname.com. It has 4 instances viz., BIDEV1 and BIDEV2 which have the same service name as the instance name.
    Last week, on our new X4-2 Exadata, we tried to create a fresh database. While doing so, we entered the details as below in the installer:
    Global Database Name: BIDEV
    SID Prefix: BIDEV
    Service Name: BIDEV.
    Then upon the successful installation of the database, when we query
    1. (SELECT * FROM GLOBAL_NAME), it shows BIDEV as the global database name.
    2.
    SQL> sho parameter service
    NAME                                 TYPE        VALUE
    service_names                        string      BIDEV1
    3. Sho parameter name gives the below details:
    SQL> sho parameter name;
    NAME                                 TYPE        VALUE
    cell_offloadgroup_name               string
    db_file_name_convert                 string
    db_name                              string      BIDEV
    db_unique_name                       string      BIDEV
    global_names                         boolean     FALSE
    instance_name                        string      BIDEV_1
    lock_name_space                      string
    log_file_name_convert                string
    processor_group_name                 string
    service_names                        string      BIDEV1
    Curious to know why it created an instance name as BIDEV_1 instead as BIDEV1.
    Had tried another attempt on our test environment with SID prefix as BIDEV1, then the instance was created with the name as BIDEV1_1.
    Also, would like to know what happen if we give the Global Database Name as BIDEV.domainname.com for installing the same BIDEV database on a different server while the 1st server is still functional.
    Appreciate if someone could throw some light on the above confusion. Any reference material or source to the clarify the doubt.
    Warm Regards,
    Vikram.

    Hi Vikram,
    Your clustered database is not full RAC, it's RAC ONE node database. In RAC ONE node database, instance names are created in that format only (i.e.e dbname_1), I don't know if there is any way we can change it to dbname1. OR if you really want to change the instance name to dbname1 format, then you can convert RAC one node database to Full RAC, then remove instance and add another instance, I hope it would be added in dbname1 format. I have not tested it, test it on your test system first.
    You can find the database type in the output you shared,
    Type: RACOneNode
    Regards,
    Saurabh

  • How do i upload an image to a server and put the name into a database table

    Ok, i found a php image upload script that im using for a cms
    image gallery on my site. But for it to work the way i need to i
    have to have certain information submited into a mysql table at the
    same time. I could just make it so the user types the name of the
    image in a second form, but i would rather not have to as it seems
    a clumsy way to do things and opens things up to typos etc.
    So, i can upload the image ok, and i can upload data to the
    table, but i dont know what I have to do so that the name of the
    uploaded file is automaticly inserted into the mysql table.
    The first bit of code below is the form I am using to upload
    the file to the server. The second bit of code is what I am using
    to tell the server what the file name is.
    How do I combine the 2 form into one? Please help. It is
    driving me to dispair.
    Attach Code
    <form enctype="multipart/form-data" action="uploader.php"
    method="POST">
    <input type="hidden" name="MAX_FILE_SIZE" value="500000"
    />
    Choose a file to upload: <input name="uploadedfile"
    type="file" />
    <br />
    <input type="submit" value="Upload File" />
    </form>
    <form action="<?php echo $editFormAction; ?>"
    method="post" name="form2" id="form2">
    <table align="center">
    <tr valign="baseline">
    <td nowrap="nowrap" align="right">Image One</td>
    <td><input type="text" name="kingsImage1"
    value="<?php echo
    htmlentities($row_rskingscentre['kingsImage1'], ENT_COMPAT,
    'UTF-8'); ?>" size="32" /></td>
    </tr>
    <tr valign="baseline">
    <td nowrap="nowrap" align="right">Image Two</td>
    <td><input type="text" name="kingsImage2"
    value="<?php echo
    htmlentities($row_rskingscentre['kingsImage2'], ENT_COMPAT,
    'UTF-8'); ?>" size="32" /></td>
    </tr>
    <tr valign="baseline">
    <td nowrap="nowrap" align="right">Image
    Three</td>
    <td><input type="text" name="kingsImage3"
    value="<?php echo
    htmlentities($row_rskingscentre['kingsImage3'], ENT_COMPAT,
    'UTF-8'); ?>" size="32" /></td>
    </tr>
    <tr valign="baseline">
    <td nowrap="nowrap"
    align="right"> </td>
    <td><input type="submit" value="Update record"
    /></td>
    </tr>
    </table>
    <p>  </p>
    <p>
    <input type="hidden" name="MM_update" value="form2" />
    <input type="hidden" name="kingsHeader" value="<?php
    echo $row_rskingscentre['kingsHeader']; ?>" />
    </p>
    </form>

    jeffoirecoupe1234 wrote:
    > Ok, i found a php image upload script that im using for
    a cms image gallery on
    > my site. But for it to work the way i need to i have to
    have certain
    > information submited into a mysql table at the same
    time. I could just make it
    > so the user types the name of the image in a second
    form, but i would rather
    > not have to as it seems a clumsy way to do things and
    opens things up to typos
    > etc.
    >
    > So, i can upload the image ok, and i can upload data to
    the table, but i dont
    > know what I have to do so that the name of the uploaded
    file is automaticly
    > inserted into the mysql table.
    >
    > The first bit of code below is the form I am using to
    upload the file to the
    > server. The second bit of code is what I am using to
    tell the server what the
    > file name is.
    >
    > How do I combine the 2 form into one? Please help. It is
    driving me to dispair.
    >
    > Attach Code
    >
    > <form enctype="multipart/form-data"
    action="uploader.php" method="POST">
    > <input type="hidden" name="MAX_FILE_SIZE"
    value="500000" />
    > Choose a file to upload: <input name="uploadedfile"
    type="file" />
    > <br />
    > <input type="submit" value="Upload File" />
    > </form>
    >
    > <form action="<?php echo $editFormAction; ?>"
    method="post" name="form2"
    > id="form2">
    > <table align="center">
    > <tr valign="baseline">
    > <td nowrap="nowrap" align="right">Image
    One</td>
    > <td><input type="text" name="kingsImage1"
    value="<?php echo
    > htmlentities($row_rskingscentre['kingsImage1'],
    ENT_COMPAT, 'UTF-8'); ?>"
    > size="32" /></td>
    > </tr>
    > <tr valign="baseline">
    > <td nowrap="nowrap" align="right">Image
    Two</td>
    > <td><input type="text" name="kingsImage2"
    value="<?php echo
    > htmlentities($row_rskingscentre['kingsImage2'],
    ENT_COMPAT, 'UTF-8'); ?>"
    > size="32" /></td>
    > </tr>
    > <tr valign="baseline">
    > <td nowrap="nowrap" align="right">Image
    Three</td>
    > <td><input type="text" name="kingsImage3"
    value="<?php echo
    > htmlentities($row_rskingscentre['kingsImage3'],
    ENT_COMPAT, 'UTF-8'); ?>"
    > size="32" /></td>
    > </tr>
    > <tr valign="baseline">
    > <td nowrap="nowrap"
    align="right"> </td>
    > <td><input type="submit" value="Update record"
    /></td>
    > </tr>
    > </table>
    > <p>  </p>
    > <p>
    > <input type="hidden" name="MM_update" value="form2"
    />
    > <input type="hidden" name="kingsHeader"
    value="<?php echo
    > $row_rskingscentre['kingsHeader']; ?>" />
    > </p>
    > </form>
    >
    >
    >
    Hi Jeff:
    Though this does not show you how to solve this issue via a
    code
    snippett, there are a couple of extensions at WebAssist.com
    that enable
    you to do this, they are Data Assist and Digital File Pro.
    When you have
    time, take a look at these Solution Recipes (tutorials) that
    show how
    DataAssist is used and then now Digital File Pro is used in
    conjunction
    with DataAssist:
    http://www.webassist.com/professional/products/solutionrecipe/Media_139.asp
    http://www.webassist.com/professional/products/solutionrecipe/Media_112.asp
    DataAssist can be used to save time when you need to build
    database
    search and management applications quickly, and Digital File
    Pro can be
    used to include file upload functionality to your form fields
    while
    enabling you to insert your server file name into the
    database, all on
    the same page.
    enthusiastically,
    mark haynes

  • Can not connect the database via query string (C#). The SQL Server Management Studio is showing the full path of a location instead of database name.

    I can not connect to the database via C#. The database is showing full path of the database file instead of the database name. See the pic: a database showing only name 'emart' and the other database showing the full path.
    : Robby

    Hi,
    According to your post, I know that the database name is showing file path of the database rather than the database name in SQL Server Management Studio. You were not able to
    establish a connection to the database using C#.
    As Olaf said, was any error message thrown out when the connection failed? How did you create these databases?
    You can use the following T-SQL to attach the database and see if the issue persists.
    CREATE DATABASE
    databasename
        ON (FILENAME = 'filepath _Data.mdf'),
        (FILENAME = 'filepath_Log.ldf')
    FOR ATTACH;
    Thanks.
    Tracy Cai
    TechNet Community Support

  • Variable database name in SQL Server query using Oracle database link

    Hi All,
    I have an ApEx 4.1 app running on 11g x64 (11.2.0.1) on Windows Server 2008 x64, and I have some data integration points with a SQL Server (2005 and 2008) that I need to establish. I have configured the database link with dg4odbc and it works beautifully... I can execute queries against the SQL Server database without any problems using the database link.
    However, there is a scenario where the SQL Server database name is dynamic, and I need to generate it on the fly in a PL/SQL block, and then use that in a dynamic SQL query (all of this in ApEx). This is where I run into problems... when I am querying the default database based on the ODBC connection and I don't have to specify the database name, there is no issue. But when I need to access one of several other non-default databases, I keep receiving the "invalid table" error.
    This runs fine:* (note that "fv" is the name of my database link)
    v_query1 := 'select "ReleaseDate" from dbo.Schedules@fv where dbo.Schedules."SchedID" = :schedule';
    EXECUTE IMMEDIATE v_query1 into rel_date using schedule;
    I then take that rel_date variable, convert to a varchar2 (rel_date_char), and then use it as the database name in the next query...
    This returns an error_ (Error ORA-00903: invalid table name)
    v_query2 := 'select "PARTNO" from :rel_date_char.dbo.ProdDetails@fv where "SchedID" = :schedule and "UnitID" = :unit
    and "MasterKey" = :master and "ParentKey" = :parent';
    EXECUTE IMMEDIATE v_query2 into part_number using schedule, unit, master, parent;
    I have also tried using all of the following to no avail:
    'select "PARTNO" from ' || :rel_date_char || '.dbo.ProdDetails@fv where "SchedID"...
    'select "PARTNO" from ' || rel_date_char || '.dbo.ProdDetails@fv where "SchedID"...
    'select "PARTNO" from ' || @rel_date_char || '.dbo.ProdDetails@fv where "SchedID"...
    'select "PARTNO" from @rel_date_char.dbo.ProdDetails@fv where "SchedID"...
    Is there a way to do this in PL/SQL?
    Thanks for any help!
    -Ian C.
    Edited by: 946532 on Jul 15, 2012 7:45 PM

    Just did a test using passthrough:
    SQL> set serveroutput on
    SQL> declare
    2 val varchar2(100);
    3 c integer;
    4 nr integer;
    5 begin
    6 c:= dbms_hs_passthrough.open_cursor@FREETDS_DG4ODBC_EMGTW_11_2_0_3;
    7 dbms_hs_passthrough.parse@FREETDS_DG4ODBC_EMGTW_11_2_0_3 (c, 'select count(*) from EMP');
    8 LOOP
    9 nr:= DBMS_Hs_Passthrough.fetch_row@FREETDS_DG4ODBC_EMGTW_11_2_0_3(c);
    10 exit when nr=0;
    11 dbms_hs_passthrough.get_value@FREETDS_DG4ODBC_EMGTW_11_2_0_3(c,1,val);
    12 dbms_output.put_line(val);
    13 end loop;
    14 dbms_hs_passthrough.close_cursor@FREETDS_DG4ODBC_EMGTW_11_2_0_3(c);
    15 end;
    16 /
    24576
    PL/SQL procedure successfully completed.
    SQL> declare
    2 val varchar2(100);
    3 c integer;
    4 nr integer;
    5 begin
    6 c:= dbms_hs_passthrough.open_cursor@FREETDS_DG4ODBC_EMGTW_11_2_0_3;
    7 dbms_hs_passthrough.parse@FREETDS_DG4ODBC_EMGTW_11_2_0_3 (c, 'select count(*) from dbo.EMP');
    8 LOOP
    9 nr:= DBMS_Hs_Passthrough.fetch_row@FREETDS_DG4ODBC_EMGTW_11_2_0_3(c);
    10 exit when nr=0;
    11 dbms_hs_passthrough.get_value@FREETDS_DG4ODBC_EMGTW_11_2_0_3(c,1,val);
    12 dbms_output.put_line(val);
    13 end loop;
    14 dbms_hs_passthrough.close_cursor@FREETDS_DG4ODBC_EMGTW_11_2_0_3(c);
    15 end;
    16 /
    24576
    PL/SQL procedure successfully completed.
    So all 3 ways work for me.
    Edited by: kgronau on Jul 23, 2012 10:08 AM
    Now using variables to perform the select:
    SQL> declare
    2 val varchar2(100);
    3 c integer;
    4 nr integer;
    5 tabname varchar2(20) :='EMP';
    6 ownr varchar2(20) :='dbo';
    7 dbname varchar2(20) :='gateway';
    8 begin
    9 c:= dbms_hs_passthrough.open_cursor@FREETDS_DG4ODBC_EMGTW_11_2_0_3;
    10 dbms_hs_passthrough.parse@FREETDS_DG4ODBC_EMGTW_11_2_0_3 (c, 'SELECT count(*) FROM '||dbname||'.'|| ownr || '.'||tabname||'');
    11 LOOP
    12 nr:= DBMS_Hs_Passthrough.fetch_row@FREETDS_DG4ODBC_EMGTW_11_2_0_3(c);
    13 exit when nr=0;
    14 dbms_hs_passthrough.get_value@FREETDS_DG4ODBC_EMGTW_11_2_0_3(c,1,val);
    15 dbms_output.put_line(val);
    16 end loop;
    17 dbms_hs_passthrough.close_cursor@FREETDS_DG4ODBC_EMGTW_11_2_0_3(c);
    18 end;
    19 /
    24576
    PL/SQL procedure successfully completed.
    => instead of executing the statement using "execute Immediate" we have to use PASTHROUGH package to pass the statement to the SQL Server.
    Edited by: kgronau on Jul 23, 2012 10:10 AM

Maybe you are looking for

  • Java Job not working

    We have a java job that sends an XML to remote URL by opening OutputStreamWriter to URL and receives the response XML from same URL using InputStreamWriter. This Job is working fine, when running on Solaris Env. Now we have new server installed on Re

  • Visualization of rectangulars in pdf forms?

    Is it possible to visualize a rectangular dynamically (by typing the numbers in the specific fields e.g. A=heiht, B=width)?     Thanks

  • Capture errors in owb . version 10gR2

    Hi Expert, I am pavan, new to this technology. i had one question. i just want to capture errors during the run of etl process. means when i run the etl process,if any errors occur during the run those error records should be captured in a separate t

  • Aggregate Persistence

    Hi all I try to create three aggregate table based on my dimensions. After run Aggregate Persistence Wizard, I run the command to create the table. The command interrupt with the error: "[nQSError: 84008] [Aggregate Persistence] Error while processin

  • IDM in multi-master LDAP Replication

    Hi, We got two functional SUN Java Directory Server in multi-master replication setup. Both server have their own IDM's. When I change password/uid from any IDM , straightaway changes get done on both LDAP servers and I can see changes on another IDM