diff --git a/src/UnicaenOracle/Service/SchemaService.php b/src/UnicaenOracle/Service/SchemaService.php
index 8056a54d23cc2cdcefe0314b0498d08d39f30864..e9750fdd29a4dad50e549cd470b9f6d4a0c1fe80 100644
--- a/src/UnicaenOracle/Service/SchemaService.php
+++ b/src/UnicaenOracle/Service/SchemaService.php
@@ -302,7 +302,7 @@ EOS;
 
         $refConstraintsSql = NULL;
         if ($refConstraintsIncluded) {
-            $refConstraintsSql = $this->generateSQLForRefConstraintsCreation($connection);
+            $refConstraintsSql = $this->generateSQLForRefConstraintsCreation($connection, true);
             $refConstraintsSql = <<<EOS
     UNION ALL
 
@@ -448,16 +448,14 @@ EOS;
 
     /**
      * @param Connection $connection
+     * @param bool       $innerSQLOnly
      * @return string
      */
-    function generateSQLForRefConstraintsCreation(Connection $connection)
+    function generateSQLForRefConstraintsCreation(Connection $connection, $innerSQLOnly = false)
     {
         $schemaName = $this->extractSchemaNameFromConnection($connection);
 
-        return <<<EOS
-        
-SELECT sql from (
-    
+        $sql = <<<EOS
     --
     -- reference constraints
     --
@@ -472,9 +470,19 @@ SELECT sql from (
     where owner = '$schemaName'
           and constraint_type = 'R'
 
+EOS;
+
+        if (! $innerSQLOnly) {
+            $sql = <<<EOS
+SELECT sql from (
+    
+    $sql
+
 )
 ORDER BY ORD
 EOS;
+        }
 
+        return $sql;
     }
 }
\ No newline at end of file