You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tajo.apache.org by hy...@apache.org on 2014/10/20 08:59:21 UTC

git commit: TAJO-235: Support Oracle CatalogStore. (Jihun Kang via hyunsik)

Repository: tajo
Updated Branches:
  refs/heads/master 2e32f5a62 -> 0563a6a26


TAJO-235: Support Oracle CatalogStore. (Jihun Kang via hyunsik)

Closes #154


Project: http://git-wip-us.apache.org/repos/asf/tajo/repo
Commit: http://git-wip-us.apache.org/repos/asf/tajo/commit/0563a6a2
Tree: http://git-wip-us.apache.org/repos/asf/tajo/tree/0563a6a2
Diff: http://git-wip-us.apache.org/repos/asf/tajo/diff/0563a6a2

Branch: refs/heads/master
Commit: 0563a6a26fd97a3e8cfa9c6ae99772436c58da76
Parents: 2e32f5a
Author: Hyunsik Choi <hy...@apache.org>
Authored: Sun Oct 19 23:57:05 2014 -0700
Committer: Hyunsik Choi <hy...@apache.org>
Committed: Sun Oct 19 23:57:05 2014 -0700

----------------------------------------------------------------------
 CHANGES                                         |   4 +-
 .../apache/tajo/catalog/store/OracleStore.java  | 380 +++++++++++++++++++
 .../main/resources/schemas/oracle/columns.sql   |   9 +
 .../main/resources/schemas/oracle/databases.sql |   6 +
 .../main/resources/schemas/oracle/indexes.sql   |  14 +
 .../schemas/oracle/partition_methods.sql        |   7 +
 .../resources/schemas/oracle/partitions.sql     |  10 +
 .../src/main/resources/schemas/oracle/stats.sql |   6 +
 .../schemas/oracle/table_properties.sql         |   7 +
 .../main/resources/schemas/oracle/tables.sql    |   9 +
 .../resources/schemas/oracle/tablespaces.sql    |   6 +
 .../org/apache/tajo/catalog/TestCatalog.java    |   4 +-
 12 files changed, 460 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tajo/blob/0563a6a2/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 3a306a5..3d44a7c 100644
--- a/CHANGES
+++ b/CHANGES
@@ -7,6 +7,8 @@ Release 0.9.1 - unreleased
 
     TAJO-233: Support PostgreSQL CatalogStore. (Jihun Kang via hyunsik)
 
+    TAJO-235: Support Oracle CatalogStore. (Jihun Kang via hyunsik)
+
   IMPROVEMENT
 
     TAJO-1092: Improve the function system to allow other function 
@@ -20,7 +22,7 @@ Release 0.9.1 - unreleased
 
 
 
-Release 0.9.0 - unreleased
+Release 0.9.0
 
   NEW FEATURES 
 

http://git-wip-us.apache.org/repos/asf/tajo/blob/0563a6a2/tajo-catalog/tajo-catalog-server/src/main/java/org/apache/tajo/catalog/store/OracleStore.java
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-server/src/main/java/org/apache/tajo/catalog/store/OracleStore.java b/tajo-catalog/tajo-catalog-server/src/main/java/org/apache/tajo/catalog/store/OracleStore.java
new file mode 100644
index 0000000..cea777e
--- /dev/null
+++ b/tajo-catalog/tajo-catalog-server/src/main/java/org/apache/tajo/catalog/store/OracleStore.java
@@ -0,0 +1,380 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tajo.catalog.store;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.tajo.catalog.CatalogUtil;
+import org.apache.tajo.catalog.exception.CatalogException;
+import org.apache.tajo.exception.InternalException;
+
+public class OracleStore extends AbstractDBStore {
+  
+  private static final int ORACLE_STORE_VERSION = 2;
+  private static final String CATALOG_DRIVER = "oracle.jdbc.OracleDriver";
+
+  public OracleStore(Configuration conf) throws InternalException {
+    super(conf);
+  }
+
+  @Override
+  protected String getCatalogDriverName() {
+    return CATALOG_DRIVER;
+  }
+
+  @Override
+  protected Connection createConnection(Configuration conf) throws SQLException {
+    return DriverManager.getConnection(getCatalogUri(), this.connectionId, this.connectionPassword);
+  }
+
+  @Override
+  protected boolean isInitialized() throws CatalogException {
+    Connection conn;
+    ResultSet res = null;
+
+    try {
+      conn = getConnection();
+      res = conn.getMetaData().getTables(null, 
+          this.connectionId != null?this.connectionId.toUpperCase():null, 
+              null, new String[] { "TABLE" });
+      
+      baseTableMaps.put(TB_META, false);
+      baseTableMaps.put(TB_SPACES, false);
+      baseTableMaps.put(TB_DATABASES, false);
+      baseTableMaps.put(TB_TABLES, false);
+      baseTableMaps.put(TB_COLUMNS, false);
+      baseTableMaps.put(TB_OPTIONS, false);
+      baseTableMaps.put(TB_STATISTICS, false);
+      baseTableMaps.put(TB_INDEXES, false);
+      baseTableMaps.put(TB_PARTITION_METHODS, false);
+      baseTableMaps.put(TB_PARTTIONS, false);
+      
+      while (res.next()) {
+        baseTableMaps.put(res.getString("TABLE_NAME"), true);
+      }
+    } catch (SQLException se) {
+      throw new CatalogException(se);
+    } finally {
+      CatalogUtil.closeQuietly(res);
+    }
+    
+    for(Map.Entry<String, Boolean> entry : baseTableMaps.entrySet()) {
+      if (!entry.getValue()) {
+        return false;
+      }
+    }
+
+    return true;
+  }
+
+  @Override
+  protected void createBaseTable() throws CatalogException {
+    Statement stmt = null;
+    Connection conn = null;
+
+    try {
+      conn = getConnection();
+      stmt = conn.createStatement();
+
+
+      // META
+      if (!baseTableMaps.get(TB_META)) {
+        String sql = super.readSchemaFile("common/meta.sql");
+
+        if (LOG.isDebugEnabled()) {
+          LOG.debug(sql);
+        }
+
+        stmt.executeUpdate(sql);
+        LOG.info("Table '" + TB_META + " is created.");
+        baseTableMaps.put(TB_META, true);
+      }
+
+      // TABLE SPACES
+      if (!baseTableMaps.get(TB_SPACES)) {
+        String sql = readSchemaFile("tablespaces.sql");
+
+        if (LOG.isDebugEnabled()) {
+          LOG.debug(sql);
+        }
+        stmt.addBatch(sql);
+        
+        sql = "CREATE SEQUENCE TABLESPACES_SEQ";
+        if (LOG.isDebugEnabled()) {
+          LOG.debug(sql);
+        }
+        stmt.addBatch(sql);
+        
+        sql = "CREATE OR REPLACE TRIGGER TABLESPACES_AUTOINC " +
+                "BEFORE INSERT ON TABLESPACES " +
+                "FOR EACH ROW " +
+                "WHEN (new.SPACE_ID IS NULL) " +
+                "BEGIN " +
+                "  SELECT TABLESPACES_SEQ.NEXTVAL INTO :new.SPACE_ID FROM DUAL; " +
+                "END;";
+        if (LOG.isDebugEnabled()) {
+          LOG.debug(sql);
+        }
+        stmt.addBatch(sql);
+
+        stmt.executeBatch();
+        LOG.info("Table '" + TB_SPACES + "' is created.");
+        baseTableMaps.put(TB_SPACES, true);
+      }
+
+      // DATABASES
+      if (!baseTableMaps.get(TB_DATABASES)) {
+        String sql = readSchemaFile("databases.sql");
+        if (LOG.isDebugEnabled()) {
+          LOG.debug(sql);
+        }        
+        stmt.addBatch(sql);
+        
+        sql = "CREATE SEQUENCE DATABASES__SEQ";
+        if (LOG.isDebugEnabled()) {
+          LOG.debug(sql);
+        }
+        stmt.addBatch(sql);
+        
+        sql = "CREATE OR REPLACE TRIGGER DATABASES__AUTOINC " +
+            "BEFORE INSERT ON DATABASES_ " +
+            "FOR EACH ROW " +
+            "WHEN (new.DB_ID IS NULL) " +
+            "BEGIN " +
+            "  SELECT DATABASES__SEQ.NEXTVAL INTO :new.DB_ID FROM DUAL; " +
+            "END;";
+        if (LOG.isDebugEnabled()) {
+          LOG.debug(sql);
+        }
+        stmt.addBatch(sql);
+        
+        stmt.executeBatch();
+        LOG.info("Table '" + TB_DATABASES + "' is created.");
+        baseTableMaps.put(TB_DATABASES, true);
+      }
+
+      // TABLES
+      if (!baseTableMaps.get(TB_TABLES)) {
+        String sql = readSchemaFile("tables.sql");
+        if (LOG.isDebugEnabled()) {
+          LOG.debug(sql);
+        }
+        stmt.addBatch(sql);
+        
+        sql = "CREATE SEQUENCE TABLES_SEQ";
+        if (LOG.isDebugEnabled()) {
+          LOG.debug(sql);
+        }
+        stmt.addBatch(sql);
+        
+        sql = "CREATE OR REPLACE TRIGGER TABLES_AUTOINC " +
+            "BEFORE INSERT ON TABLES " +
+            "FOR EACH ROW " +
+            "WHEN (new.TID IS NULL) " +
+            "BEGIN " +
+            "  SELECT TABLES_SEQ.NEXTVAL INTO :new.TID FROM DUAL; " +
+            "END;";
+        if (LOG.isDebugEnabled()) {
+          LOG.debug(sql);
+        }
+        stmt.addBatch(sql);
+        
+        sql = "CREATE INDEX TABLES_IDX_DB_ID on TABLES (DB_ID)";
+        if (LOG.isDebugEnabled()) {
+          LOG.debug(sql);
+        }
+        stmt.addBatch(sql);
+        
+        sql = "CREATE UNIQUE INDEX TABLES_IDX_TABLE_ID on TABLES (DB_ID, TABLE_NAME)";
+        if (LOG.isDebugEnabled()) {
+          LOG.debug(sql);
+        }
+        stmt.addBatch(sql);
+        
+        stmt.executeBatch();
+        LOG.info("Table '" + TB_TABLES + "' is created.");
+        baseTableMaps.put(TB_TABLES, true);
+      }
+
+      // COLUMNS
+      if (!baseTableMaps.get(TB_COLUMNS)) {
+        String sql = readSchemaFile("columns.sql");
+        if (LOG.isDebugEnabled()) {
+          LOG.debug(sql);
+        }
+
+        stmt.executeUpdate(sql);
+        LOG.info("Table '" + TB_COLUMNS + " is created.");
+        baseTableMaps.put(TB_COLUMNS, true);
+      }
+
+      // OPTIONS
+      if (!baseTableMaps.get(TB_OPTIONS)) {
+        String sql = readSchemaFile("table_properties.sql");
+
+        if (LOG.isDebugEnabled()) {
+          LOG.debug(sql);
+        }
+
+        stmt.executeUpdate(sql);
+        LOG.info("Table '" + TB_OPTIONS + " is created.");
+        baseTableMaps.put(TB_OPTIONS, true);
+      }
+
+      // INDEXES
+      if (!baseTableMaps.get(TB_INDEXES)) {
+        String sql = readSchemaFile("indexes.sql");
+
+        if (LOG.isDebugEnabled()) {
+          LOG.debug(sql);
+        }
+        stmt.addBatch(sql);
+        
+        sql = "CREATE INDEX INDEXES_IDX_TID_COLUMN_NAME on INDEXES (TID, COLUMN_NAME)";
+        if (LOG.isDebugEnabled()) {
+          LOG.debug(sql);
+        }
+        stmt.addBatch(sql);
+        
+        stmt.executeBatch();
+        LOG.info("Table '" + TB_INDEXES + "' is created.");
+        baseTableMaps.put(TB_INDEXES, true);
+      }
+
+      if (!baseTableMaps.get(TB_STATISTICS)) {
+        String sql = readSchemaFile("stats.sql");
+
+        if (LOG.isDebugEnabled()) {
+          LOG.debug(sql);
+        }
+
+        stmt.executeUpdate(sql);
+        LOG.info("Table '" + TB_STATISTICS + "' is created.");
+        baseTableMaps.put(TB_STATISTICS, true);
+      }
+
+      // PARTITION_METHODS
+      if (!baseTableMaps.get(TB_PARTITION_METHODS)) {
+        String sql = readSchemaFile("partition_methods.sql");
+
+        if (LOG.isDebugEnabled()) {
+          LOG.debug(sql);
+        }
+
+        stmt.executeUpdate(sql);
+        LOG.info("Table '" + TB_PARTITION_METHODS + "' is created.");
+        baseTableMaps.put(TB_PARTITION_METHODS, true);
+      }
+
+      // PARTITIONS
+      if (!baseTableMaps.get(TB_PARTTIONS)) {
+        String sql = readSchemaFile("partitions.sql");
+
+        if (LOG.isDebugEnabled()) {
+          LOG.debug(sql);
+        }
+        stmt.addBatch(sql);
+        
+        sql = "CREATE INDEX PARTITIONS_IDX_TID on PARTITIONS (TID)";
+        if (LOG.isDebugEnabled()) {
+          LOG.debug(sql);
+        }
+        stmt.addBatch(sql);
+        
+        stmt.executeBatch();
+        LOG.info("Table '" + TB_PARTTIONS + "' is created.");
+        baseTableMaps.put(TB_PARTTIONS, true);
+      }
+
+      insertSchemaVersion();
+
+    } catch (SQLException se) {
+      throw new CatalogException("failed to create base tables for Oracle catalog store", se);
+    } finally {
+      CatalogUtil.closeQuietly(stmt);
+    }
+  }
+
+  @Override
+  protected void dropBaseTable() throws CatalogException {
+    Connection conn;
+    Statement stmt = null;
+    PreparedStatement dropSequence = null;
+    Map<String, Boolean> droppedTable = new HashMap<String, Boolean>();
+
+    try {
+      conn = getConnection();
+      stmt = conn.createStatement();
+
+      for(Map.Entry<String, Boolean> entry : baseTableMaps.entrySet()) {
+        if(entry.getValue() && !entry.getKey().equals(TB_TABLES)) {
+          String sql = "DROP TABLE " + entry.getKey();
+          stmt.addBatch(sql);
+          droppedTable.put(entry.getKey(), true);
+        }
+      }
+      if(baseTableMaps.get(TB_TABLES)) {
+        String sql = "DROP TABLE " + TB_TABLES;
+        stmt.addBatch(sql);
+        droppedTable.put(TB_TABLES, true);
+      }
+      stmt.executeBatch();
+      
+      for(String tableName : droppedTable.keySet()) {
+        LOG.info("Table '" + tableName + "' is dropped");
+      }
+      
+      // Drop sequences
+      dropSequence = conn.prepareStatement("SELECT COUNT(*) FROM USER_SEQUENCES WHERE SEQUENCE_NAME = ?");
+      for(String tableName : droppedTable.keySet()) {
+        String possibleSeqName = tableName + "_SEQ";
+        dropSequence.setString(1, possibleSeqName);
+        ResultSet rs = dropSequence.executeQuery();
+        
+        if (rs.next() && rs.getInt(1) > 0) {
+          String sql = "DROP SEQUENCE " + possibleSeqName;
+          stmt.execute(sql);
+          LOG.info("Sequence '" + possibleSeqName + "' is dropped");
+        }
+      }
+    } catch (SQLException se) {
+      throw new CatalogException(se);
+    } finally {
+      CatalogUtil.closeQuietly(stmt);
+      CatalogUtil.closeQuietly(dropSequence);
+    }
+  }
+
+  @Override
+  public int getDriverVersion() {
+    return ORACLE_STORE_VERSION;
+  }
+
+  @Override
+  public String readSchemaFile(String path) throws CatalogException {
+    return super.readSchemaFile("oracle/" + path);
+  }
+}

http://git-wip-us.apache.org/repos/asf/tajo/blob/0563a6a2/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/oracle/columns.sql
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/oracle/columns.sql b/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/oracle/columns.sql
new file mode 100644
index 0000000..71943c0
--- /dev/null
+++ b/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/oracle/columns.sql
@@ -0,0 +1,9 @@
+CREATE TABLE COLUMNS (
+  TID INT NOT NULL,
+  COLUMN_NAME VARCHAR2(255) NOT NULL,
+  ORDINAL_POSITION INT NOT NULL,
+  DATA_TYPE CHAR(16),
+  TYPE_LENGTH INTEGER,
+  CONSTRAINT COLUMNS_PKEY PRIMARY KEY (TID, COLUMN_NAME),
+  FOREIGN KEY (TID) REFERENCES TABLES (TID) ON DELETE CASCADE
+)
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tajo/blob/0563a6a2/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/oracle/databases.sql
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/oracle/databases.sql b/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/oracle/databases.sql
new file mode 100644
index 0000000..33d82d8
--- /dev/null
+++ b/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/oracle/databases.sql
@@ -0,0 +1,6 @@
+CREATE TABLE DATABASES_ (
+  DB_ID NUMBER(10) NOT NULL PRIMARY KEY,
+  DB_NAME VARCHAR2(128) NOT NULL UNIQUE,
+  SPACE_ID INT NOT NULL,
+  FOREIGN KEY (SPACE_ID) REFERENCES TABLESPACES (SPACE_ID)
+)
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tajo/blob/0563a6a2/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/oracle/indexes.sql
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/oracle/indexes.sql b/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/oracle/indexes.sql
new file mode 100644
index 0000000..ae31d6f
--- /dev/null
+++ b/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/oracle/indexes.sql
@@ -0,0 +1,14 @@
+CREATE TABLE INDEXES (
+  DB_ID INT NOT NULL,
+  TID INT NOT NULL,
+  INDEX_NAME VARCHAR2(128) NOT NULL,
+  COLUMN_NAME VARCHAR2(128) NOT NULL,
+  DATA_TYPE VARCHAR2(128) NOT NULL,
+  INDEX_TYPE CHAR(32) NOT NULL,
+  IS_UNIQUE CHAR NOT NULL,
+  IS_CLUSTERED CHAR NOT NULL,
+  IS_ASCENDING CHAR NOT NULL,
+  CONSTRAINT INDEXES_PKEY PRIMARY KEY (DB_ID, INDEX_NAME),
+  FOREIGN KEY (DB_ID) REFERENCES DATABASES_ (DB_ID) ON DELETE CASCADE,
+  FOREIGN KEY (TID) REFERENCES TABLES (TID) ON DELETE CASCADE
+)
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tajo/blob/0563a6a2/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/oracle/partition_methods.sql
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/oracle/partition_methods.sql b/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/oracle/partition_methods.sql
new file mode 100644
index 0000000..7d37a6e
--- /dev/null
+++ b/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/oracle/partition_methods.sql
@@ -0,0 +1,7 @@
+CREATE TABLE PARTITION_METHODS (
+  TID INT NOT NULL PRIMARY KEY,
+  PARTITION_TYPE VARCHAR2(10) NOT NULL,
+  EXPRESSION VARCHAR2(1024) NOT NULL,
+  EXPRESSION_SCHEMA RAW(1024) NOT NULL,
+  FOREIGN KEY (TID) REFERENCES TABLES (TID) ON DELETE CASCADE
+)

http://git-wip-us.apache.org/repos/asf/tajo/blob/0563a6a2/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/oracle/partitions.sql
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/oracle/partitions.sql b/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/oracle/partitions.sql
new file mode 100644
index 0000000..2fee267
--- /dev/null
+++ b/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/oracle/partitions.sql
@@ -0,0 +1,10 @@
+CREATE TABLE PARTITIONS (
+  PID INT NOT NULL PRIMARY KEY,
+  TID INT NOT NULL,
+  PARTITION_NAME VARCHAR2(128),
+  ORDINAL_POSITION INT NOT NULL,
+  PARTITION_VALUE VARCHAR2(1024),
+  PATH VARCHAR2(4000),
+  FOREIGN KEY (TID) REFERENCES TABLES (TID) ON DELETE CASCADE,
+  CONSTRAINT C_PARTITION_UNIQUE UNIQUE (TID, PARTITION_NAME)
+)
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tajo/blob/0563a6a2/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/oracle/stats.sql
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/oracle/stats.sql b/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/oracle/stats.sql
new file mode 100644
index 0000000..d7091b4
--- /dev/null
+++ b/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/oracle/stats.sql
@@ -0,0 +1,6 @@
+CREATE TABLE STATS (
+  TID INT NOT NULL PRIMARY KEY,
+  NUM_ROWS NUMBER(38),
+  NUM_BYTES NUMBER(38),
+  FOREIGN KEY (TID) REFERENCES TABLES (TID) ON DELETE CASCADE
+)
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tajo/blob/0563a6a2/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/oracle/table_properties.sql
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/oracle/table_properties.sql b/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/oracle/table_properties.sql
new file mode 100644
index 0000000..130402c
--- /dev/null
+++ b/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/oracle/table_properties.sql
@@ -0,0 +1,7 @@
+CREATE TABLE OPTIONS (
+  TID INT NOT NULL,
+  KEY_ VARCHAR2(255) NOT NULL,
+  VALUE_ VARCHAR2(255) NOT NULL,
+  CONSTRAINT OPTIONS_PKEY PRIMARY KEY (TID, KEY_),
+  FOREIGN KEY (TID) REFERENCES TABLES (TID) ON DELETE CASCADE
+)
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tajo/blob/0563a6a2/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/oracle/tables.sql
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/oracle/tables.sql b/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/oracle/tables.sql
new file mode 100644
index 0000000..36f8067
--- /dev/null
+++ b/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/oracle/tables.sql
@@ -0,0 +1,9 @@
+CREATE TABLE TABLES (
+  TID NUMBER(10) NOT NULL PRIMARY KEY,
+  DB_ID INT NOT NULL,
+  TABLE_NAME VARCHAR2(128) NOT NULL,
+  TABLE_TYPE VARCHAR2(128) NOT NULL,
+  PATH VARCHAR2(4000),
+  STORE_TYPE CHAR(16),
+  FOREIGN KEY (DB_ID) REFERENCES DATABASES_ (DB_ID)
+)
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tajo/blob/0563a6a2/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/oracle/tablespaces.sql
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/oracle/tablespaces.sql b/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/oracle/tablespaces.sql
new file mode 100644
index 0000000..461e77c
--- /dev/null
+++ b/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/oracle/tablespaces.sql
@@ -0,0 +1,6 @@
+CREATE TABLE TABLESPACES (
+  SPACE_ID NUMBER(10) NOT NULL PRIMARY KEY,
+  SPACE_NAME VARCHAR2(128) NOT NULL UNIQUE,
+  SPACE_HANDLER VARCHAR2(1024) DEFAULT 'HDFS',
+  SPACE_URI VARCHAR2(4000) NOT NULL
+)
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tajo/blob/0563a6a2/tajo-catalog/tajo-catalog-server/src/test/java/org/apache/tajo/catalog/TestCatalog.java
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-server/src/test/java/org/apache/tajo/catalog/TestCatalog.java b/tajo-catalog/tajo-catalog-server/src/test/java/org/apache/tajo/catalog/TestCatalog.java
index f586660..4a45abc 100644
--- a/tajo-catalog/tajo-catalog-server/src/test/java/org/apache/tajo/catalog/TestCatalog.java
+++ b/tajo-catalog/tajo-catalog-server/src/test/java/org/apache/tajo/catalog/TestCatalog.java
@@ -33,6 +33,7 @@ import org.apache.tajo.catalog.proto.CatalogProtos.StoreType;
 import org.apache.tajo.catalog.store.DerbyStore;
 import org.apache.tajo.catalog.store.MySQLStore;
 import org.apache.tajo.catalog.store.MariaDBStore;
+import org.apache.tajo.catalog.store.OracleStore;
 import org.apache.tajo.common.TajoDataTypes;
 import org.apache.tajo.common.TajoDataTypes.Type;
 import org.apache.tajo.conf.TajoConf;
@@ -119,7 +120,8 @@ public class TestCatalog {
   public static boolean isConnectionIdRequired(String driverClass) {
     return driverClass.equals(MySQLStore.class.getCanonicalName()) ||
            driverClass.equals(MariaDBStore.class.getCanonicalName()) ||
-           driverClass.equals(PostgreSQLStore.class.getCanonicalName());
+           driverClass.equals(PostgreSQLStore.class.getCanonicalName()) ||
+	   driverClass.equals(OracleStore.class.getCanonicalName());
   }
 	
 	@AfterClass