Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Altering a column to be nullable

Tags:

sql

I want to alter a table column to be nullable. I have used:

ALTER TABLE Merchant_Pending_Functions Modify NumberOfLocations NULL 

This gives an error at Modify. What is the correct syntax?

like image 488
challengeAccepted Avatar asked Aug 24 '10 13:08

challengeAccepted


People also ask

What does it mean for a column to be nullable?

It means, if a column nullable type is defined as 0, it means it cannot be NULL, every time it will have some value.

How do I create a nullable column in SQL?

Example# When creating tables it is possible to declare a column as nullable or non-nullable. CREATE TABLE MyTable ( MyCol1 INT NOT NULL, -- non-nullable MyCol2 INT NULL -- nullable ) ; By default every column (except those in primary key constraint) is nullable unless we explicitly set NOT NULL constraint.

How do I change a column to nullable in Oracle?

1) Select the table in which you want to modify changes. 2) Click on Actions.. ---> select column ----> add. 3) Now give the column name, datatype, size, etc.


1 Answers

Assuming SQL Server (based on your previous questions):

ALTER TABLE Merchant_Pending_Functions ALTER COLUMN NumberOfLocations INT NULL 

Replace INT with your actual datatype.

like image 178
Quassnoi Avatar answered Oct 16 '22 14:10

Quassnoi