English 中文(简体)
我能否将一栏从NOT NUL改为NUL,而不会放弃?
原标题:Can I change a column from NOT NULL to NULL without dropping it?
  • 时间:2011-09-13 19:54:08
  •  标签:
  • sql-server

有必要修改一个表格,以便一栏中不作任何改动,但可以删除一栏。 正在尝试像:

ALTER TABLE myTable MODIFY myColumn NULL;

但无济于事。

最佳回答
ALTER TABLE myTable ALTER COLUMN myColumn {DataType} NULL

<代码>-DataType}为该栏的现有数据类型(例如<代码>int或varchar(10))

问题回答

Sure you can.

ALTER TABLE myTable ALTER COLUMN myColumn int NULL

每栏中任何数据类型都只是替代的。

该星群非常以数据库服务为基础。

<>SQL服务器/MS Access:

ALTER TABLE table_name
ALTER COLUMN column_name datatype NULL;

Mykou /Oracle (prior edition 10G):

ALTER TABLE table_name
MODIFY COLUMN column_name datatype NULL;

Oracle 10G and subsequently:

ALTER TABLE table_name
MODIFY column_name datatype NULL;

如果你想设定一个违约值:

ALTER TABLE table_name
ALTER COLUMN column_name datatype DEFAULT default_value;

MYSQL

ALTER TABLE myTable MODIFY myColumn {DataType} NULL




相关问题
Export tables from SQL Server to be imported to Oracle 10g

I m trying to export some tables from SQL Server 2005 and then create those tables and populate them in Oracle. I have about 10 tables, varying from 4 columns up to 25. I m not using any constraints/...

SQL server: Can NT accounts be mapped to SQL server accounts

In our database we have an SQL server account that has the correct roles to access some of the databases. We are now switching to windows authentication and I was wondering if we can create a NT user ...

SQL Server 2000, ADO 2.8, VB6

How to determine if a Transaction is active i.e. before issuing Begin Transaction I want to ensure that no previous transaction are open.. the platform is VB6, MS-SQL Server 2000 and ADO 2.8

热门标签