Repository: apache/incubator-shardingsphere
Pull request #4521 (2020-02-28 10:39:39)

Add getAllTables() method
For #4520.


Patch:
diff --git a/sharding-core/sharding-core-rewrite/src/main/java/org/apache/shardingsphere/sharding/rewrite/token/generator/impl/TableTokenGenerator.java b/sharding-core/sharding-core-rewrite/src/main/java/org/apache/shardingsphere/sharding/rewrite/token/generator/impl/TableTokenGenerator.java
index b8ebac74b18..7b97f11f53e 100644
--- a/sharding-core/sharding-core-rewrite/src/main/java/org/apache/shardingsphere/sharding/rewrite/token/generator/impl/TableTokenGenerator.java
+++ b/sharding-core/sharding-core-rewrite/src/main/java/org/apache/shardingsphere/sharding/rewrite/token/generator/impl/TableTokenGenerator.java
@@ -41,7 +41,6 @@ import org.apache.shardingsphere.sql.parser.sql.segment.generic.OwnerSegmentAvai
 import org.apache.shardingsphere.sql.parser.sql.segment.generic.TableSegment;
 import org.apache.shardingsphere.sql.parser.sql.statement.SQLStatement;
 import org.apache.shardingsphere.sql.parser.sql.statement.dml.SelectStatement;
-import org.apache.shardingsphere.sql.parser.sql.statement.generic.TableSegmentAvailable;
 import org.apache.shardingsphere.sql.parser.sql.statement.generic.TableSegmentsAvailable;
 import org.apache.shardingsphere.sql.parser.sql.statement.generic.WhereSegmentAvailable;
 import org.apache.shardingsphere.underlying.rewrite.sql.token.generator.CollectionSQLTokenGenerator;
@@ -66,17 +65,12 @@ public final class TableTokenGenerator implements CollectionSQLTokenGenerator, S
     public Collection<TableToken> generateSQLTokens(final SQLStatementContext sqlStatementContext) {
         Collection<TableToken> result = new LinkedList<>();
         if (sqlStatementContext.getSqlStatement() instanceof TableSegmentsAvailable) {
-            for (TableSegment each : ((TableSegmentsAvailable) sqlStatementContext.getSqlStatement()).getTables()) {
+            for (TableSegment each : ((TableSegmentsAvailable) sqlStatementContext.getSqlStatement()).getAllTables()) {
                 Optional<TableToken> tableToken = generateSQLToken(sqlStatementContext.getSqlStatement(), each);
                 if (tableToken.isPresent()) {
                     result.add(tableToken.get());
                 }
             }
-        } else if (sqlStatementContext.getSqlStatement() instanceof TableSegmentAvailable && null != ((TableSegmentAvailable) sqlStatementContext.getSqlStatement()).getTable()) {
-            Optional<TableToken> tableToken = generateSQLToken(sqlStatementContext.getSqlStatement(), ((TableSegmentAvailable) sqlStatementContext.getSqlStatement()).getTable());
-            if (tableToken.isPresent()) {
-                result.add(tableToken.get());
-            }
         }
         if (sqlStatementContext.getSqlStatement() instanceof WhereSegmentAvailable && ((WhereSegmentAvailable) sqlStatementContext.getSqlStatement()).getWhere().isPresent()) {
             result.addAll(generateSQLTokens(sqlStatementContext, ((WhereSegmentAvailable) sqlStatementContext.getSqlStatement()).getWhere().get()));
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/sql/statement/dal/dialect/mysql/DescribeStatement.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/sql/statement/dal/dialect/mysql/DescribeStatement.java
index c91666365d6..2a8d80c199a 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/sql/statement/dal/dialect/mysql/DescribeStatement.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/sql/statement/dal/dialect/mysql/DescribeStatement.java
@@ -21,14 +21,22 @@ import lombok.Getter;
 import lombok.Setter;
 import org.apache.shardingsphere.sql.parser.sql.segment.generic.TableSegment;
 import org.apache.shardingsphere.sql.parser.sql.statement.dal.DALStatement;
-import org.apache.shardingsphere.sql.parser.sql.statement.generic.TableSegmentAvailable;
+import org.apache.shardingsphere.sql.parser.sql.statement.generic.TableSegmentsAvailable;
+
+import java.util.Collection;
+import java.util.Collections;
 
 /**
  * Describe statement.
  */
 @Getter
 @Setter
-public final class DescribeStatement extends DALStatement implements TableSegmentAvailable {
+public final class DescribeStatement extends DALStatement implements TableSegmentsAvailable {
 
     private TableSegment table;
+    
+    @Override
+    public Collection<TableSegment> getAllTables() {
+        return null == table ? Collections.<TableSegment>emptyList() : Collections.singletonList(table);
+    }
 }
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/sql/statement/dal/dialect/mysql/ShowColumnsStatement.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/sql/statement/dal/dialect/mysql/ShowColumnsStatement.java
index 7d963a2c14a..e67f35a706b 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/sql/statement/dal/dialect/mysql/ShowColumnsStatement.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/sql/statement/dal/dialect/mysql/ShowColumnsStatement.java
@@ -23,14 +23,17 @@ import lombok.Setter;
 import org.apache.shardingsphere.sql.parser.sql.segment.generic.RemoveAvailable;
 import org.apache.shardingsphere.sql.parser.sql.segment.generic.TableSegment;
 import org.apache.shardingsphere.sql.parser.sql.statement.dal.DALStatement;
-import org.apache.shardingsphere.sql.parser.sql.statement.generic.TableSegmentAvailable;
+import org.apache.shardingsphere.sql.parser.sql.statement.generic.TableSegmentsAvailable;
+
+import java.util.Collection;
+import java.util.Collections;
 
 /**
  * Show columns statement.
  */
 @Getter
 @Setter
-public final class ShowColumnsStatement extends DALStatement implements TableSegmentAvailable {
+public final class ShowColumnsStatement extends DALStatement implements TableSegmentsAvailable {
     
     private TableSegment table;
     
@@ -44,4 +47,9 @@ public final class ShowColumnsStatement extends DALStatement implements TableSeg
     public Optional<RemoveAvailable> getFromSchema() {
         return Optional.fromNullable(fromSchema);
     }
+    
+    @Override
+    public Collection<TableSegment> getAllTables() {
+        return null == table ? Collections.<TableSegment>emptyList() : Collections.singletonList(table);
+    }
 }
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/sql/statement/dal/dialect/mysql/ShowCreateTableStatement.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/sql/statement/dal/dialect/mysql/ShowCreateTableStatement.java
index 5b42347d12c..7f32d8ebdd5 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/sql/statement/dal/dialect/mysql/ShowCreateTableStatement.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/sql/statement/dal/dialect/mysql/ShowCreateTableStatement.java
@@ -21,14 +21,22 @@ import lombok.Getter;
 import lombok.Setter;
 import org.apache.shardingsphere.sql.parser.sql.segment.generic.TableSegment;
 import org.apache.shardingsphere.sql.parser.sql.statement.dal.DALStatement;
-import org.apache.shardingsphere.sql.parser.sql.statement.generic.TableSegmentAvailable;
+import org.apache.shardingsphere.sql.parser.sql.statement.generic.TableSegmentsAvailable;
+
+import java.util.Collection;
+import java.util.Collections;
 
 /**
  * Show create table statement.
  */
 @Getter
 @Setter
-public final class ShowCreateTableStatement extends DALStatement implements TableSegmentAvailable {
+public final class ShowCreateTableStatement extends DALStatement implements TableSegmentsAvailable {
     
     private TableSegment table;
+    
+    @Override
+    public Collection<TableSegment> getAllTables() {
+        return null == table ? Collections.<TableSegment>emptyList() : Collections.singletonList(table);
+    }
 }
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/sql/statement/dal/dialect/mysql/ShowIndexStatement.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/sql/statement/dal/dialect/mysql/ShowIndexStatement.java
index 999c26d5c09..674a9ae10e4 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/sql/statement/dal/dialect/mysql/ShowIndexStatement.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/sql/statement/dal/dialect/mysql/ShowIndexStatement.java
@@ -23,14 +23,17 @@ import lombok.Setter;
 import org.apache.shardingsphere.sql.parser.sql.segment.generic.SchemaSegment;
 import org.apache.shardingsphere.sql.parser.sql.segment.generic.TableSegment;
 import org.apache.shardingsphere.sql.parser.sql.statement.dal.DALStatement;
-import org.apache.shardingsphere.sql.parser.sql.statement.generic.TableSegmentAvailable;
+import org.apache.shardingsphere.sql.parser.sql.statement.generic.TableSegmentsAvailable;
+
+import java.util.Collection;
+import java.util.Collections;
 
 /**
  * Show columns statement.
  */
 @Getter
 @Setter
-public final class ShowIndexStatement extends DALStatement implements TableSegmentAvailable {
+public final class ShowIndexStatement extends DALStatement implements TableSegmentsAvailable {
     
     private TableSegment table;
     
@@ -44,4 +47,9 @@ public final class ShowIndexStatement extends DALStatement implements TableSegme
     public Optional<SchemaSegment> getSchema() {
         return Optional.fromNullable(schema);
     }
+    
+    @Override
+    public Collection<TableSegment> getAllTables() {
+        return null == table ? Collections.<TableSegment>emptyList() : Collections.singletonList(table);
+    }
 }
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/sql/statement/dcl/DenyUserStatement.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/sql/statement/dcl/DenyUserStatement.java
index f23e271887d..88dcbfff030 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/sql/statement/dcl/DenyUserStatement.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/sql/statement/dcl/DenyUserStatement.java
@@ -20,14 +20,22 @@ package org.apache.shardingsphere.sql.parser.sql.statement.dcl;
 import lombok.Getter;
 import lombok.Setter;
 import org.apache.shardingsphere.sql.parser.sql.segment.generic.TableSegment;
-import org.apache.shardingsphere.sql.parser.sql.statement.generic.TableSegmentAvailable;
+import org.apache.shardingsphere.sql.parser.sql.statement.generic.TableSegmentsAvailable;
+
+import java.util.Collection;
+import java.util.Collections;
 
 /**
  * Deny user statement.
  */
 @Getter
 @Setter
-public final class DenyUserStatement extends DCLStatement implements TableSegmentAvailable {
+public final class DenyUserStatement extends DCLStatement implements TableSegmentsAvailable {
     
     private TableSegment table;
+    
+    @Override
+    public Collection<TableSegment> getAllTables() {
+        return null == table ? Collections.<TableSegment>emptyList() : Collections.singletonList(table);
+    }
 }
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/sql/statement/dcl/GrantStatement.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/sql/statement/dcl/GrantStatement.java
index db6f8eb6867..b6d027a23d9 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/sql/statement/dcl/GrantStatement.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/sql/statement/dcl/GrantStatement.java
@@ -31,4 +31,9 @@ import java.util.LinkedList;
 public final class GrantStatement extends DCLStatement implements TableSegmentsAvailable {
     
     private final Collection<TableSegment> tables = new LinkedList<>();
+    
+    @Override
+    public Collection<TableSegment> getAllTables() {
+        return tables;
+    }
 }
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/sql/statement/dcl/RevokeStatement.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/sql/statement/dcl/RevokeStatement.java
index 4f6da7015de..be73504f0fc 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/sql/statement/dcl/RevokeStatement.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/sql/statement/dcl/RevokeStatement.java
@@ -31,4 +31,9 @@ import java.util.LinkedList;
 public final class RevokeStatement extends DCLStatement implements TableSegmentsAvailable {
     
     private final Collection<TableSegment> tables = new LinkedList<>();
+    
+    @Override
+    public Collection<TableSegment> getAllTables() {
+        return tables;
+    }
 }
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/sql/statement/ddl/AlterIndexStatement.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/sql/statement/ddl/AlterIndexStatement.java
index 542f6c6c613..bb44550861e 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/sql/statement/ddl/AlterIndexStatement.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/sql/statement/ddl/AlterIndexStatement.java
@@ -22,16 +22,24 @@ import lombok.Setter;
 import org.apache.shardingsphere.sql.parser.sql.segment.ddl.index.IndexSegment;
 import org.apache.shardingsphere.sql.parser.sql.segment.generic.TableSegment;
 import org.apache.shardingsphere.sql.parser.sql.statement.generic.IndexSegmentAvailable;
-import org.apache.shardingsphere.sql.parser.sql.statement.generic.TableSegmentAvailable;
+import org.apache.shardingsphere.sql.parser.sql.statement.generic.TableSegmentsAvailable;
+
+import java.util.Collection;
+import java.util.Collections;
 
 /**
  * Alter index statement.
  */
 @Getter
 @Setter
-public final class AlterIndexStatement extends DDLStatement implements TableSegmentAvailable, IndexSegmentAvailable {
+public final class AlterIndexStatement extends DDLStatement implements TableSegmentsAvailable, IndexSegmentAvailable {
     
     private IndexSegment index;
     
     private TableSegment table;
+    
+    @Override
+    public Collection<TableSegment> getAllTables() {
+        return null == table ? Collections.<TableSegment>emptyList() : Collections.singletonList(table);
+    }
 }
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/sql/statement/ddl/AlterTableStatement.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/sql/statement/ddl/AlterTableStatement.java
index cd89e4b2c24..89b7ba88a70 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/sql/statement/ddl/AlterTableStatement.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/sql/statement/ddl/AlterTableStatement.java
@@ -18,33 +18,52 @@
 package org.apache.shardingsphere.sql.parser.sql.statement.ddl;
 
 import lombok.Getter;
+import lombok.RequiredArgsConstructor;
+import org.apache.shardingsphere.sql.parser.sql.segment.ddl.column.ColumnDefinitionSegment;
 import org.apache.shardingsphere.sql.parser.sql.segment.ddl.column.alter.AddColumnDefinitionSegment;
 import org.apache.shardingsphere.sql.parser.sql.segment.ddl.column.alter.DropColumnDefinitionSegment;
 import org.apache.shardingsphere.sql.parser.sql.segment.ddl.column.alter.ModifyColumnDefinitionSegment;
-import org.apache.shardingsphere.sql.parser.sql.segment.ddl.column.position.ColumnPositionSegment;
 import org.apache.shardingsphere.sql.parser.sql.segment.ddl.constraint.ConstraintDefinitionSegment;
 import org.apache.shardingsphere.sql.parser.sql.segment.generic.TableSegment;
 import org.apache.shardingsphere.sql.parser.sql.statement.generic.TableSegmentsAvailable;
 
 import java.util.Collection;
 import java.util.LinkedList;
-import java.util.TreeSet;
 
 /**
  * Alter table statement.
  */
+@RequiredArgsConstructor
 @Getter
 public final class AlterTableStatement extends DDLStatement implements TableSegmentsAvailable {
     
-    private final Collection<TableSegment> tables = new LinkedList<>();
+    private final TableSegment table;
     
     private final Collection<AddColumnDefinitionSegment> addColumnDefinitions = new LinkedList<>();
     
-    private final Collection<ConstraintDefinitionSegment> addConstraintDefinitions = new LinkedList<>();
-    
     private final Collection<ModifyColumnDefinitionSegment> modifyColumnDefinitions = new LinkedList<>();
     
     private final Collection<DropColumnDefinitionSegment> dropColumnDefinitions = new LinkedList<>();
     
-    private final Collection<ColumnPositionSegment> changedPositionColumns = new TreeSet<>();
+    private final Collection<ConstraintDefinitionSegment> addConstraintDefinitions = new LinkedList<>();
+    
+    @Override
+    public Collection<TableSegment> getAllTables() {
+        Collection<TableSegment> result = new LinkedList<>();
+        result.add(table);
+        for (AddColumnDefinitionSegment each : addColumnDefinitions) {
+            for (ColumnDefinitionSegment columnDefinition : each.getColumnDefinitions()) {
+                result.addAll(columnDefinition.getReferencedTables());
+            }
+        }
+        for (ModifyColumnDefinitionSegment each : modifyColumnDefinitions) {
+            result.addAll(each.getColumnDefinition().getReferencedTables());
+        }
+        for (ConstraintDefinitionSegment each : addConstraintDefinitions) {
+            if (each.getReferencedTable().isPresent()) {
+                result.add(each.getReferencedTable().get());
+            }
+        }
+        return result;
+    }
 }
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/sql/statement/ddl/CreateIndexStatement.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/sql/statement/ddl/CreateIndexStatement.java
index cf0551756b1..61309a83a3e 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/sql/statement/ddl/CreateIndexStatement.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/sql/statement/ddl/CreateIndexStatement.java
@@ -22,16 +22,24 @@ import lombok.Setter;
 import org.apache.shardingsphere.sql.parser.sql.segment.ddl.index.IndexSegment;
 import org.apache.shardingsphere.sql.parser.sql.segment.generic.TableSegment;
 import org.apache.shardingsphere.sql.parser.sql.statement.generic.IndexSegmentAvailable;
-import org.apache.shardingsphere.sql.parser.sql.statement.generic.TableSegmentAvailable;
+import org.apache.shardingsphere.sql.parser.sql.statement.generic.TableSegmentsAvailable;
+
+import java.util.Collection;
+import java.util.Collections;
 
 /**
  * Create index statement.
  */
 @Getter
 @Setter
-public final class CreateIndexStatement extends DDLStatement implements TableSegmentAvailable, IndexSegmentAvailable {
+public final class CreateIndexStatement extends DDLStatement implements TableSegmentsAvailable, IndexSegmentAvailable {
     
     private IndexSegment index;
     
     private TableSegment table;
+    
+    @Override
+    public Collection<TableSegment> getAllTables() {
+        return null == table ? Collections.<TableSegment>emptyList() : Collections.singletonList(table);
+    }
 }
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/sql/statement/ddl/CreateTableStatement.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/sql/statement/ddl/CreateTableStatement.java
index 777eb7461d5..96b746aebea 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/sql/statement/ddl/CreateTableStatement.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/sql/statement/ddl/CreateTableStatement.java
@@ -18,6 +18,7 @@
 package org.apache.shardingsphere.sql.parser.sql.statement.ddl;
 
 import lombok.Getter;
+import lombok.RequiredArgsConstructor;
 import org.apache.shardingsphere.sql.parser.sql.segment.ddl.column.ColumnDefinitionSegment;
 import org.apache.shardingsphere.sql.parser.sql.segment.ddl.constraint.ConstraintDefinitionSegment;
 import org.apache.shardingsphere.sql.parser.sql.segment.ddl.index.IndexSegment;
@@ -31,14 +32,30 @@ import java.util.LinkedList;
 /**
  * Create table statement.
  */
+@RequiredArgsConstructor
 @Getter
 public final class CreateTableStatement extends DDLStatement implements TableSegmentsAvailable, IndexSegmentsAvailable {
     
-    private final Collection<TableSegment> tables = new LinkedList<>();
+    private final TableSegment table;
     
     private final Collection<ColumnDefinitionSegment> columnDefinitions = new LinkedList<>();
     
     private final Collection<ConstraintDefinitionSegment> constraintDefinitions = new LinkedList<>();
     
     private final Collection<IndexSegment> indexes = new LinkedList<>();
+    
+    @Override
+    public Collection<TableSegment> getAllTables() {
+        Collection<TableSegment> result = new LinkedList<>();
+        result.add(table);
+        for (ColumnDefinitionSegment each : columnDefinitions) {
+            result.addAll(each.getReferencedTables());
+        }
+        for (ConstraintDefinitionSegment each : constraintDefinitions) {
+            if (each.getReferencedTable().isPresent()) {
+                result.add(each.getReferencedTable().get());
+            }
+        }
+        return result;
+    }
 }
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/sql/statement/ddl/DropIndexStatement.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/sql/statement/ddl/DropIndexStatement.java
index 84dbc0e8b95..b96cd64c7e4 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/sql/statement/ddl/DropIndexStatement.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/sql/statement/ddl/DropIndexStatement.java
@@ -22,9 +22,10 @@ import lombok.Setter;
 import org.apache.shardingsphere.sql.parser.sql.segment.ddl.index.IndexSegment;
 import org.apache.shardingsphere.sql.parser.sql.segment.generic.TableSegment;
 import org.apache.shardingsphere.sql.parser.sql.statement.generic.IndexSegmentsAvailable;
-import org.apache.shardingsphere.sql.parser.sql.statement.generic.TableSegmentAvailable;
+import org.apache.shardingsphere.sql.parser.sql.statement.generic.TableSegmentsAvailable;
 
 import java.util.Collection;
+import java.util.Collections;
 import java.util.LinkedList;
 
 /**
@@ -32,9 +33,14 @@ import java.util.LinkedList;
  */
 @Getter
 @Setter
-public final class DropIndexStatement extends DDLStatement implements TableSegmentAvailable, IndexSegmentsAvailable {
+public final class DropIndexStatement extends DDLStatement implements TableSegmentsAvailable, IndexSegmentsAvailable {
     
     private final Collection<IndexSegment> indexes = new LinkedList<>();
     
     private TableSegment table;
+    
+    @Override
+    public Collection<TableSegment> getAllTables() {
+        return null == table ? Collections.<TableSegment>emptyList() : Collections.singletonList(table);
+    }
 }
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/sql/statement/ddl/DropTableStatement.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/sql/statement/ddl/DropTableStatement.java
index 2c68d4e9ba3..4838bd07574 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/sql/statement/ddl/DropTableStatement.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/sql/statement/ddl/DropTableStatement.java
@@ -18,7 +18,6 @@
 package org.apache.shardingsphere.sql.parser.sql.statement.ddl;
 
 import lombok.Getter;
-import lombok.Setter;
 import org.apache.shardingsphere.sql.parser.sql.segment.generic.TableSegment;
 import org.apache.shardingsphere.sql.parser.sql.statement.generic.TableSegmentsAvailable;
 
@@ -29,8 +28,12 @@ import java.util.LinkedList;
  * Drop table statement.
  */
 @Getter
-@Setter
 public final class DropTableStatement extends DDLStatement implements TableSegmentsAvailable {
     
     private final Collection<TableSegment> tables = new LinkedList<>();
+    
+    @Override
+    public Collection<TableSegment> getAllTables() {
+        return tables;
+    }
 }
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/sql/statement/dml/InsertStatement.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/sql/statement/dml/InsertStatement.java
index 0488a6cd841..5fd1267f4d3 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/sql/statement/dml/InsertStatement.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/sql/statement/dml/InsertStatement.java
@@ -28,7 +28,7 @@ import org.apache.shardingsphere.sql.parser.sql.segment.dml.column.InsertColumns
 import org.apache.shardingsphere.sql.parser.sql.segment.dml.column.OnDuplicateKeyColumnsSegment;
 import org.apache.shardingsphere.sql.parser.sql.segment.dml.expr.ExpressionSegment;
 import org.apache.shardingsphere.sql.parser.sql.segment.generic.TableSegment;
-import org.apache.shardingsphere.sql.parser.sql.statement.generic.TableSegmentAvailable;
+import org.apache.shardingsphere.sql.parser.sql.statement.generic.TableSegmentsAvailable;
 
 import java.util.ArrayList;
 import java.util.Collection;
@@ -41,7 +41,7 @@ import java.util.List;
  */
 @Getter
 @Setter
-public final class InsertStatement extends DMLStatement implements TableSegmentAvailable {
+public final class InsertStatement extends DMLStatement implements TableSegmentsAvailable {
     
     private TableSegment table;
     
@@ -171,4 +171,9 @@ public final class InsertStatement extends DMLStatement implements TableSegmentA
         }
         return result;
     }
+    
+    @Override
+    public Collection<TableSegment> getAllTables() {
+        return Collections.singletonList(table);
+    }
 }
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/sql/statement/dml/SelectStatement.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/sql/statement/dml/SelectStatement.java
index fdc378ad3cd..2f77a2e9838 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/sql/statement/dml/SelectStatement.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/sql/statement/dml/SelectStatement.java
@@ -56,6 +56,11 @@ public final class SelectStatement extends DMLStatement implements TableSegments
     
     private LockSegment lock;
     
+    @Override
+    public Collection<TableSegment> getAllTables() {
+        return tables;
+    }
+    
     @Override
     public Optional<WhereSegment> getWhere() {
         return Optional.fromNullable(where);
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/sql/statement/generic/TableSegmentAvailable.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/sql/statement/generic/TableSegmentAvailable.java
deleted file mode 100644
index 798da4633b7..00000000000
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/sql/statement/generic/TableSegmentAvailable.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * 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.shardingsphere.sql.parser.sql.statement.generic;
-
-import org.apache.shardingsphere.sql.parser.sql.segment.generic.TableSegment;
-
-/**
- * Table segment available.
- */
-public interface TableSegmentAvailable {
-    
-    /**
-     * Get table segment.
-     * 
-     * @return table segment
-     */
-    TableSegment getTable();
-    
-    /**
-     * Set table segment.
-     * 
-     * @param table table segment
-     */
-    void setTable(TableSegment table);
-}
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/sql/statement/generic/TableSegmentsAvailable.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/sql/statement/generic/TableSegmentsAvailable.java
index f8e806bf978..18551148884 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/sql/statement/generic/TableSegmentsAvailable.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/sql/statement/generic/TableSegmentsAvailable.java
@@ -27,9 +27,9 @@ import java.util.Collection;
 public interface TableSegmentsAvailable {
     
     /**
-     * Get table segments.
+     * Get all table segments.
      * 
-     * @return table segments
+     * @return all table segments
      */
-    Collection<TableSegment> getTables();
+    Collection<TableSegment> getAllTables();
 }
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-mysql/src/main/java/org/apache/shardingsphere/sql/parser/visitor/impl/MySQLDDLVisitor.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-mysql/src/main/java/org/apache/shardingsphere/sql/parser/visitor/impl/MySQLDDLVisitor.java
index 7a5ba9a1ba4..64e04879763 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-mysql/src/main/java/org/apache/shardingsphere/sql/parser/visitor/impl/MySQLDDLVisitor.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-mysql/src/main/java/org/apache/shardingsphere/sql/parser/visitor/impl/MySQLDDLVisitor.java
@@ -82,22 +82,14 @@ public final class MySQLDDLVisitor extends MySQLVisitor implements DDLVisitor {
     @SuppressWarnings("unchecked")
     @Override
     public ASTNode visitCreateTable(final CreateTableContext ctx) {
-        CreateTableStatement result = new CreateTableStatement();
-        TableSegment table = (TableSegment) visit(ctx.tableName());
-        result.getTables().add(table);
+        CreateTableStatement result = new CreateTableStatement((TableSegment) visit(ctx.tableName()));
         if (null != ctx.createDefinitionClause()) {
             CollectionValue<CreateDefinitionSegment> createDefinitions = (CollectionValue<CreateDefinitionSegment>) visit(ctx.createDefinitionClause());
             for (CreateDefinitionSegment each : createDefinitions.getValue()) {
                 if (each instanceof ColumnDefinitionSegment) {
                     result.getColumnDefinitions().add((ColumnDefinitionSegment) each);
-                    result.getTables().addAll(((ColumnDefinitionSegment) each).getReferencedTables());
                 } else if (each instanceof ConstraintDefinitionSegment) {
                     result.getConstraintDefinitions().add((ConstraintDefinitionSegment) each);
-                    // CHECKSTYLE:OFF
-                    if (((ConstraintDefinitionSegment) each).getReferencedTable().isPresent()) {
-                        // CHECKSTYLE:ON
-                        result.getTables().add(((ConstraintDefinitionSegment) each).getReferencedTable().get());
-                    }
                 }
             }
         }
@@ -129,28 +121,17 @@ public final class MySQLDDLVisitor extends MySQLVisitor implements DDLVisitor {
     @SuppressWarnings("unchecked")
     @Override
     public ASTNode visitAlterTable(final AlterTableContext ctx) {
-        AlterTableStatement result = new AlterTableStatement();
-        TableSegment table = (TableSegment) visit(ctx.tableName());
-        result.getTables().add(table);
+        AlterTableStatement result = new AlterTableStatement((TableSegment) visit(ctx.tableName()));
         if (null != ctx.alterDefinitionClause()) {
             for (AlterDefinitionSegment each : ((CollectionValue<AlterDefinitionSegment>) visit(ctx.alterDefinitionClause())).getValue()) {
                 if (each instanceof AddColumnDefinitionSegment) {
                     result.getAddColumnDefinitions().add((AddColumnDefinitionSegment) each);
-                    for (ColumnDefinitionSegment columnDefinition : ((AddColumnDefinitionSegment) each).getColumnDefinitions()) {
-                        result.getTables().addAll(columnDefinition.getReferencedTables());
-                    }
                 } else if (each instanceof ModifyColumnDefinitionSegment) {
                     result.getModifyColumnDefinitions().add((ModifyColumnDefinitionSegment) each);
-                    result.getTables().addAll(((ModifyColumnDefinitionSegment) each).getColumnDefinition().getReferencedTables());
                 } else if (each instanceof DropColumnDefinitionSegment) {
                     result.getDropColumnDefinitions().add((DropColumnDefinitionSegment) each);
                 } else if (each instanceof ConstraintDefinitionSegment) {
                     result.getAddConstraintDefinitions().add((ConstraintDefinitionSegment) each);
-                    // CHECKSTYLE:OFF
-                    if (((ConstraintDefinitionSegment) each).getReferencedTable().isPresent()) {
-                        // CHECKSTYLE:ON
-                        result.getTables().add(((ConstraintDefinitionSegment) each).getReferencedTable().get());
-                    }
                 }
             }
         }
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-oracle/src/main/java/org/apache/shardingsphere/sql/parser/visitor/impl/OracleDDLVisitor.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-oracle/src/main/java/org/apache/shardingsphere/sql/parser/visitor/impl/OracleDDLVisitor.java
index 696be6fe64a..87d149d96bf 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-oracle/src/main/java/org/apache/shardingsphere/sql/parser/visitor/impl/OracleDDLVisitor.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-oracle/src/main/java/org/apache/shardingsphere/sql/parser/visitor/impl/OracleDDLVisitor.java
@@ -72,21 +72,14 @@ public final class OracleDDLVisitor extends OracleVisitor implements DDLVisitor
     @SuppressWarnings("unchecked")
     @Override
     public ASTNode visitCreateTable(final CreateTableContext ctx) {
-        CreateTableStatement result = new CreateTableStatement();
-        result.getTables().add((TableSegment) visit(ctx.tableName()));
+        CreateTableStatement result = new CreateTableStatement((TableSegment) visit(ctx.tableName()));
         if (null != ctx.createDefinitionClause()) {
             CollectionValue<CreateDefinitionSegment> createDefinitions = (CollectionValue<CreateDefinitionSegment>) visit(ctx.createDefinitionClause());
             for (CreateDefinitionSegment each : createDefinitions.getValue()) {
                 if (each instanceof ColumnDefinitionSegment) {
                     result.getColumnDefinitions().add((ColumnDefinitionSegment) each);
-                    result.getTables().addAll(((ColumnDefinitionSegment) each).getReferencedTables());
                 } else if (each instanceof ConstraintDefinitionSegment) {
                     result.getConstraintDefinitions().add((ConstraintDefinitionSegment) each);
-                    // CHECKSTYLE:OFF
-                    if (((ConstraintDefinitionSegment) each).getReferencedTable().isPresent()) {
-                        // CHECKSTYLE:ON
-                        result.getTables().add(((ConstraintDefinitionSegment) each).getReferencedTable().get());
-                    }
                 }
             }
         }
@@ -162,38 +155,23 @@ public final class OracleDDLVisitor extends OracleVisitor implements DDLVisitor
     @SuppressWarnings("unchecked")
     @Override
     public ASTNode visitAlterTable(final AlterTableContext ctx) {
-        AlterTableStatement result = new AlterTableStatement();
-        TableSegment table = (TableSegment) visit(ctx.tableName());
-        result.getTables().add(table);
+        AlterTableStatement result = new AlterTableStatement((TableSegment) visit(ctx.tableName()));
         if (null != ctx.alterDefinitionClause()) {
             for (AlterDefinitionSegment each : ((CollectionValue<AlterDefinitionSegment>) visit(ctx.alterDefinitionClause())).getValue()) {
                 if (each instanceof AddColumnDefinitionSegment) {
                     result.getAddColumnDefinitions().add((AddColumnDefinitionSegment) each);
-                    for (ColumnDefinitionSegment columnDefinition : ((AddColumnDefinitionSegment) each).getColumnDefinitions()) {
-                        result.getTables().addAll(columnDefinition.getReferencedTables());
-                    }
                 } else if (each instanceof ModifyColumnDefinitionSegment) {
                     result.getModifyColumnDefinitions().add((ModifyColumnDefinitionSegment) each);
-                    // CHECKSTYLE:OFF
-                    if (null != ((ModifyColumnDefinitionSegment) each).getColumnDefinition()) {
-                        // CHECKSTYLE:ON
-                        result.getTables().addAll(((ModifyColumnDefinitionSegment) each).getColumnDefinition().getReferencedTables());
-                    }
                 } else if (each instanceof DropColumnDefinitionSegment) {
                     result.getDropColumnDefinitions().add((DropColumnDefinitionSegment) each);
                 } else if (each instanceof ConstraintDefinitionSegment) {
                     result.getAddConstraintDefinitions().add((ConstraintDefinitionSegment) each);
-                    // CHECKSTYLE:OFF
-                    if (((ConstraintDefinitionSegment) each).getReferencedTable().isPresent()) {
-                        // CHECKSTYLE:ON
-                        result.getTables().add(((ConstraintDefinitionSegment) each).getReferencedTable().get());
-                    }
                 }
             }
         }
         return result;
     }
-
+    
     @SuppressWarnings("unchecked")
     @Override
     public ASTNode visitAlterDefinitionClause(final AlterDefinitionClauseContext ctx) {
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-postgresql/src/main/java/org/apache/shardingsphere/sql/parser/visitor/impl/PostgreSQLDDLVisitor.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-postgresql/src/main/java/org/apache/shardingsphere/sql/parser/visitor/impl/PostgreSQLDDLVisitor.java
index 73717cbaa45..d235a3e8b67 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-postgresql/src/main/java/org/apache/shardingsphere/sql/parser/visitor/impl/PostgreSQLDDLVisitor.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-postgresql/src/main/java/org/apache/shardingsphere/sql/parser/visitor/impl/PostgreSQLDDLVisitor.java
@@ -73,21 +73,14 @@ public final class PostgreSQLDDLVisitor extends PostgreSQLVisitor implements DDL
     @SuppressWarnings("unchecked")
     @Override
     public ASTNode visitCreateTable(final CreateTableContext ctx) {
-        CreateTableStatement result = new CreateTableStatement();
-        result.getTables().add((TableSegment) visit(ctx.tableName()));
+        CreateTableStatement result = new CreateTableStatement((TableSegment) visit(ctx.tableName()));
         if (null != ctx.createDefinitionClause()) {
             CollectionValue<CreateDefinitionSegment> createDefinitions = (CollectionValue<CreateDefinitionSegment>) visit(ctx.createDefinitionClause());
             for (CreateDefinitionSegment each : createDefinitions.getValue()) {
                 if (each instanceof ColumnDefinitionSegment) {
                     result.getColumnDefinitions().add((ColumnDefinitionSegment) each);
-                    result.getTables().addAll(((ColumnDefinitionSegment) each).getReferencedTables());
                 } else if (each instanceof ConstraintDefinitionSegment) {
                     result.getConstraintDefinitions().add((ConstraintDefinitionSegment) each);
-                    // CHECKSTYLE:OFF
-                    if (((ConstraintDefinitionSegment) each).getReferencedTable().isPresent()) {
-                        // CHECKSTYLE:ON
-                        result.getTables().add(((ConstraintDefinitionSegment) each).getReferencedTable().get());
-                    }
                 }
             }
         }
@@ -111,32 +104,17 @@ public final class PostgreSQLDDLVisitor extends PostgreSQLVisitor implements DDL
     @SuppressWarnings("unchecked")
     @Override
     public ASTNode visitAlterTable(final AlterTableContext ctx) {
-        AlterTableStatement result = new AlterTableStatement();
-        TableSegment table = (TableSegment) visit(ctx.tableNameClause().tableName());
-        result.getTables().add(table);
+        AlterTableStatement result = new AlterTableStatement((TableSegment) visit(ctx.tableNameClause().tableName()));
         if (null != ctx.alterDefinitionClause()) {
             for (AlterDefinitionSegment each : ((CollectionValue<AlterDefinitionSegment>) visit(ctx.alterDefinitionClause())).getValue()) {
                 if (each instanceof AddColumnDefinitionSegment) {
                     result.getAddColumnDefinitions().add((AddColumnDefinitionSegment) each);
-                    for (ColumnDefinitionSegment columnDefinition : ((AddColumnDefinitionSegment) each).getColumnDefinitions()) {
-                        result.getTables().addAll(columnDefinition.getReferencedTables());
-                    }
                 } else if (each instanceof ModifyColumnDefinitionSegment) {
                     result.getModifyColumnDefinitions().add((ModifyColumnDefinitionSegment) each);
-                    // CHECKSTYLE:OFF
-                    if (null != ((ModifyColumnDefinitionSegment) each).getColumnDefinition()) {
-                        // CHECKSTYLE:ON
-                        result.getTables().addAll(((ModifyColumnDefinitionSegment) each).getColumnDefinition().getReferencedTables());
-                    }
                 } else if (each instanceof DropColumnDefinitionSegment) {
                     result.getDropColumnDefinitions().add((DropColumnDefinitionSegment) each);
                 } else if (each instanceof ConstraintDefinitionSegment) {
                     result.getAddConstraintDefinitions().add((ConstraintDefinitionSegment) each);
-                    // CHECKSTYLE:OFF
-                    if (((ConstraintDefinitionSegment) each).getReferencedTable().isPresent()) {
-                        // CHECKSTYLE:ON
-                        result.getTables().add(((ConstraintDefinitionSegment) each).getReferencedTable().get());
-                    }
                 }
             }
         }
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-relation/src/main/java/org/apache/shardingsphere/sql/parser/relation/segment/table/TablesContext.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-relation/src/main/java/org/apache/shardingsphere/sql/parser/relation/segment/table/TablesContext.java
index 927b41a043e..39a6dbd905c 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-relation/src/main/java/org/apache/shardingsphere/sql/parser/relation/segment/table/TablesContext.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-relation/src/main/java/org/apache/shardingsphere/sql/parser/relation/segment/table/TablesContext.java
@@ -24,7 +24,6 @@ import org.apache.shardingsphere.sql.parser.relation.metadata.RelationMetas;
 import org.apache.shardingsphere.sql.parser.sql.segment.dml.column.ColumnSegment;
 import org.apache.shardingsphere.sql.parser.sql.segment.generic.TableSegment;
 import org.apache.shardingsphere.sql.parser.sql.statement.SQLStatement;
-import org.apache.shardingsphere.sql.parser.sql.statement.generic.TableSegmentAvailable;
 import org.apache.shardingsphere.sql.parser.sql.statement.generic.TableSegmentsAvailable;
 
 import java.util.ArrayList;
@@ -64,14 +63,7 @@ public final class TablesContext {
     }
     
     private Collection<TableSegment> getTableSegments(final SQLStatement sqlStatement) {
-        if (sqlStatement instanceof TableSegmentAvailable) {
-            TableSegment table = ((TableSegmentAvailable) sqlStatement).getTable();
-            return null == table ? Collections.<TableSegment>emptyList() : Collections.singletonList(table);
-        }
-        if (sqlStatement instanceof TableSegmentsAvailable) {
-            return ((TableSegmentsAvailable) sqlStatement).getTables();
-        }
-        return Collections.emptyList();
+        return sqlStatement instanceof TableSegmentsAvailable ? ((TableSegmentsAvailable) sqlStatement).getAllTables() : Collections.<TableSegment>emptyList();
     }
     
     private void setSchema(final TableSegment tableSegment) {
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-sql92/src/main/java/org/apache/shardingsphere/sql/parser/visitor/impl/SQL92DDLVisitor.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-sql92/src/main/java/org/apache/shardingsphere/sql/parser/visitor/impl/SQL92DDLVisitor.java
index 5da283c6937..d0ac8bbda0f 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-sql92/src/main/java/org/apache/shardingsphere/sql/parser/visitor/impl/SQL92DDLVisitor.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-sql92/src/main/java/org/apache/shardingsphere/sql/parser/visitor/impl/SQL92DDLVisitor.java
@@ -57,21 +57,14 @@ public final class SQL92DDLVisitor extends SQL92Visitor implements DDLVisitor {
     @SuppressWarnings("unchecked")
     @Override
     public ASTNode visitCreateTable(final CreateTableContext ctx) {
-        CreateTableStatement result = new CreateTableStatement();
-        result.getTables().add((TableSegment) visit(ctx.tableName()));
+        CreateTableStatement result = new CreateTableStatement((TableSegment) visit(ctx.tableName()));
         if (null != ctx.createDefinitionClause()) {
             CollectionValue<CreateDefinitionSegment> createDefinitions = (CollectionValue<CreateDefinitionSegment>) visit(ctx.createDefinitionClause());
             for (CreateDefinitionSegment each : createDefinitions.getValue()) {
                 if (each instanceof ColumnDefinitionSegment) {
                     result.getColumnDefinitions().add((ColumnDefinitionSegment) each);
-                    result.getTables().addAll(((ColumnDefinitionSegment) each).getReferencedTables());
                 } else if (each instanceof ConstraintDefinitionSegment) {
                     result.getConstraintDefinitions().add((ConstraintDefinitionSegment) each);
-                    // CHECKSTYLE:OFF
-                    if (((ConstraintDefinitionSegment) each).getReferencedTable().isPresent()) {
-                        // CHECKSTYLE:ON
-                        result.getTables().add(((ConstraintDefinitionSegment) each).getReferencedTable().get());
-                    }
                 }
             }
         }
@@ -80,13 +73,13 @@ public final class SQL92DDLVisitor extends SQL92Visitor implements DDLVisitor {
     
     @Override
     public ASTNode visitCreateDefinitionClause(final CreateDefinitionClauseContext ctx) {
-        CreateTableStatement result = new CreateTableStatement();
+        CollectionValue<CreateDefinitionSegment> result = new CollectionValue<>();
         for (CreateDefinitionContext each : ctx.createDefinition()) {
             if (null != each.columnDefinition()) {
-                result.getColumnDefinitions().add((ColumnDefinitionSegment) visit(each.columnDefinition()));
+                result.getValue().add((ColumnDefinitionSegment) visit(each.columnDefinition()));
             }
             if (null != each.constraintDefinition()) {
-                result.getConstraintDefinitions().add((ConstraintDefinitionSegment) visit(each.constraintDefinition()));
+                result.getValue().add((ConstraintDefinitionSegment) visit(each.constraintDefinition()));
             }
         }
         return result;
@@ -132,28 +125,17 @@ public final class SQL92DDLVisitor extends SQL92Visitor implements DDLVisitor {
     @SuppressWarnings("unchecked")
     @Override
     public ASTNode visitAlterTable(final AlterTableContext ctx) {
-        AlterTableStatement result = new AlterTableStatement();
-        TableSegment table = (TableSegment) visit(ctx.tableName());
-        result.getTables().add(table);
+        AlterTableStatement result = new AlterTableStatement((TableSegment) visit(ctx.tableName()));
         if (null != ctx.alterDefinitionClause()) {
             for (AlterDefinitionSegment each : ((CollectionValue<AlterDefinitionSegment>) visit(ctx.alterDefinitionClause())).getValue()) {
                 if (each instanceof AddColumnDefinitionSegment) {
                     result.getAddColumnDefinitions().add((AddColumnDefinitionSegment) each);
-                    for (ColumnDefinitionSegment columnDefinition : ((AddColumnDefinitionSegment) each).getColumnDefinitions()) {
-                        result.getTables().addAll(columnDefinition.getReferencedTables());
-                    }
                 } else if (each instanceof ModifyColumnDefinitionSegment) {
                     result.getModifyColumnDefinitions().add((ModifyColumnDefinitionSegment) each);
-                    result.getTables().addAll(((ModifyColumnDefinitionSegment) each).getColumnDefinition().getReferencedTables());
                 } else if (each instanceof DropColumnDefinitionSegment) {
                     result.getDropColumnDefinitions().add((DropColumnDefinitionSegment) each);
                 } else if (each instanceof ConstraintDefinitionSegment) {
                     result.getAddConstraintDefinitions().add((ConstraintDefinitionSegment) each);
-                    // CHECKSTYLE:OFF
-                    if (((ConstraintDefinitionSegment) each).getReferencedTable().isPresent()) {
-                        // CHECKSTYLE:ON
-                        result.getTables().add(((ConstraintDefinitionSegment) each).getReferencedTable().get());
-                    }
                 }
             }
         }
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-sqlserver/src/main/java/org/apache/shardingsphere/sql/parser/visitor/impl/SQLServerDDLVisitor.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-sqlserver/src/main/java/org/apache/shardingsphere/sql/parser/visitor/impl/SQLServerDDLVisitor.java
index 70ecb9880fa..fd78ead978a 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-sqlserver/src/main/java/org/apache/shardingsphere/sql/parser/visitor/impl/SQLServerDDLVisitor.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-sqlserver/src/main/java/org/apache/shardingsphere/sql/parser/visitor/impl/SQLServerDDLVisitor.java
@@ -71,21 +71,14 @@ public final class SQLServerDDLVisitor extends SQLServerVisitor implements DDLVi
     @SuppressWarnings("unchecked")
     @Override
     public ASTNode visitCreateTable(final CreateTableContext ctx) {
-        CreateTableStatement result = new CreateTableStatement();
-        result.getTables().add((TableSegment) visit(ctx.tableName()));
+        CreateTableStatement result = new CreateTableStatement((TableSegment) visit(ctx.tableName()));
         if (null != ctx.createDefinitionClause()) {
             CollectionValue<CreateDefinitionSegment> createDefinitions = (CollectionValue<CreateDefinitionSegment>) visit(ctx.createDefinitionClause());
             for (CreateDefinitionSegment each : createDefinitions.getValue()) {
                 if (each instanceof ColumnDefinitionSegment) {
                     result.getColumnDefinitions().add((ColumnDefinitionSegment) each);
-                    result.getTables().addAll(((ColumnDefinitionSegment) each).getReferencedTables());
                 } else if (each instanceof ConstraintDefinitionSegment) {
                     result.getConstraintDefinitions().add((ConstraintDefinitionSegment) each);
-                    // CHECKSTYLE:OFF
-                    if (((ConstraintDefinitionSegment) each).getReferencedTable().isPresent()) {
-                        // CHECKSTYLE:ON
-                        result.getTables().add(((ConstraintDefinitionSegment) each).getReferencedTable().get());
-                    }
                 }
             }
         }
@@ -165,32 +158,17 @@ public final class SQLServerDDLVisitor extends SQLServerVisitor implements DDLVi
     @SuppressWarnings("unchecked")
     @Override
     public ASTNode visitAlterTable(final AlterTableContext ctx) {
-        AlterTableStatement result = new AlterTableStatement();
-        TableSegment table = (TableSegment) visit(ctx.tableName());
-        result.getTables().add(table);
+        AlterTableStatement result = new AlterTableStatement((TableSegment) visit(ctx.tableName()));
         if (null != ctx.alterDefinitionClause()) {
             for (AlterDefinitionSegment each : ((CollectionValue<AlterDefinitionSegment>) visit(ctx.alterDefinitionClause())).getValue()) {
                 if (each instanceof AddColumnDefinitionSegment) {
                     result.getAddColumnDefinitions().add((AddColumnDefinitionSegment) each);
-                    for (ColumnDefinitionSegment columnDefinition : ((AddColumnDefinitionSegment) each).getColumnDefinitions()) {
-                        result.getTables().addAll(columnDefinition.getReferencedTables());
-                    }
                 } else if (each instanceof ModifyColumnDefinitionSegment) {
                     result.getModifyColumnDefinitions().add((ModifyColumnDefinitionSegment) each);
-                    // CHECKSTYLE:OFF
-                    if (null != ((ModifyColumnDefinitionSegment) each).getColumnDefinition()) {
-                        // CHECKSTYLE:ON
-                        result.getTables().addAll(((ModifyColumnDefinitionSegment) each).getColumnDefinition().getReferencedTables());
-                    }
                 } else if (each instanceof DropColumnDefinitionSegment) {
                     result.getDropColumnDefinitions().add((DropColumnDefinitionSegment) each);
                 } else if (each instanceof ConstraintDefinitionSegment) {
                     result.getAddConstraintDefinitions().add((ConstraintDefinitionSegment) each);
-                    // CHECKSTYLE:OFF
-                    if (((ConstraintDefinitionSegment) each).getReferencedTable().isPresent()) {
-                        // CHECKSTYLE:ON
-                        result.getTables().add(((ConstraintDefinitionSegment) each).getReferencedTable().get());
-                    }
                 }
             }
         }


Test patch:
diff --git a/shadow-core/shadow-core-rewrite/src/test/java/org/apache/shardingsphere/shadow/rewrite/judgement/impl/PreparedJudgementEngineTest.java b/shadow-core/shadow-core-rewrite/src/test/java/org/apache/shardingsphere/shadow/rewrite/judgement/impl/PreparedJudgementEngineTest.java
index 7d7d0ae7f11..c49a5f6bd0a 100644
--- a/shadow-core/shadow-core-rewrite/src/test/java/org/apache/shardingsphere/shadow/rewrite/judgement/impl/PreparedJudgementEngineTest.java
+++ b/shadow-core/shadow-core-rewrite/src/test/java/org/apache/shardingsphere/shadow/rewrite/judgement/impl/PreparedJudgementEngineTest.java
@@ -23,6 +23,7 @@ import org.apache.shardingsphere.sql.parser.relation.metadata.RelationMetas;
 import org.apache.shardingsphere.sql.parser.relation.statement.impl.InsertSQLStatementContext;
 import org.apache.shardingsphere.sql.parser.sql.segment.dml.column.ColumnSegment;
 import org.apache.shardingsphere.sql.parser.sql.segment.dml.column.InsertColumnsSegment;
+import org.apache.shardingsphere.sql.parser.sql.segment.generic.TableSegment;
 import org.apache.shardingsphere.sql.parser.sql.statement.dml.InsertStatement;
 import org.apache.shardingsphere.sql.parser.sql.value.identifier.IdentifierValue;
 import org.junit.Assert;
@@ -43,6 +44,7 @@ public final class PreparedJudgementEngineTest {
         shadowRuleConfiguration.setColumn("shadow");
         ShadowRule shadowRule = new ShadowRule(shadowRuleConfiguration);
         InsertStatement insertStatement = new InsertStatement();
+        insertStatement.setTable(new TableSegment(0, 0, new IdentifierValue("tbl")));
         InsertColumnsSegment insertColumnsSegment = new InsertColumnsSegment(0, 0, 
                 Arrays.asList(new ColumnSegment(0, 0, new IdentifierValue("id")), new ColumnSegment(0, 0, new IdentifierValue("name")), new ColumnSegment(0, 0, new IdentifierValue("shadow"))));
         insertStatement.setInsertColumns(insertColumnsSegment);
diff --git a/shadow-core/shadow-core-rewrite/src/test/java/org/apache/shardingsphere/shadow/rewrite/judgement/impl/SimpleJudgementEngineTest.java b/shadow-core/shadow-core-rewrite/src/test/java/org/apache/shardingsphere/shadow/rewrite/judgement/impl/SimpleJudgementEngineTest.java
index f9cfc9ebb66..b41023b9c41 100644
--- a/shadow-core/shadow-core-rewrite/src/test/java/org/apache/shardingsphere/shadow/rewrite/judgement/impl/SimpleJudgementEngineTest.java
+++ b/shadow-core/shadow-core-rewrite/src/test/java/org/apache/shardingsphere/shadow/rewrite/judgement/impl/SimpleJudgementEngineTest.java
@@ -33,6 +33,7 @@ import org.apache.shardingsphere.sql.parser.sql.segment.dml.predicate.AndPredica
 import org.apache.shardingsphere.sql.parser.sql.segment.dml.predicate.PredicateSegment;
 import org.apache.shardingsphere.sql.parser.sql.segment.dml.predicate.WhereSegment;
 import org.apache.shardingsphere.sql.parser.sql.segment.dml.predicate.value.PredicateCompareRightValue;
+import org.apache.shardingsphere.sql.parser.sql.segment.generic.TableSegment;
 import org.apache.shardingsphere.sql.parser.sql.statement.dml.InsertStatement;
 import org.apache.shardingsphere.sql.parser.sql.statement.dml.SelectStatement;
 import org.apache.shardingsphere.sql.parser.sql.value.identifier.IdentifierValue;
@@ -65,6 +66,7 @@ public final class SimpleJudgementEngineTest {
     @Test
     public void judgeForInsert() {
         InsertStatement insertStatement = new InsertStatement();
+        insertStatement.setTable(new TableSegment(0, 0, new IdentifierValue("tbl")));
         InsertColumnsSegment insertColumnsSegment = new InsertColumnsSegment(0, 0, 
                 Arrays.asList(new ColumnSegment(0, 0, new IdentifierValue("id")), new ColumnSegment(0, 0, new IdentifierValue("name")), new ColumnSegment(0, 0, new IdentifierValue("shadow"))));
         insertStatement.setInsertColumns(insertColumnsSegment);
diff --git a/sharding-core/sharding-core-merge/src/test/java/org/apache/shardingsphere/sharding/merge/ShardingResultMergerEngineTest.java b/sharding-core/sharding-core-merge/src/test/java/org/apache/shardingsphere/sharding/merge/ShardingResultMergerEngineTest.java
index acc93e029a9..0e75aca8262 100644
--- a/sharding-core/sharding-core-merge/src/test/java/org/apache/shardingsphere/sharding/merge/ShardingResultMergerEngineTest.java
+++ b/sharding-core/sharding-core-merge/src/test/java/org/apache/shardingsphere/sharding/merge/ShardingResultMergerEngineTest.java
@@ -31,6 +31,7 @@ import org.apache.shardingsphere.sql.parser.relation.statement.impl.InsertSQLSta
 import org.apache.shardingsphere.sql.parser.relation.statement.impl.SelectSQLStatementContext;
 import org.apache.shardingsphere.sql.parser.sql.segment.dml.column.ColumnSegment;
 import org.apache.shardingsphere.sql.parser.sql.segment.dml.column.InsertColumnsSegment;
+import org.apache.shardingsphere.sql.parser.sql.segment.generic.TableSegment;
 import org.apache.shardingsphere.sql.parser.sql.statement.dal.dialect.postgresql.ShowStatement;
 import org.apache.shardingsphere.sql.parser.sql.statement.dml.InsertStatement;
 import org.apache.shardingsphere.sql.parser.sql.statement.dml.SelectStatement;
@@ -68,6 +69,7 @@ public final class ShardingResultMergerEngineTest {
     public void assertNewInstanceWithOtherStatement() {
         InsertStatement insertStatement = new InsertStatement();
         InsertColumnsSegment insertColumnsSegment = new InsertColumnsSegment(0, 0, Collections.singletonList(new ColumnSegment(0, 0, new IdentifierValue("col"))));
+        insertStatement.setTable(new TableSegment(0, 0, new IdentifierValue("tbl")));
         insertStatement.setInsertColumns(insertColumnsSegment);
         SQLStatementContext sqlStatementContext = new InsertSQLStatementContext(null, Collections.emptyList(), insertStatement);
         ShardingSphereProperties properties = new ShardingSphereProperties(new Properties());
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/sql/statement/ddl/TruncateStatement.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/sql/statement/ddl/TruncateStatement.java
index 6a3b21f8ea9..126cf67fd94 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/sql/statement/ddl/TruncateStatement.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/sql/statement/ddl/TruncateStatement.java
@@ -31,4 +31,9 @@ import java.util.LinkedList;
 public final class TruncateStatement extends DDLStatement implements TableSegmentsAvailable {
     
     private final Collection<TableSegment> tables = new LinkedList<>();
+    
+    @Override
+    public Collection<TableSegment> getAllTables() {
+        return tables;
+    }
 }
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/sql/statement/dml/DeleteStatement.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/sql/statement/dml/DeleteStatement.java
index bc1b67ff0dc..90d8a9e0f46 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/sql/statement/dml/DeleteStatement.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/sql/statement/dml/DeleteStatement.java
@@ -39,6 +39,11 @@ public final class DeleteStatement extends DMLStatement implements TableSegments
     
     private WhereSegment where;
     
+    @Override
+    public Collection<TableSegment> getAllTables() {
+        return tables;
+    }
+    
     @Override
     public Optional<WhereSegment> getWhere() {
         return Optional.fromNullable(where);
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/sql/statement/dml/UpdateStatement.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/sql/statement/dml/UpdateStatement.java
index e7d40566355..4d0481dbffa 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/sql/statement/dml/UpdateStatement.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/sql/statement/dml/UpdateStatement.java
@@ -42,6 +42,11 @@ public final class UpdateStatement extends DMLStatement implements TableSegments
     
     private WhereSegment where;
     
+    @Override
+    public Collection<TableSegment> getAllTables() {
+        return tables;
+    }
+    
     @Override
     public Optional<WhereSegment> getWhere() {
         return Optional.fromNullable(where);
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-relation/src/test/java/org/apache/shardingsphere/sql/parser/relation/segment/select/projection/engine/ProjectionsContextEngineTest.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-relation/src/test/java/org/apache/shardingsphere/sql/parser/relation/segment/select/projection/engine/ProjectionsContextEngineTest.java
index 58679efe7c7..1792b4290e2 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-relation/src/test/java/org/apache/shardingsphere/sql/parser/relation/segment/select/projection/engine/ProjectionsContextEngineTest.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-relation/src/test/java/org/apache/shardingsphere/sql/parser/relation/segment/select/projection/engine/ProjectionsContextEngineTest.java
@@ -156,7 +156,7 @@ public final class ProjectionsContextEngineTest {
         OwnerSegment owner = new OwnerSegment(0, 10, new IdentifierValue("name"));
         table.setOwner(new OwnerSegment(0, 10, new IdentifierValue("name")));
         shorthandProjectionSegment.setOwner(owner);
-        when(selectStatement.getTables()).thenReturn(Collections.singletonList(tableSegment));
+        when(selectStatement.getAllTables()).thenReturn(Collections.singletonList(tableSegment));
         ColumnSegment columnSegment = new ColumnSegment(0, 0, new IdentifierValue("col"));
         columnSegment.setOwner(owner);
         ColumnProjectionSegment columnProjectionSegment = new ColumnProjectionSegment("ColumnProjectionSegment", columnSegment);
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-relation/src/test/java/org/apache/shardingsphere/sql/parser/relation/segment/table/TablesContextTest.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-relation/src/test/java/org/apache/shardingsphere/sql/parser/relation/segment/table/TablesContextTest.java
index 9909a78d8a2..dc7bcaae43f 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-relation/src/test/java/org/apache/shardingsphere/sql/parser/relation/segment/table/TablesContextTest.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-relation/src/test/java/org/apache/shardingsphere/sql/parser/relation/segment/table/TablesContextTest.java
@@ -51,7 +51,7 @@ public final class TablesContextTest {
     @Test
     public void assertIsNotEmpty() {
         SelectStatement selectStatement = new SelectStatement();
-        selectStatement.getTables().add(createTableSegment("table", "tbl"));
+        selectStatement.getAllTables().add(createTableSegment("table", "tbl"));
         TablesContext tablesContext = new TablesContext(selectStatement);
         assertFalse(tablesContext.isEmpty());
     }
@@ -59,7 +59,7 @@ public final class TablesContextTest {
     @Test
     public void assertIsSingleTable() {
         SelectStatement selectStatement = new SelectStatement();
-        selectStatement.getTables().add(createTableSegment("table", "tbl"));
+        selectStatement.getAllTables().add(createTableSegment("table", "tbl"));
         TablesContext tablesContext = new TablesContext(selectStatement);
         assertTrue(tablesContext.isSingleTable());
     }
@@ -67,8 +67,8 @@ public final class TablesContextTest {
     @Test
     public void assertIsSingleTableWithCaseSensitiveNames() {
         SelectStatement selectStatement = new SelectStatement();
-        selectStatement.getTables().add(createTableSegment("table", "tbl"));
-        selectStatement.getTables().add(createTableSegment("Table", null));
+        selectStatement.getAllTables().add(createTableSegment("table", "tbl"));
+        selectStatement.getAllTables().add(createTableSegment("Table", null));
         TablesContext tablesContext = new TablesContext(selectStatement);
         assertTrue(tablesContext.isSingleTable());
     }
@@ -76,8 +76,8 @@ public final class TablesContextTest {
     @Test
     public void assertIsSingleTableWithNameConflictAlias() {
         SelectStatement selectStatement = new SelectStatement();
-        selectStatement.getTables().add(createTableSegment("table", "tbl"));
-        selectStatement.getTables().add(createTableSegment("tbl", null));
+        selectStatement.getAllTables().add(createTableSegment("table", "tbl"));
+        selectStatement.getAllTables().add(createTableSegment("tbl", null));
         TablesContext tablesContext = new TablesContext(selectStatement);
         assertTrue(tablesContext.isSingleTable());
     }
@@ -85,8 +85,8 @@ public final class TablesContextTest {
     @Test
     public void assertIsNotSingleTable() {
         SelectStatement selectStatement = new SelectStatement();
-        selectStatement.getTables().add(createTableSegment("table_1", "tbl_1"));
-        selectStatement.getTables().add(createTableSegment("table_2", "tbl_2"));
+        selectStatement.getAllTables().add(createTableSegment("table_1", "tbl_1"));
+        selectStatement.getAllTables().add(createTableSegment("table_2", "tbl_2"));
         TablesContext tablesContext = new TablesContext(selectStatement);
         assertFalse(tablesContext.isSingleTable());
     }
@@ -94,7 +94,7 @@ public final class TablesContextTest {
     @Test
     public void assertGetSingleTableName() {
         SelectStatement selectStatement = new SelectStatement();
-        selectStatement.getTables().add(createTableSegment("table", "tbl"));
+        selectStatement.getAllTables().add(createTableSegment("table", "tbl"));
         TablesContext tablesContext = new TablesContext(selectStatement);
         assertThat(tablesContext.getSingleTableName(), is("table"));
     }
@@ -102,8 +102,8 @@ public final class TablesContextTest {
     @Test
     public void assertGetTableNames() {
         SelectStatement selectStatement = new SelectStatement();
-        selectStatement.getTables().add(createTableSegment("table_1", "tbl_1"));
-        selectStatement.getTables().add(createTableSegment("table_2", "tbl_2"));
+        selectStatement.getAllTables().add(createTableSegment("table_1", "tbl_1"));
+        selectStatement.getAllTables().add(createTableSegment("table_2", "tbl_2"));
         TablesContext tablesContext = new TablesContext(selectStatement);
         assertThat(tablesContext.getTableNames(), CoreMatchers.<Collection<String>>is(Sets.newHashSet("table_1", "table_2")));
     }
@@ -111,8 +111,8 @@ public final class TablesContextTest {
     @Test
     public void assertFindTableWithName() {
         SelectStatement selectStatement = new SelectStatement();
-        selectStatement.getTables().add(createTableSegment("table_1", "tbl_1"));
-        selectStatement.getTables().add(createTableSegment("table_2", "tbl_2"));
+        selectStatement.getAllTables().add(createTableSegment("table_1", "tbl_1"));
+        selectStatement.getAllTables().add(createTableSegment("table_2", "tbl_2"));
         TablesContext tablesContext = new TablesContext(selectStatement);
         Optional<Table> table = tablesContext.find("table_1");
         assertTrue(table.isPresent());
@@ -123,8 +123,8 @@ public final class TablesContextTest {
     @Test
     public void assertFindTableWithAlias() {
         SelectStatement selectStatement = new SelectStatement();
-        selectStatement.getTables().add(createTableSegment("table_1", "tbl_1"));
-        selectStatement.getTables().add(createTableSegment("table_2", "tbl_2"));
+        selectStatement.getAllTables().add(createTableSegment("table_1", "tbl_1"));
+        selectStatement.getAllTables().add(createTableSegment("table_2", "tbl_2"));
         TablesContext tablesContext = new TablesContext(selectStatement);
         Optional<Table> table = tablesContext.find("tbl_1");
         assertTrue(table.isPresent());
@@ -135,8 +135,8 @@ public final class TablesContextTest {
     @Test
     public void assertNotFoundTable() {
         SelectStatement selectStatement = new SelectStatement();
-        selectStatement.getTables().add(createTableSegment("table_1", "tbl_1"));
-        selectStatement.getTables().add(createTableSegment("table_2", "tbl_2"));
+        selectStatement.getAllTables().add(createTableSegment("table_1", "tbl_1"));
+        selectStatement.getAllTables().add(createTableSegment("table_2", "tbl_2"));
         TablesContext tablesContext = new TablesContext(selectStatement);
         Optional<Table> table = tablesContext.find("table_3");
         assertFalse(table.isPresent());
@@ -145,15 +145,15 @@ public final class TablesContextTest {
     @Test
     public void assertFindTableNameWhenSingleTable() {
         SelectStatement selectStatement = new SelectStatement();
-        selectStatement.getTables().add(createTableSegment("table_1", "tbl_1"));
+        selectStatement.getAllTables().add(createTableSegment("table_1", "tbl_1"));
         assertTrue(new TablesContext(selectStatement).findTableName(null, null).isPresent());
     }
     
     @Test
     public void assertFindTableNameWhenColumnSegmentOwnerPresent() {
         SelectStatement selectStatement = new SelectStatement();
-        selectStatement.getTables().add(createTableSegment("table_1", "tbl_1"));
-        selectStatement.getTables().add(createTableSegment("table_2", "tbl_2"));
+        selectStatement.getAllTables().add(createTableSegment("table_1", "tbl_1"));
+        selectStatement.getAllTables().add(createTableSegment("table_2", "tbl_2"));
         TablesContext tablesContext = new TablesContext(selectStatement);
         ColumnSegment columnSegment = mock(ColumnSegment.class);
         when(columnSegment.getOwner()).thenReturn(Optional.of(new OwnerSegment(0, 10, new IdentifierValue("table_1"))));
@@ -163,8 +163,8 @@ public final class TablesContextTest {
     @Test
     public void assertFindTableNameWhenColumnSegmentOwnerAbsent() {
         SelectStatement selectStatement = new SelectStatement();
-        selectStatement.getTables().add(createTableSegment("table_1", "tbl_1"));
-        selectStatement.getTables().add(createTableSegment("table_2", "tbl_2"));
+        selectStatement.getAllTables().add(createTableSegment("table_1", "tbl_1"));
+        selectStatement.getAllTables().add(createTableSegment("table_2", "tbl_2"));
         TablesContext tablesContext = new TablesContext(selectStatement);
         ColumnSegment columnSegment = new ColumnSegment(0, 0, new IdentifierValue("col"));
         RelationMetas relationMetas = mock(RelationMetas.class);
@@ -174,8 +174,8 @@ public final class TablesContextTest {
     @Test
     public void assertFindTableNameWhenColumnSegmentOwnerAbsentAndRelationMetasContainsColumn() {
         SelectStatement selectStatement = new SelectStatement();
-        selectStatement.getTables().add(createTableSegment("table_1", "tbl_1"));
-        selectStatement.getTables().add(createTableSegment("table_2", "tbl_2"));
+        selectStatement.getAllTables().add(createTableSegment("table_1", "tbl_1"));
+        selectStatement.getAllTables().add(createTableSegment("table_2", "tbl_2"));
         ColumnSegment columnSegment = new ColumnSegment(0, 0, new IdentifierValue("col"));
         RelationMetas relationMetas = mock(RelationMetas.class);
         when(relationMetas.containsColumn(anyString(), anyString())).thenReturn(true);
@@ -185,7 +185,7 @@ public final class TablesContextTest {
     @Test
     public void assertGetSchema() {
         SelectStatement selectStatement = new SelectStatement();
-        selectStatement.getTables().add(createTableSegment("table_1", "tbl_1"));
+        selectStatement.getAllTables().add(createTableSegment("table_1", "tbl_1"));
         assertFalse(new TablesContext(selectStatement).getSchema().isPresent());
     }
     
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/test/java/org/apache/shardingsphere/sql/parser/integrate/asserts/statement/ddl/impl/AlterTableStatementAssert.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/test/java/org/apache/shardingsphere/sql/parser/integrate/asserts/statement/ddl/impl/AlterTableStatementAssert.java
index e3fe5e35700..8aadf7db657 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/test/java/org/apache/shardingsphere/sql/parser/integrate/asserts/statement/ddl/impl/AlterTableStatementAssert.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/test/java/org/apache/shardingsphere/sql/parser/integrate/asserts/statement/ddl/impl/AlterTableStatementAssert.java
@@ -68,8 +68,7 @@ public final class AlterTableStatementAssert {
     }
     
     private static void assertTable(final SQLCaseAssertContext assertContext, final AlterTableStatement actual, final AlterTableStatementTestCase expected) {
-        // TODO split old table and new table
-        TableAssert.assertIs(assertContext, actual.getTables(), expected.getTables());
+        TableAssert.assertIs(assertContext, actual.getTable(), expected.getTable());
     }
     
     private static void assertAddColumnDefinitions(final SQLCaseAssertContext assertContext, final AlterTableStatement actual, final AlterTableStatementTestCase expected) {
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/test/java/org/apache/shardingsphere/sql/parser/integrate/asserts/statement/ddl/impl/CreateTableStatementAssert.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/test/java/org/apache/shardingsphere/sql/parser/integrate/asserts/statement/ddl/impl/CreateTableStatementAssert.java
index 4eb6b07a188..c96a0e50a92 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/test/java/org/apache/shardingsphere/sql/parser/integrate/asserts/statement/ddl/impl/CreateTableStatementAssert.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/test/java/org/apache/shardingsphere/sql/parser/integrate/asserts/statement/ddl/impl/CreateTableStatementAssert.java
@@ -54,8 +54,7 @@ public final class CreateTableStatementAssert {
     }
     
     private static void assertTable(final SQLCaseAssertContext assertContext, final CreateTableStatement actual, final CreateTableStatementTestCase expected) {
-        // TODO split table and fk table
-        TableAssert.assertIs(assertContext, actual.getTables(), expected.getTables());
+        TableAssert.assertIs(assertContext, actual.getTable(), expected.getTable());
     }
     
     private static void assertColumnDefinitions(final SQLCaseAssertContext assertContext, final CreateTableStatement actual, final CreateTableStatementTestCase expected) {
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/test/java/org/apache/shardingsphere/sql/parser/integrate/jaxb/domain/statement/ddl/AlterTableStatementTestCase.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/test/java/org/apache/shardingsphere/sql/parser/integrate/jaxb/domain/statement/ddl/AlterTableStatementTestCase.java
index c5dbab6077f..47fa9eedc06 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/test/java/org/apache/shardingsphere/sql/parser/integrate/jaxb/domain/statement/ddl/AlterTableStatementTestCase.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/test/java/org/apache/shardingsphere/sql/parser/integrate/jaxb/domain/statement/ddl/AlterTableStatementTestCase.java
@@ -38,7 +38,7 @@ import java.util.List;
 public final class AlterTableStatementTestCase extends SQLParserTestCase {
     
     @XmlElement(name = "table")
-    private final List<ExpectedTable> tables = new LinkedList<>();
+    private ExpectedTable table;
     
     @XmlElement(name = "add-column")
     private final List<ExpectedAddColumnDefinition> addColumns = new LinkedList<>();
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/test/java/org/apache/shardingsphere/sql/parser/integrate/jaxb/domain/statement/ddl/CreateTableStatementTestCase.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/test/java/org/apache/shardingsphere/sql/parser/integrate/jaxb/domain/statement/ddl/CreateTableStatementTestCase.java
index a640dcd07c4..c711127f820 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/test/java/org/apache/shardingsphere/sql/parser/integrate/jaxb/domain/statement/ddl/CreateTableStatementTestCase.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/test/java/org/apache/shardingsphere/sql/parser/integrate/jaxb/domain/statement/ddl/CreateTableStatementTestCase.java
@@ -18,6 +18,7 @@
 package org.apache.shardingsphere.sql.parser.integrate.jaxb.domain.statement.ddl;
 
 import lombok.Getter;
+import lombok.Setter;
 import org.apache.shardingsphere.sql.parser.integrate.jaxb.domain.segment.impl.definition.ExpectedColumnDefinition;
 import org.apache.shardingsphere.sql.parser.integrate.jaxb.domain.segment.impl.definition.ExpectedConstraintDefinition;
 import org.apache.shardingsphere.sql.parser.integrate.jaxb.domain.segment.impl.index.ExpectedIndex;
@@ -32,10 +33,11 @@ import java.util.List;
  * Create table statement test case.
  */
 @Getter
+@Setter
 public final class CreateTableStatementTestCase extends SQLParserTestCase {
     
     @XmlElement(name = "table")
-    private final List<ExpectedTable> tables = new LinkedList<>();
+    private ExpectedTable table;
     
     @XmlElement(name = "column-definition")
     private final List<ExpectedColumnDefinition> columnDefinitions = new LinkedList<>();
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/test/resources/sql/ddl/alter-table.xml b/shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/test/resources/sql/ddl/alter-table.xml
index 9869588e8ee..4cca4b4f95d 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/test/resources/sql/ddl/alter-table.xml
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/test/resources/sql/ddl/alter-table.xml
@@ -439,7 +439,6 @@
     
     <alter-table sql-case-id="alter_table_add_constraints">
         <table name="t_order_item" start-index="12" stop-index="23" />
-        <table name="t_order" start-index="113" stop-index="119" />
         <add-constraint>
             <primary-key-column name="order_id" start-index="42" stop-index="49" />
         </add-constraint>
@@ -621,7 +620,6 @@
     
     <alter-table sql-case-id="alter_table_add_foreign_key_with_cascade">
         <table name="t_order_item" start-index="12" stop-index="23" />
-        <table name="t_order" start-index="86" stop-index="92" />
         <add-constraint>
             <referenced-table name="t_order" start-index="86" stop-index="92" />
         </add-constraint>
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/test/resources/sql/ddl/create-table.xml b/shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/test/resources/sql/ddl/create-table.xml
index 7494d0c1493..8855bec88c5 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/test/resources/sql/ddl/create-table.xml
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/test/resources/sql/ddl/create-table.xml
@@ -312,8 +312,6 @@
     
     <create-table sql-case-id="create_table_with_inline_foreign_key">
         <table name="t_order_item" start-index="13" stop-index="24" />
-        <!-- FIXME remove t_order assert -->
-        <table name="t_order" start-index="64" stop-index="70" />
         <column-definition type="INT">
             <column name="item_id" />
         </column-definition>
@@ -461,7 +459,6 @@
     
     <create-table sql-case-id="create_table_with_out_of_line_foreign_key">
         <table name="t_order_item" start-index="13" stop-index="24" />
-        <table name="t_order" start-index="207" stop-index="213" />
         <column-definition type="INT">
             <column name="item_id" />
         </column-definition>
@@ -490,7 +487,6 @@
     
     <create-table sql-case-id="create_table_with_out_of_line_composite_foreign_key">
         <table name="t_order_item" start-index="13" stop-index="24" />
-        <table name="t_order" start-index="224" stop-index="230" />
         <column-definition type="INT">
             <column name="item_id" />
         </column-definition>
@@ -542,7 +538,6 @@
     
     <create-table sql-case-id="create_table_with_out_of_line_constraints">
         <table name="t_order_item" start-index="13" stop-index="24" />
-        <table name="t_order" start-index="225" stop-index="231" />
         <column-definition type="INT">
             <column name="item_id" />
         </column-definition>
@@ -790,8 +785,6 @@
     
     <create-table sql-case-id="create_table_with_inline_foreign_key_reference">
         <table name="t_order_item" start-index="13" stop-index="24" />
-        <!-- FIXME remove t_order table segment-->
-        <table name="t_order" start-index="101" stop-index="107" />
         <column-definition type="NUMBER">
             <column name="item_id" />
         </column-definition>
@@ -840,7 +833,6 @@
     
     <create-table sql-case-id="create_table_with_inline_constraints_cascade">
         <table name="t_order_item" start-index="13" stop-index="24" />
-        <table name="t_order" start-index="150" stop-index="156" />
         <column-definition type="NUMBER" primary-key="true">
             <column name="item_id" />
         </column-definition>
@@ -867,7 +859,6 @@
     
     <create-table sql-case-id="create_table_with_out_of_line_foreign_key_oracle">
         <table name="t_order_item" start-index="13" stop-index="24" />
-        <table name="t_order" start-index="232" stop-index="238" />
         <column-definition type="NUMBER">
             <column name="item_id" />
         </column-definition>
@@ -896,7 +887,6 @@
     
     <create-table sql-case-id="create_table_with_out_of_line_composite_foreign_key_oracle">
         <table name="t_order_item" start-index="13" stop-index="24" />
-        <table name="t_order" start-index="249" stop-index="255" />
         <column-definition type="NUMBER">
             <column name="item_id" />
         </column-definition>
@@ -925,7 +915,6 @@
     
     <create-table sql-case-id="create_table_with_out_of_line_constraints_oracle">
         <table name="t_order_item" start-index="13" stop-index="24" />
-        <table name="t_order" start-index="250" stop-index="256" />
         <column-definition type="NUMBER">
             <column name="item_id" />
         </column-definition>
@@ -1235,7 +1224,6 @@
     
     <create-table sql-case-id="create_table_with_inline_foreign_key_sqlserver">
         <table name="t_order_item" start-index="13" stop-index="24" />
-        <table name="t_order" start-index="87" stop-index="93" />
         <column-definition type="INT">
             <column name="item_id" />
         </column-definition>