Interface IDatabase

All Superinterfaces:
IStatement, IStatementContainer
All Known Implementing Classes:
ChDatabase, MsDatabase, PgDatabase

public interface IDatabase extends IStatementContainer
Interface representing a database containing schemas. Provides access to database schemas and extends statement container functionality.
  • Method Details

    • getSchemas

      Collection<? extends ISchema> getSchemas()
      Gets all schemas in this database.
      Returns:
      a collection of schemas
    • getSchema

      ISchema getSchema(String name)
      Gets a schema by name.
      Parameters:
      name - the schema name
      Returns:
      the schema with the given name, or null if not found
    • containsSchema

      default boolean containsSchema(String name)
    • getStatement

      IStatement getStatement(ObjectReference objectReference)
      Parameters:
      objectReference - - object reference
      Returns:
      object from database by reference, or null if not found
      Throws:
      IllegalStateException - if reference type is not supported by database
    • getDatabase

      default IDatabase getDatabase()
      Description copied from interface: IStatement
      Gets the database that contains this statement.
      Specified by:
      getDatabase in interface IStatement
      Returns:
      the containing database
    • getStatementType

      default DbObjType getStatementType()
      Description copied from interface: IStatement
      Gets the type of this database object.
      Specified by:
      getStatementType in interface IStatement
      Returns:
      the database object type
    • getVersion

      ISupportedVersion getVersion()
      Returns:
      default database version
    • getCreationSQL

      default void getCreationSQL(SQLScript script)
      Description copied from interface: IStatement
      Generates the SQL statements needed to create this database object. This is an abstract method that must be implemented by subclasses to provide the specific CREATE SQL for each object type.
      Specified by:
      getCreationSQL in interface IStatement
      Parameters:
      script - the SQL script to append creation statements to
    • appendAlterSQL

      default ObjectState appendAlterSQL(IStatement newCondition, SQLScript script)
      Description copied from interface: IStatement
      Fill script with object changes and return change type
      Specified by:
      appendAlterSQL in interface IStatement
      Parameters:
      newCondition - new object state
      script - script to collect changes
      Returns:
      object change type
    • getDropSQL

      default void getDropSQL(SQLScript script, boolean optionExists)
      Description copied from interface: IStatement
      Generates DROP SQL for this statement.
      Specified by:
      getDropSQL in interface IStatement
      Parameters:
      script - the SQL script to append the DROP statement to
      optionExists - whether to include "IF EXISTS" in the DROP statement
    • getDefaultSchema

      ISchema getDefaultSchema()
    • setDefaultSchema

      void setDefaultSchema(String name)
    • addLib

      default void addLib(IDatabase lib, String libName, String owner)
      Adds a library database to this database, merging its objects and analysis launchers.
      Parameters:
      lib - the library database to add
      libName - the name of the library
      owner - the owner to set for owned objects
    • concat

      default void concat(IStatement st)
      Adds library object to database with override
      Parameters:
      st - the library object to add
    • addOverride

      void addOverride(ObjectOverride override)
      Adds object override
      Parameters:
      override - object override
    • getOverrides

      Collection<ObjectOverride> getOverrides()
      Gets the list of object overrides for this database.
      Returns:
      the list of overrides
    • getObjReferences

      Map<String,Set<ObjectLocation>> getObjReferences()
      Returns:
      all object references for this database
    • getAnalysisLaunchers

      List<IAnalysisLauncher> getAnalysisLaunchers()
      Returns:
      all analysis launcher for this database
    • addAnalysisLauncher

      void addAnalysisLauncher(IAnalysisLauncher launcher)
      Add 'analysis launcher' for deferred analyze.
      Parameters:
      launcher - launcher that contains almost everything needed to analyze a statement contained in it
    • addReference

      void addReference(String fileName, ObjectLocation loc)
      Adds an object reference to the specified file.
      Parameters:
      fileName - the file name to associate with the location
      loc - the object location to add
    • clearAnalysisLaunchers

      void clearAnalysisLaunchers()
      Clears all analysis launchers and trims the internal list to size.
    • listObjects

      default Map<String,IStatement> listObjects()
      Creates a map of all database objects with their qualified names as keys.
      Returns:
      a map of qualified names to statements