Exemple #1
0
        public void Create(IEnumerable <string> columnDefinitions)
        {
            var sb = new StringBuilder();

            var quotedSchema = _quoter.QuoteSchemaName(_schemaName);

            if (!string.IsNullOrEmpty(quotedSchema))
            {
                sb.AppendFormat("CREATE SCHEMA {0};", quotedSchema);
            }

            sb.Append("CREATE TABLE ");

            sb.Append(NameWithSchema);
            sb.Append(" (");

            foreach (string definition in columnDefinitions)
            {
                sb.Append(definition);
                sb.Append(", ");
            }

            sb.Remove(sb.Length - 2, 2);
            sb.Append(")");

            var s = sb.ToString();

            using (var command = new HanaCommand(s, Connection, Transaction))
                command.ExecuteNonQuery();
        }
Exemple #2
0
        public void Create(string[] columnDefinitions)
        {
            var sb = new StringBuilder();

            if (!string.IsNullOrEmpty(_schema))
            {
                sb.AppendFormat("CREATE SCHEMA {0};", _quoter.QuoteSchemaName(_schema));
            }

            var columns = string.Join(", ", columnDefinitions);

            sb.AppendFormat("CREATE TABLE {0} ({1})", NameWithSchema, columns);

            Processor.Execute(sb.ToString());
        }
        public void Create(SqlServerProcessor processor, IEnumerable <string> columnDefinitions)
        {
            if (!string.IsNullOrEmpty(_schemaName) && !processor.SchemaExists(_schemaName))
            {
                using (var command = new SqlCommand(string.Format("CREATE SCHEMA {0}", _quoter.QuoteSchemaName(_schemaName)), Connection, Transaction))
                    command.ExecuteNonQuery();
            }

            var quotedObjectName = _quoter.QuoteTableName(Name, _schemaName);

            var sb = new StringBuilder();

            sb.AppendFormat("CREATE TABLE ");
            sb.Append(quotedObjectName);

            sb.Append("(");
            foreach (string definition in columnDefinitions)
            {
                sb.Append(definition);
                sb.Append(", ");
            }

            sb.Remove(sb.Length - 2, 2);
            sb.Append(")");

            using (var command = new SqlCommand(sb.ToString(), Connection, Transaction))
                command.ExecuteNonQuery();
        }
Exemple #4
0
        public string Generate(CreateSchemaExpression expression)
        {
            var schemaPassword = expression.SchemaName;

            if (expression.SchemaName.Equals(DbMigrationConfig.Schema,
                                             StringComparison.OrdinalIgnoreCase))
            {
                schemaPassword = DbMigrationConfig.SchemaPassword;
            }

            if (string.IsNullOrEmpty(schemaPassword))
            {
                schemaPassword = expression.SchemaName;
            }

            using (var writer = new StringWriter())
            {
                writer.WriteLine(CreateSchemaSqlTemplate,
                                 Quoter.QuoteSchemaName(expression.SchemaName),
                                 Quoter.QuoteSchemaName(schemaPassword),
                                 Quoter.QuoteSchemaName(DbMigrationConfig.DefaultTablespace),
                                 Quoter.QuoteSchemaName(DbMigrationConfig.TempTablespace));
                writer.WriteLine(";");
                writer.WriteLine(GrantTableSpaceAccess(expression.SchemaName));
                writer.WriteLine(";");
                writer.WriteLine(GrantSessionAccess(expression.SchemaName));

                return(writer.ToString());
            };
        }
        public void Create(string[] columnDefinitions)
        {
            var sb = new StringBuilder();

            if (!string.IsNullOrEmpty(_schema))
            {
                sb.AppendFormat("CREATE SCHEMA {0} ", quoter.QuoteSchemaName(_schema));
            }

            var columns = string.Join(", ", columnDefinitions);

            sb.AppendFormat("CREATE TABLE {0} ({1})", NameWithSchema, columns);

            using (var command = Factory.CreateCommand(sb.ToString(), Connection, Transaction, Processor.Options))
            {
                command.ExecuteNonQuery();
            }
        }
 public string Generate(DeleteSchemaExpression expression)
 {
     return(string.Format(DropSchemaSqlTemplate, Quoter.QuoteSchemaName(expression.SchemaName)));
 }