Open Source RDBMS - Seamless, Scalable, Stable and Free

한국어 | Login |Register

Cubrid OIDs


First of all, what is an OID…? 

A CUBRID OID(Object Identifier) is an object identifier represented by physical location information such as the volume number, page number and slot number. By using such OIDs, CUBRID manages the reference relationships of objects and searches, saves or deletes them. When an OID is used, accessibility is improved because the object in the heap file can be directly accessed without referring to the table (see http://www.cubrid.org/questions/235437).

As the concept of OID is specific only to CUBRID, the CUBRID .NET Provider implements custom extensions to deal with. For example:

CUBRIDOid oid = new CUBRIDOid("@620|1|0");

Debug.Assert(oid.Page() == 620);
Debug.Assert(oid.Slot() == 1);
Debug.Assert(oid.Volume() == 0);

or:

string sql = "select * from nation limit 1";
using (CUBRIDCommand cmd = new CUBRIDCommand(sql, conn))
{
    using (CUBRIDDataReader reader = (CUBRIDDataReader)cmd.ExecuteReader())
    {
        reader.Read();
        CUBRIDOid oid = reader.GetOid();
    }
}

Here is a complete example:

using CUBRID.Data.CUBRIDClient;
using System.Diagnostics;
using System.Data;

namespace CUBRIDOidExample
{
    class Program
    {
        static void Main(string[] args)
        {
            CUBRIDOid oid = new CUBRIDOid("@620|1|0");
            Debug.Assert(oid.Page() == 620);
            Debug.Assert(oid.Slot() == 1);
            Debug.Assert(oid.Volume() == 0);

            CUBRIDConnectionStringBuilder sb = new CUBRIDConnectionStringBuilder("localhost", "demodb", "public", "", "33000");
            using (CUBRIDConnection conn = new CUBRIDConnection(sb.GetConnectionString()))
            {
                conn.Open();

                string sql = "select * from nation limit 1";
                using (CUBRIDCommand cmd = new CUBRIDCommand(sql, conn))
                {
                    using (CUBRIDDataReader reader = (CUBRIDDataReader)cmd.ExecuteReader())
                    {
                        reader.Read();
                        oid = reader.GetOid();
                        Debug.Assert(oid.ToString() == "OID:@0|0|0");
                    }
                }

                conn.Close();
            }
        }
    }
}

comments powered by Disqus
Page info
viewed 1619 times
translations en
Author
posted 2 years ago by
CUBRID
Contributors
updated 2 years ago by
View revisions
Share this article