如何将员工表中工资列的列大小从数字(18,0)更改为数字(22,5)


当前回答

ALTER TABLE [table_name] ALTER COLUMN [column_name] varchar(150)

其他回答

ALTER TABLE [Employee]
ALTER COLUMN [Salary] NUMERIC(22,5) NOT NULL

可以使用ALTER命令修改表模式。

修改列大小的语法为

ALTER table table_name modify COLUMN column_name varchar (size);
alter table Employee alter column salary numeric(22,5)

有趣的方法可以在这里找到:如何扩大你的专栏没有停机由spaghettidba

If you try to enlarge this column with a straight “ALTER TABLE” command, you will have to wait for SQLServer to go through all the rows and write the new data type ALTER TABLE tab_name ALTER COLUMN col_name new_larger_data_type; To overcome this inconvenience, there is a magic column enlargement pill that your table can take, and it’s called Row Compression. (...) With Row Compression, your fixed size columns can use only the space needed by the smallest data type where the actual data fits.

当表在ROW级别被压缩时,ALTER table ALTER COLUMN是仅元数据的操作。

在这种情况下,您需要使用ALTER TABLE语句来增加列的大小。

下面是它的语法

ALTER TABLE table_name 修改column_name varchar (new_length);