如何将员工表中工资列的列大小从数字(18,0)更改为数字(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是仅元数据的操作。

其他回答

对于Oracle数据库:

VARCHAR2(255 CHAR);

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

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

修改列大小的语法为

ALTER table table_name modify COLUMN column_name varchar (size);

有趣的方法可以在这里找到:如何扩大你的专栏没有停机由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 [Employee]
ALTER COLUMN [Salary] NUMERIC(22,5) NOT NULL