Describes the properties of a schema in a database system.

A schema is a collection of database objects (for example TABLE, VIEW, TYPE, TRIEGGER, etc.).

It is possible for a schema to specify additional metadata information, such as the culture that will be used by default to collate strings in comparisons.

It is not possible to define more than one schema with the same name in a database.

Inheritance: IObjectInfo
コード例 #1
0
ファイル: Schema.cs プロジェクト: deveel/deveeldb
        public Schema(SchemaInfo schemaInfo)
        {
            if (schemaInfo == null)
                throw new ArgumentNullException("schemaInfo");

            SchemaInfo = schemaInfo;
        }
コード例 #2
0
ファイル: SchemaManager.cs プロジェクト: deveel/deveeldb
        public void CreateSchema(SchemaInfo schemaInfo)
        {
            if (schemaInfo == null)
                throw new ArgumentNullException("schemaInfo");

            var tableName = SystemSchema.SchemaInfoTableName;
            var t = Transaction.GetMutableTable(tableName);

            var nameObj = Field.String(schemaInfo.Name);

            if (t.Exists(1, nameObj))
                throw new DatabaseSystemException(String.Format("Schema '{0}' already defined in the database.", schemaInfo.Name));

            var row = t.NewRow();
            var uniqueId = Transaction.NextTableId(tableName);
            row.SetValue(0, Field.Number(uniqueId));
            row.SetValue(1, Field.String(schemaInfo.Name));
            row.SetValue(2, Field.String(schemaInfo.Type));
            row.SetValue(3, Field.String(schemaInfo.Culture));

            t.AddRow(row);
        }
コード例 #3
0
        // TODO: move this elsewhere
        public static void CreateSystemSchema(this ITransaction transaction)
        {
            transaction.CreateSystem();

            // TODO: get the configured default culture...
            var culture = CultureInfo.CurrentCulture.Name;
            var schemaInfo = new SchemaInfo(SystemSchema.Name, SchemaTypes.System);
            schemaInfo.Culture = culture;

            transaction.CreateSchema(schemaInfo);
        }
コード例 #4
0
 public static void CreateSchema(this ITransaction transaction, SchemaInfo schemaInfo)
 {
     transaction.CreateObject(schemaInfo);
 }
コード例 #5
0
ファイル: SchemaManager.cs プロジェクト: deveel/deveeldb
        public Schema GetSchema(string name)
        {
            if (String.IsNullOrEmpty(name))
                throw new ArgumentNullException("name");

            var tableName = SystemSchema.SchemaInfoTableName;
            var t = Transaction.GetMutableTable(tableName);

            var nameObj = Field.String(name);

            var rows = t.SelectRows(1, SqlExpressionType.Equal, nameObj).ToArray();
            if (rows.Length == 0)
                return null;

            if (rows.Length > 1)
                throw new InvalidOperationException();

            var row = rows[0];

            var schemaName = t.GetValue(row, 1).Value.ToString();
            var schemaType = t.GetValue(row, 2).Value.ToString();
            var culture = t.GetValue(row, 3);

            var schemaInfo = new SchemaInfo(schemaName, schemaType);

            if (!culture.IsNull)
                schemaInfo.Culture = culture.Value.ToString();

            return new Schema(schemaInfo);
        }