zoukankan      html  css  js  c++  java
  • The object 'DF__*' is dependent on column '*'

    The object 'DF__*' is dependent on column '*' - Changing int to double

    Try this:

    Remove the constraint DF_Movies_Rating__48CFD27E before changing your field type.

    The constraint is typically created automatically by the DBMS (SQL Server).

    To see the constraint associated with the table, expand the table attributes in Object explorer, followed by the category Constraints as shown below:

     You must remove the constraint before changing the field type.

    Changing the size of a column referenced by a schema-bound view in SQL Server

    The object 'Address_e' is dependent on column 'Addr1'.
    ALTER TABLE ALTER COLUMN Addr1 failed because one or more objects access 
    this column.

    The views are probably created using the WITH SCHEMABINDING option and this means they are explicitly wired up to prevent such changes. Looks like the schemabinding worked and prevented you from breaking those views, lucky day, heh? Contact your database administrator and ask him to do the change, after it asserts the impact on the database.

    From MSDN:

    SCHEMABINDING

    Binds the view to the schema of the underlying table or tables. When SCHEMABINDING is specified, the base table or tables cannot be modified in a way that would affect the view definition. The view definition itself must first be modified or dropped to remove dependencies on the table that is to be modified.

    CREATE VIEW (Transact-SQL)

    SCHEMABINDING
    Binds the view to the schema of the underlying table or tables. When SCHEMABINDING is specified, the base table or tables cannot be modified in a way that would affect the view definition. The view definition itself must first be modified or dropped to remove dependencies on the table that is to be modified. When you use SCHEMABINDING, the select_statement must include the two-part names (schema.object) of tables, views, or user-defined functions that are referenced. All referenced objects must be in the same database.

    Views or tables that participate in a view created with the SCHEMABINDING clause cannot be dropped unless that view is dropped or changed so that it no longer has schema binding. Otherwise, the Database Engine raises an error. Also, executing ALTER TABLE statements on tables that participate in views that have schema binding fail when these statements affect the view definition.

    USE master;
    IF NOT EXISTS (SELECT * FROM sys.databases WHERE name = 'ChuckTest')
        CREATE DATABASE ChuckTest
        ON PRIMARY
               (
                   NAME = N'ChuckTest_Data',
                   FILENAME = N'D:MSSQLSQL2014DATAChuckTest_Data.mdf',
                   SIZE = 167872KB,
                   MAXSIZE = UNLIMITED,
                   FILEGROWTH = 16384KB
               )
        LOG ON
            (
                NAME = N'ChuckTest_Log',
                FILENAME = N'D:MSSQLSQL2014DATAChuckTest_Log.ldf',
                SIZE = 2048KB,
                MAXSIZE = 2048GB,
                FILEGROWTH = 16384KB
            );
    GO
    
    USE ChuckTest;
    IF (NOT EXISTS
    (
        SELECT *
        FROM INFORMATION_SCHEMA.TABLES
        WHERE TABLE_SCHEMA = 'TheSchema'
              AND TABLE_NAME = 'Student'
    )
       )
        CREATE TABLE Student
        (
            Id INT,
            FirstName NVARCHAR(20),
            LastName NVARCHAR(20)
        );
    IF (NOT EXISTS
    (
        SELECT *
        FROM INFORMATION_SCHEMA.TABLES
        WHERE TABLE_SCHEMA = 'TheSchema'
              AND TABLE_NAME = 'Score'
    )
       )
        CREATE TABLE Score
        (
            StudentId INT,
            Score INT
        );
    
    GO
    
    CREATE VIEW V_StudentScore
    WITH SCHEMABINDING
    AS
    SELECT a.Id,
           a.FirstName,
           a.LastName,
           b.StudentId,
           b.Score
    FROM dbo.Student AS a
        INNER JOIN dbo.Score AS b
            ON a.Id = b.StudentId;
    GO
    
    DROP VIEW dbo.V_StudentScore
    ALTER TABLE Score ALTER COLUMN Score int;
  • 相关阅读:
    React.render和reactDom.render的区别
    CSS中position的4种定位详解
    React.js入门必须知道的那些事
    JS处理事件小技巧
    React.js深入学习详细解析
    React.js实现原生js拖拽效果及思考
    Linux ./configure && make && make install 编译安装和卸载
    Redis set集合结构及命令详解
    Redis数据过期策略
    Redis TTL命令
  • 原文地址:https://www.cnblogs.com/chucklu/p/14721377.html
Copyright © 2011-2022 走看看