protected virtual Command OnCreateTable(IMetadata sourceMetadata, IMetadata targetMetadata, IComparerContext context) { var command = new Command(); var isGtt = MetadataRelationType == MetadataRelationType.GlobalTemporaryPreserve || MetadataRelationType == MetadataRelationType.GlobalTemporaryDelete; var isExternal = MetadataRelationType == MetadataRelationType.External; command.Append("CREATE "); if (isGtt) { command.Append("GLOBAL TEMPORARY "); } command.Append($"TABLE {RelationName.AsSqlIndentifier()} "); if (isExternal) { command.Append($"EXTERNAL '{SqlHelper.DoubleSingleQuotes(ExternalFile)}' "); } command.Append("("); command.AppendLine(); InsertColumns(command, sourceMetadata, targetMetadata, context, false); command.AppendLine(); command.Append(")"); if (isGtt) { command.AppendLine(); command.Append($"ON COMMIT {MetadataRelationType.ToDescription()} ROWS"); } if (SqlSecurity != null) { command.AppendLine(); command.Append($"SQL SECURITY {SqlHelper.SqlSecurityString(SqlSecurity)}"); } return(command); }
protected virtual Command OnCreateTable(IMetadata sourceMetadata, IMetadata targetMetadata, IComparerContext context) { var command = new Command(); var isGtt = MetadataRelationType == MetadataRelationType.GLOBAL_TEMPORARY_PRESERVE || MetadataRelationType == MetadataRelationType.GLOBAL_TEMPORARY_DELETE; var isExternal = MetadataRelationType == MetadataRelationType.EXTERNAL; command.Append("CREATE "); if (isGtt) { command.Append("GLOBAL TEMPORARY "); } command.Append($"TABLE {RelationName.AsSqlIndentifier()} "); if (isExternal) { command.Append($"EXTERNAL '{SqlHelper.DoubleSingleQuotes(ExternalFile)}' "); } command.Append("("); command.AppendLine(); InsertColumns(command, sourceMetadata, targetMetadata, context, false); command.AppendLine(); command.Append(")"); if (isGtt) { command.AppendLine(); command.Append($"ON COMMIT {MetadataRelationType.ToDescription()} ROWS"); } return(command); }