2017-12-21 3 views
0

명령 줄을 사용하여 PervasiveSQL에서 데이터베이스를 만드는 방법은 무엇입니까?명령 줄에서 PervasiveSQL의 데이터베이스 만들기

나는 Control Center를 통해이를 수행하는 방법을 알고 있지만 명령 줄을 통해 작성하려고합니다. 필자는 작업중인 프로젝트를위한 PervasiveSQL 상자의 자동화를 위해 노력하고 있습니다. 서버를 자동으로 설치하고 RegKey 가져 오기를 사용하여 서버 구성을 조정합니다.

이제 데이터베이스 생성을 스크립팅해야합니다. 새 데이터베이스는 이미 서버에 복사 된 기존 데이터베이스 파일을 사용합니다.

found here을 사용하는 문서에는 작업을 수행하는 것처럼 보이는 dbMaint (264 페이지)라는 유틸리티가 있지만 내 서버에는 해당 도구가없는 것 같습니다.

도움을 주셔서 감사합니다.

답변

1

dbMaint는 Linux의 PSQL에만 제공됩니다. DTI (Distributed Tuning Interface) 또는 DTO (Distributed Tuning Object)를 사용하여 유틸리티를 작성하여 데이터베이스를 작성하는 방법이 있습니다. PSQL 문서에 연결할 수는 없지만 해당 API를 사용하는 방법을 설명하는 PSQL v11 설명서 다운로드에 PSQL_DTI_GUIDE.pdf 및 PSQL_DTO_Guide.pdf가 있습니다.

나는 C# 샘플을 발견했다. Pervasive DTO 라이브러리를 참조 용으로 추가해야합니다. 그것은 COM 객체입니다. 간단한 샘플은 다음과 같습니다.

using System; 
using DTOLib; 

namespace dtoTest 
{ 
    class Class1 
    { 
     [STAThread] 
     static void Main(string[] args) 
     { 
      string compName = null; 
      string userName = null; 
      string password = null; 
      string dbname = null; 
      string ddflocation = null; 
      string datalocation = null; 
      dtoDbFlags dbflags = DTOLib.dtoDbFlags.dtoDbFlagDefault; 

      DTOLib.dtoResult result; 
      if (args.LongLength < 1) 
      { 
       Console.WriteLine("Invalid options.\n"); 
       Console.WriteLine("Usage: dtoDBN.EXE <computername> <username> <password> <dbname> <ddf location> <data location> <DBFlage>"); 
       Console.WriteLine("NOTE: locations must be relative to the computer where the PSQL engine is running."); 
       Console.WriteLine("DB Flags must be passed as integer in this example with these values: "); 
       Console.WriteLine(" P_DBFLAG_BOUND = 1; (* bound database - must have P_DBFLAG_CREATE_DDF too *)"); 
       Console.WriteLine(" P_DBFLAG_RI = 2; (*relational integrity *)"); 
       Console.WriteLine(" P_DBFLAG_CREATE_DDF = 4; (*create ddf flag *)"); 
       Console.WriteLine(" P_DBFLAG_NA = 2147483648; (*not applicable *)"); 
       Console.WriteLine(" P_DBFLAG_DEFAULT = (P_DBFLAG_BOUND or P_DBFLAG_RI); "); 

       return; 
      } 
      if (args.LongLength == 7) 
      { 
       compName = args[0].ToString(); 
       userName = args[1].ToString(); 
       password = args[2].ToString(); 
       dbname = args[3].ToString(); 
       ddflocation = args[4].ToString(); 
       datalocation = args[5].ToString(); 
       dbflags = (dtoDbFlags)Convert.ToInt32(args[6]); 
      } 
      Console.WriteLine("Create Pervasive Database using DTO and C#"); 
      DtoSession mDtoSession = new DTOLib.DtoSession(); 
      try 
      { 
       result = mDtoSession.Connect(compName, userName, password); 
       if (result != 0) 
       { 
        Console.WriteLine("Error connecting to server. Error code:"); 
       } 
       else 
       { 
        //Create a Database name here. 
        DtoDatabase db = new DtoDatabase(); 
        db.Name = dbname; 
        db.DdfPath = ddflocation; 
        db.DataPath = datalocation; 
        db.Flags = dbflags; 
        result = mDtoSession.Databases.Add(db); 
        if (result !=0) 
        { 
         Console.WriteLine(string.Format("Error creating the datbase ({0}). Error code: {1}", dbname, result.ToString())); 
        } 
        else 
        { 
         Console.WriteLine(string.Format("Database ({0}) created. ", dbname)); 

        } 

        result = mDtoSession.Disconnect(); 
        Console.ReadLine(); 
       } 
      } 
      catch (Exception e1) 
      { 
       Console.WriteLine(e1.Message.ToString()); 
      } 
     } 
    } 
} 
+0

내가 원하는 것은 아니지만 대답은 아무 것도 예상하지 못했습니다. 다음 질문은 Linux 컴퓨터에서이 도구를 사용하여 Windows 컴퓨터에 DB를 만들 수 있습니까? – Sage

+0

설명서를 보면 원격 DB 이름을 만드는 데 사용할 수있는 것으로 보이지 않습니다. DTI/DTO를 사용하여 작은 샘플을 사용했는데 찾을 수 있는지 보았습니다. – mirtheil

+0

DTI \ DTO를 사용하여 해당 예제를 찾을 수 있습니까? – Sage