How to change column datatype in SQL database without losing data

前端 未结 11 2351
迷失自我
迷失自我 2020-12-02 06:55

I have SQL Server database and I just realized that I can change the type of one of the columns from int to bool.

How can I do that withou

相关标签:
11条回答
  • 2020-12-02 07:12

    If it is a valid change.

    you can change the property.

    Tools --> Options --> Designers --> Table and Database designers --> Uncheck --> Prevent saving changes that required table re-creation.

    Now you can easily change the column name without recreating the table or losing u r records.

    0 讨论(0)
  • 2020-12-02 07:14
    ALTER TABLE tablename
    ALTER COLUMN columnname columndatatype(size)
    

    Note: if there is a size of columns, just write the size also.

    0 讨论(0)
  • 2020-12-02 07:14

    Go to Tool-Option-designers-Table and Database designers and Uncheck Prevent saving option

    0 讨论(0)
  • 2020-12-02 07:23

    I can modify the table field's datatype, with these following query: and also in the Oracle DB,

    ALTER TABLE table_name
    MODIFY column_name datatype;
    
    0 讨论(0)
  • 2020-12-02 07:26

    Replace datatype without losing data

    alter table tablename modify columnn  newdatatype(size);
    
    0 讨论(0)
提交回复
热议问题